Skip to content

Commit e9f8470

Browse files
authored
build: run graalvm integration tests on emulator (#1662)
* build: run graalvm integration tests on emulator * build: always use emulator * fix: start emulator in detached mode * fix: typo in Docker run command * build: use owned instance when testing on emulator * build: use embedded emulator * chore: add logging for emulator startup * build: start emulator in build script * chore: cleanup
1 parent 60c59f5 commit e9f8470

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

.kokoro/build.sh

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

45+
# Start the Spanner emulator if the environment variable for it has been set.
46+
# TODO: Change if statement once the env var can be set in the config.
47+
#if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
48+
if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then
49+
echo "Starting emulator"
50+
export SPANNER_EMULATOR_HOST=localhost:9010
51+
docker pull gcr.io/cloud-spanner-emulator/emulator
52+
docker run -d --rm --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
53+
fi
54+
4555
RETURN_CODE=0
4656
set +e
4757

@@ -145,6 +155,11 @@ clirr)
145155
;;
146156
esac
147157

158+
if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then
159+
echo "Stopping emulator"
160+
docker container stop spanner-emulator
161+
fi
162+
148163
if [ "${REPORT_COVERAGE}" == "true" ]
149164
then
150165
bash ${KOKORO_GFILE_DIR}/codecov.sh

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgNumericTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.cloud.spanner.DatabaseAdminClient;
2626
import com.google.cloud.spanner.DatabaseId;
2727
import com.google.cloud.spanner.Dialect;
28-
import com.google.cloud.spanner.IntegrationTestEnv;
2928
import com.google.cloud.spanner.ParallelIntegrationTest;
3029
import com.google.cloud.spanner.Value;
3130
import com.google.cloud.spanner.connection.ConnectionOptions;
@@ -54,7 +53,7 @@
5453
@RunWith(JUnit4.class)
5554
public class ITJdbcPgNumericTest {
5655

57-
@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
56+
@ClassRule public static JdbcIntegrationTestEnv env = new JdbcIntegrationTestEnv();
5857

5958
private static final Duration OPERATION_TIMEOUT = Duration.ofMinutes(10);
6059
private static RemoteSpannerHelper testHelper;

src/test/java/com/google/cloud/spanner/jdbc/it/ITProtoColumnsTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import com.google.cloud.spanner.DatabaseAdminClient;
2929
import com.google.cloud.spanner.DatabaseId;
3030
import com.google.cloud.spanner.Dialect;
31-
import com.google.cloud.spanner.IntegrationTestEnv;
3231
import com.google.cloud.spanner.ParallelIntegrationTest;
3332
import com.google.cloud.spanner.connection.ConnectionOptions;
3433
import com.google.cloud.spanner.jdbc.ProtoEnumType;
@@ -57,7 +56,7 @@
5756
@Category(ParallelIntegrationTest.class)
5857
@RunWith(JUnit4.class)
5958
public class ITProtoColumnsTest {
60-
@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
59+
@ClassRule public static JdbcIntegrationTestEnv env = new JdbcIntegrationTestEnv();
6160
private static final Duration OPERATION_TIMEOUT = Duration.ofMinutes(10);
6261
private static Database database;
6362
private static String url;

0 commit comments

Comments
 (0)