Skip to content

Commit

Permalink
Merge pull request #518 from GoogleCloudPlatform/docker-testing
Browse files Browse the repository at this point in the history
Docker testing
  • Loading branch information
anindyatahsin authored Jan 28, 2025
2 parents dabd6d1 + 321151f commit bd7a3cb
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 1 deletion.
5 changes: 4 additions & 1 deletion alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ RUN ARCH=`cat /tmp/arch` && apk --no-cache upgrade && apk --no-cache add \
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
gcloud --version && \
gsutil version -l && \
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"]
20 changes: 20 additions & 0 deletions debian_component_based/emulator-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/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

32 changes: 32 additions & 0 deletions debian_component_based/test-components.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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

27 changes: 27 additions & 0 deletions debian_component_based/test-dcb-emulators.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#!/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

3 changes: 3 additions & 0 deletions debian_slim/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ RUN apt-get update -qqy && apt-get -qqy upgrade && apt-get install -qqy \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_slim && \
gcloud --version && \
gsutil version -l && \
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"]
20 changes: 20 additions & 0 deletions emulators/emulator-testing.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/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

43 changes: 43 additions & 0 deletions emulators/test-all-emulators.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

#!/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

3 changes: 3 additions & 0 deletions stable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ RUN if [ `uname -m` = 'x86_64' ]; then echo -n "x86_64" > /tmp/arch; else echo -
python3-dev \
python3-crcmod; fi;
RUN gcloud --version && \
gsutil version -l && \
bq version && \
gcloud-crc32c /usr/lib/google-cloud-sdk/bin/gcloud && \
gcloud config set core/disable_usage_reporting false && \
gcloud config set component_manager/disable_update_check true && \
gcloud config set metrics/environment docker_image_stable && \
Expand Down
32 changes: 32 additions & 0 deletions test-latest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/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

0 comments on commit bd7a3cb

Please sign in to comment.