File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
google-cloud-spanner/src/test/java/com/google/cloud/spanner Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff 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} )
4949fi
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.
5363if [ -n " ${JAVA8_HOME} " ]; then
@@ -233,6 +243,11 @@ clirr)
233243 ;;
234244esac
235245
246+ if [[ ! -z " ${SPANNER_EMULATOR_HOST} " ]]; then
247+ echo " Stopping emulator"
248+ docker container stop spanner-emulator
249+ fi
250+
236251if [ " ${REPORT_COVERAGE} " == " true" ]
237252then
238253 bash ${KOKORO_GFILE_DIR} /codecov.sh
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments