Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions debian_component_based/emulator-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
Comment thread
anindyatahsin marked this conversation as resolved.

apt-get update && apt-get install -y lsof
Comment thread
anindyatahsin marked this conversation as resolved.

# Start the server in the background
gcloud beta emulators $1 start --host-port=0.0.0.0:8085 --project=blah &

# Wait a few seconds for the server to start
sleep 10

# Check if the server is listening on the port
if lsof -i :8085 > /dev/null; then
echo "Server started successfully (exiting with code 0)"
kill -9 $(lsof -t -i :8085)
exit 0
else
echo "Server failed to start"
exit 1
fi
31 changes: 31 additions & 0 deletions debian_component_based/test-components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

echo "Checking gsutil version"
gsutil version

echo "Checking kpt version"
kpt version

echo "Checking local-extract version"
local-extract --version

echo "Checking gke-gcloud-auth-plugin version"
gke-gcloud-auth-plugin --version

echo "Checking bq version"
bq version

echo "Checking bundled-python version"
/usr/lib/google-cloud-sdk/platform/bundledpythonunix/bin/python --version

echo "Checking cbt version"
cbt version

echo "Checking crc checksum for gcloud"
gcloud-crc32c /usr/bin/gcloud

echo "Checking kubectl version"
kubectl version

echo "Checking the emulators"
./test-all-emulators.sh
26 changes: 26 additions & 0 deletions debian_component_based/test-dcb-emulators.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

./emulator-testing.sh pubsub
if [ $? -ne 0 ]; then

echo "Pub/sub emulator failed to execute."
exit 1

fi

./emulator-testing.sh datastore
if [ $? -ne 0 ]; then

echo "Datastore emulator failed to execute."
exit 1

fi

./emulator-testing.sh bigtable
if [ $? -ne 0 ]; then

echo "Bigtable emulator failed to execute."
exit 1

fi

19 changes: 19 additions & 0 deletions emulators/emulator-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

apt-get update && apt-get install -y lsof

# Start the server in the background
gcloud beta emulators $1 start --host-port=0.0.0.0:8085 --project=blah &

# Wait a few seconds for the server to start
sleep 10

# Check if the server is listening on the port
if lsof -i :8085 > /dev/null; then
echo "Server started successfully (exiting with code 0)"
kill -9 $(lsof -t -i :8085)
exit 0
else
echo "Server failed to start"
exit 1
fi
42 changes: 42 additions & 0 deletions emulators/test-all-emulators.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

./emulator-testing.sh pubsub
if [ $? -ne 0 ]; then

echo "Pub/sub emulator failed to execute."
exit 1

fi

./emulator-testing.sh datastore
if [ $? -ne 0 ]; then

echo "Datastore emulator failed to execute."
exit 1

fi

./emulator-testing.sh firestore
if [ $? -ne 0 ]; then

echo "Firestore emulator failed to execute."
exit 1

fi

./emulator-testing.sh spanner
if [ $? -ne 0 ]; then

echo "Spanner emulator failed to execute."
exit 1

fi

./emulator-testing.sh bigtable
if [ $? -ne 0 ]; then

echo "Bigtable emulator failed to execute."
exit 1

fi

31 changes: 31 additions & 0 deletions test-latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

echo "Checking gsutil version"
gsutil version

echo "Checking kpt version"
kpt version

echo "Checking local-extract version"
local-extract --version

echo "Checking gke-gcloud-auth-plugin version"
gke-gcloud-auth-plugin --version

echo "Checking bq version"
bq version

echo "Checking bundled-python version"
/usr/lib/google-cloud-sdk/platform/bundledpythonunix/bin/python --version

echo "Checking cbt version"
cbt version

echo "Checking crc checksum for gcloud"
gcloud-crc32c /usr/bin/gcloud

echo "Checking kubectl version"
kubectl version

echo "Checking the emulators"
./test-all-emulators.sh
33 changes: 33 additions & 0 deletions testing/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM docker:27.4.1 as static-docker-source

FROM alpine:3.19
ARG CLOUD_SDK_VERSION
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
RUN addgroup -g 1000 -S cloudsdk && \
adduser -u 1000 -S cloudsdk -G cloudsdk
RUN if [ `uname -m` = 'x86_64' ]; then echo -n "x86_64" > /tmp/arch; else echo -n "arm" > /tmp/arch; fi;
RUN ARCH=`cat /tmp/arch` && apk --no-cache upgrade && apk --no-cache add \
curl \
python3 \
py3-crcmod \
py3-openssl \
bash \
libc6-compat \
openssh-client \
git \
gnupg \
&& curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
tar xzf google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
rm google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_alpine && \
gcloud --version && \
gsutil version && \
bq version && \
gcloud-crc32c /google-cloud-sdk/bin/gcloud
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
VOLUME ["/root/.config"]
45 changes: 45 additions & 0 deletions testing/debian_component_based/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM docker:27.4.1 as static-docker-source

FROM marketplace.gcr.io/google/debian12:latest
ARG CLOUD_SDK_VERSION
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
RUN groupadd -r -g 1000 cloudsdk && \
useradd -r -u 1000 -m -s /bin/bash -g cloudsdk cloudsdk
RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \
curl \
gcc \
python3-dev \
python3-pip \
python3-crcmod \
apt-transport-https \
lsb-release \
openssh-client \
git \
make \
gnupg \
openjdk-17-jre-headless
RUN if [ `uname -m` = 'x86_64' ]; then echo -n "x86_64" > /tmp/arch; else echo -n "arm" > /tmp/arch; fi;
RUN ARCH=`cat /tmp/arch` && curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
tar xzf google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
rm google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz
RUN echo -n "app-engine-java app-engine-python alpha beta pubsub-emulator cloud-datastore-emulator app-engine-go bigtable cbt app-engine-python-extras kubectl gke-gcloud-auth-plugin kustomize minikube skaffold kpt local-extract" > /tmp/additional_components
# These components are not available on ARM right now.
RUN if [ `uname -m` = 'x86_64' ]; then echo -n " appctl nomos anthos-auth" >> /tmp/additional_components; fi;
RUN /google-cloud-sdk/install.sh --bash-completion=false --path-update=true --usage-reporting=false \
--additional-components `cat /tmp/additional_components` && rm -rf /google-cloud-sdk/.install/.backup
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
VOLUME ["/root/.config", "/root/.kube"]
RUN gcloud config set metrics/environment docker_image_debian_component_based

COPY test-components.sh /usr/local/bin/test-components.sh
COPY emulator-testing.sh /usr/local/bin/emulator-testing.sh
COPY test-dcb-emulators.sh /usr/local/bin/test-all-emulators.sh

RUN cd /usr/local/bin && ./test-components.sh
RUN rm /usr/local/bin/emulator-testing.sh
RUN rm /usr/local/bin/test-all-emulators.sh
RUN rm /usr/local/bin/test-components.sh

36 changes: 36 additions & 0 deletions testing/debian_slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM docker:27.4.1 as static-docker-source

FROM marketplace.gcr.io/google/debian12:latest
ARG CLOUD_SDK_VERSION
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
RUN groupadd -r -g 1000 cloudsdk && \
useradd -r -u 1000 -m -s /bin/bash -g cloudsdk cloudsdk
ARG INSTALL_COMPONENTS
RUN mkdir -p /usr/share/man/man1/
RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \
curl \
gcc \
python3-dev \
python3-crcmod \
python3-pip \
apt-transport-https \
lsb-release \
openssh-client \
git \
gnupg && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /etc/apt/keyrings/google-cloud-cli.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/google-cloud-cli.gpg] https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
apt-get update && apt-get install -y google-cloud-cli=${CLOUD_SDK_VERSION}-0 $INSTALL_COMPONENTS && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_slim && \
gcloud --version && \
gsutil version && \
bq version && \
gcloud-crc32c /usr/bin/gcloud && \
docker --version
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
VOLUME ["/root/.config"]
41 changes: 41 additions & 0 deletions testing/emulators/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# debian12 is used instead of alpine because the cloud bigtable emulator requires glibc.
FROM marketplace.gcr.io/google/debian12:latest

ARG CLOUD_SDK_VERSION
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
ENV PATH /google-cloud-sdk/bin:$PATH

RUN groupadd -r -g 1000 cloudsdk && \
useradd -r -u 1000 -m -s /bin/bash -g cloudsdk cloudsdk

RUN echo -n "cloud-datastore-emulator cloud-firestore-emulator pubsub-emulator bigtable" > /tmp/additional_components
RUN if [ `uname -m` = 'x86_64' ]; then echo -n " cloud-spanner-emulator" >> /tmp/additional_components; fi;
RUN cat /tmp/additional_components
RUN if [ `uname -m` = 'x86_64' ]; then echo -n "x86_64" > /tmp/arch; else echo -n "arm" > /tmp/arch; fi;

RUN ARCH=`cat /tmp/arch` && \
mkdir -p /usr/share/man/man1/ && \
apt-get update && \
apt-get -qqy upgrade && \
apt-get -y install \
curl \
python3 \
python3-crcmod \
bash \
openjdk-17-jre-headless && \
curl -O https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
tar xzf google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
rm google-cloud-cli-${CLOUD_SDK_VERSION}-linux-${ARCH}.tar.gz && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_emulator && \
gcloud components install beta `cat /tmp/additional_components` && \
rm -rf /google-cloud-sdk/.install/.backup/ && \
find /google-cloud-sdk/ -name "__pycache__" -type d | xargs -n 1 rm -rf && \
rm -rf /var/lib/apt/lists tmp/*

COPY emulator-testing.sh /usr/local/bin/emulator-testing.sh
COPY test-all-emulators.sh /usr/local/bin/test-all-emulators.sh
RUN cd /usr/local/bin && ./test-all-emulators.sh
RUN rm /usr/local/bin/emulator-testing.sh
RUN rm /usr/local/bin/test-all-emulators.sh
56 changes: 56 additions & 0 deletions testing/latest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM docker:27.4.1 as static-docker-source

FROM marketplace.gcr.io/google/debian12:latest
ARG CLOUD_SDK_VERSION
ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION
COPY --from=static-docker-source /usr/local/bin/docker /usr/local/bin/docker
COPY --from=static-docker-source /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
RUN groupadd -r -g 1000 cloudsdk && \
useradd -r -u 1000 -m -s /bin/bash -g cloudsdk cloudsdk
RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \
curl \
python3-dev \
python3-crcmod \
apt-transport-https \
lsb-release \
openssh-client \
git \
make \
gnupg && \
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
echo "deb https://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" > /etc/apt/sources.list.d/google-cloud-sdk.list && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update && \
apt-get install -y google-cloud-cli=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-app-engine-python=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-app-engine-python-extras=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-app-engine-java=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-app-engine-go=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-datastore-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-pubsub-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-bigtable-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-firestore-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-spanner-emulator=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-cbt=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-kpt=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-local-extract=${CLOUD_SDK_VERSION}-0 \
google-cloud-cli-gke-gcloud-auth-plugin=${CLOUD_SDK_VERSION}-0 \
kubectl && \
gcloud config set core/disable_usage_reporting true && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_latest && \
gcloud --version && \
docker --version && kubectl version --client
RUN apt-get install -qqy \
gcc \
python3-pip
RUN git config --system credential.'https://source.developers.google.com'.helper gcloud.sh
COPY emulators/emulator-testing.sh /usr/local/bin/emulator-testing.sh
COPY emulators/test-all-emulators.sh /usr/local/bin/test-all-emulators.sh
COPY test-latest.sh /usr/local/bin/test-latest.sh
RUN cd /usr/local/bin && ./test-latest.sh
RUN rm /usr/local/bin/emulator-testing.sh
RUN rm /usr/local/bin/test-all-emulators.sh
RUN rm /usr/local/bin/test-latest.sh

VOLUME ["/root/.config", "/root/.kube"]
Loading