Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ 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 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
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
Comment on lines +55 to +58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: How about moving this with in the switch case below?

graalvm)
# Run Unit and Integration Tests with Native Image

I understand that there will be code duplication. But just thinking that this will give clarity to someone looking at graalvm that it runs on emulator and not real backend.

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
Expand Down Expand Up @@ -233,6 +243,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ protected void initializeConfig()
throw new NullPointerException("Property " + TEST_ENV_CONFIG_CLASS_NAME + " needs to be set");
}
Class<? extends TestEnvConfig> configClass;
if (EmulatorSpannerHelper.isUsingEmulator()) {
// Make sure that we use an owned instance on the emulator.
System.setProperty(TEST_INSTANCE_PROPERTY, "");
}
configClass = (Class<? extends TestEnvConfig>) Class.forName(CONFIG_CLASS);
config = configClass.newInstance();
}
Expand Down