Skip to content

Commit cc5834b

Browse files
authored
ci: storage emulator and caching (#7713)
Always install the storage emulator in $HOME/.local, so we can predict where all its files are, and we can clean up before an install. Ensure the test cache is invalidated by newer versions of the storage emulator.
1 parent 5885fab commit cc5834b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

ci/cloudbuild/builds/lib/integration.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ source module ci/lib/io.sh
2828

2929
# To run the integration tests we need to install the dependencies for the storage emulator
3030
export PATH="${HOME}/.local/bin:${PATH}"
31-
python3 -m pip install --quiet "git+https://github.com/googleapis/storage-testbench@v0.9.0"
31+
python3 -m pip uninstall -y --quiet googleapis-storage-testbench
32+
python3 -m pip install --upgrade --user --quiet "git+https://github.com/googleapis/storage-testbench@v0.10.0"
3233

3334
# Some of the tests will need a valid roots.pem file.
3435
rm -f /dev/shm/roots.pem

google/cloud/storage/ci/run_integration_tests_emulator_bazel.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,25 @@ printf '{"name": "%s"}' "${GOOGLE_CLOUD_CPP_STORAGE_TEST_DESTINATION_BUCKET_NAME
8585
curl -X POST -H "Content-Type: application/json" --data-binary @- \
8686
"${CLOUD_STORAGE_EMULATOR_ENDPOINT}/storage/v1/b?project=${GOOGLE_CLOUD_PROJECT}"
8787

88+
# This is just the SHA for the *description* of the testbench, it includes its
89+
# version and other info, but no details about the contents.
8890
TESTBENCH_SHA="$(pip show googleapis-storage-testbench | sha256sum)"
91+
# With these two commands we extract the SHA of the testbench contents. It
92+
# excludes the contents of its deps (say gRPC, or Flask), as those are unlikely
93+
# to affect the results of the test.
94+
TESTBENCH_LOCATION="$(pip show googleapis-storage-testbench | sed -n 's/^Location: //p')"
95+
TESTBENCH_CONTENTS_SHA="$(
96+
cd "${TESTBENCH_LOCATION}"
97+
pip show --files googleapis-storage-testbench |
98+
sed -n '/^Files:/,$p' |
99+
grep '\.py$' |
100+
xargs sha256sum |
101+
sort |
102+
sha256sum -
103+
)"
89104
emulator_args=(
90105
"--test_env=TESTBENCH_SHA=${TESTBENCH_SHA}"
106+
"--test_env=TESTBENCH_CONTENTS_SHA=${TESTBENCH_CONTENTS_SHA}"
91107
"--test_env=CLOUD_STORAGE_EMULATOR_ENDPOINT=${CLOUD_STORAGE_EMULATOR_ENDPOINT}"
92108
"--test_env=CLOUD_STORAGE_GRPC_ENDPOINT=${CLOUD_STORAGE_GRPC_ENDPOINT}"
93109
"--test_env=HTTPBIN_ENDPOINT=${HTTPBIN_ENDPOINT}"

0 commit comments

Comments
 (0)