From d9d913d08f5c9171b404c7757475013ce8fa394d Mon Sep 17 00:00:00 2001 From: rahul yadav Date: Thu, 4 Jul 2024 11:23:00 +0530 Subject: [PATCH 1/3] build: run graalvm integration tests on emulator --- .kokoro/build.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index d3eaf9922bb..0d2f9c5dee7 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -48,6 +48,14 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) fi +# Start the Spanner emulator if the job type is graalvm or graalvm17 +if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then + echo "Starting emulator" + export SPANNER_EMULATOR_HOST=localhost:9010 + docker pull gcr.io/cloud-spanner-emulator/emulator + docker run -d --rm --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator +fi + # Kokoro integration test uses both JDK 11 and JDK 8. We ensure the generated class files # are compatible with Java 8 when running tests. if [ -n "${JAVA8_HOME}" ]; then @@ -233,6 +241,11 @@ clirr) ;; esac +if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then + echo "Stopping emulator" + docker container stop spanner-emulator +fi + if [ "${REPORT_COVERAGE}" == "true" ] then bash ${KOKORO_GFILE_DIR}/codecov.sh From 96ec7e9fc77186e8fc28fa3786104e59192f19f8 Mon Sep 17 00:00:00 2001 From: rahul yadav Date: Thu, 4 Jul 2024 12:31:10 +0530 Subject: [PATCH 2/3] fix build --- .../java/com/google/cloud/spanner/IntegrationTestEnv.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java index 6dd9c29e23f..efb7ff59cc5 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java @@ -87,6 +87,10 @@ protected void initializeConfig() throw new NullPointerException("Property " + TEST_ENV_CONFIG_CLASS_NAME + " needs to be set"); } Class configClass; + if (EmulatorSpannerHelper.isUsingEmulator()) { + // Make sure that we use an owned instance on the emulator. + System.setProperty(TEST_INSTANCE_PROPERTY, ""); + } configClass = (Class) Class.forName(CONFIG_CLASS); config = configClass.newInstance(); } From e0a66dcba336e6f4b66164f0d42cb5a7b9d12982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Tue, 6 Aug 2024 19:34:44 +0200 Subject: [PATCH 3/3] build: add same TODO as in the JDBC driver --- .kokoro/build.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 0d2f9c5dee7..f8ae5a96f37 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -48,7 +48,9 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) fi -# Start the Spanner emulator if the job type is graalvm or graalvm17 +# Start the Spanner emulator if the environment variable for it has been set. +# TODO: Change if statement once the env var can be set in the config. +#if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then echo "Starting emulator" export SPANNER_EMULATOR_HOST=localhost:9010