Skip to content

Commit fedac3f

Browse files
rahul2393olavloite
andauthored
build: run graalvm integration tests on emulator (#3198)
* build: run graalvm integration tests on emulator * fix build * build: add same TODO as in the JDBC driver --------- Co-authored-by: Knut Olav Løite <[email protected]>
1 parent 2024e18 commit fedac3f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

.kokoro/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI
4848
export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS})
4949
fi
5050

51+
# Start the Spanner emulator if the environment variable for it has been set.
52+
# TODO: Change if statement once the env var can be set in the config.
53+
#if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
54+
if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then
55+
echo "Starting emulator"
56+
export SPANNER_EMULATOR_HOST=localhost:9010
57+
docker pull gcr.io/cloud-spanner-emulator/emulator
58+
docker run -d --rm --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
59+
fi
60+
5161
# Kokoro integration test uses both JDK 11 and JDK 8. We ensure the generated class files
5262
# are compatible with Java 8 when running tests.
5363
if [ -n "${JAVA8_HOME}" ]; then
@@ -233,6 +243,11 @@ clirr)
233243
;;
234244
esac
235245

246+
if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
247+
echo "Stopping emulator"
248+
docker container stop spanner-emulator
249+
fi
250+
236251
if [ "${REPORT_COVERAGE}" == "true" ]
237252
then
238253
bash ${KOKORO_GFILE_DIR}/codecov.sh

google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ protected void initializeConfig()
8787
throw new NullPointerException("Property " + TEST_ENV_CONFIG_CLASS_NAME + " needs to be set");
8888
}
8989
Class<? extends TestEnvConfig> configClass;
90+
if (EmulatorSpannerHelper.isUsingEmulator()) {
91+
// Make sure that we use an owned instance on the emulator.
92+
System.setProperty(TEST_INSTANCE_PROPERTY, "");
93+
}
9094
configClass = (Class<? extends TestEnvConfig>) Class.forName(CONFIG_CLASS);
9195
config = configClass.newInstance();
9296
}

0 commit comments

Comments
 (0)