From 2ea8b67e14bde4536b0932b6bc64ecf26df69476 Mon Sep 17 00:00:00 2001 From: Shanika Kuruppu Date: Thu, 25 Jun 2020 15:14:35 +1000 Subject: [PATCH 1/2] test: run integration tests against the emulator --- .../integration-tests-against-emulator.sh | 47 +++++++++++++++++++ .../integration-tests-against-emulator.yaml | 19 ++++++++ 2 files changed, 66 insertions(+) create mode 100644 .github/workflows/integration-tests-against-emulator.sh create mode 100644 .github/workflows/integration-tests-against-emulator.yaml diff --git a/.github/workflows/integration-tests-against-emulator.sh b/.github/workflows/integration-tests-against-emulator.sh new file mode 100644 index 00000000000..3b6d6a9d922 --- /dev/null +++ b/.github/workflows/integration-tests-against-emulator.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License.. + +# Fail on any error +set -e + +# Display commands being run +set -x + +export SPANNER_EMULATOR_HOST=localhost:9010 +export GOOGLE_CLOUD_PROJECT=emulator-test-project +echo "Running the Cloud Spanner emulator: $SPANNER_EMULATOR_HOST"; + +# Download the emulator +EMULATOR_VERSION=0.8.0 +wget https://storage.googleapis.com/cloud-spanner-emulator/releases/${EMULATOR_VERSION}/cloud-spanner-emulator_linux_amd64-${EMULATOR_VERSION}.tar.gz +tar zxvf cloud-spanner-emulator_linux_amd64-${EMULATOR_VERSION}.tar.gz +chmod u+x emulator_main + +# Start the emulator +./emulator_main --host_port $SPANNER_EMULATOR_HOST & + +EMULATOR_PID=$! + +# Stop the emulator & clean the environment variable +trap "kill -2 $EMULATOR_PID; unset SPANNER_EMULATOR_HOST; unset GOOGLE_CLOUD_PROJECT; echo \"Cleanup the emulator\";" EXIT + +mvn -B -Dspanner.testenv.instance="" \ + -Penable-integration-tests \ + -DtrimStackTrace=false \ + -Dclirr.skip=true \ + -Denforcer.skip=true \ + -fae \ + verify diff --git a/.github/workflows/integration-tests-against-emulator.yaml b/.github/workflows/integration-tests-against-emulator.yaml new file mode 100644 index 00000000000..ac27f8e17ea --- /dev/null +++ b/.github/workflows/integration-tests-against-emulator.yaml @@ -0,0 +1,19 @@ +on: + push: + branches: + - master + pull_request: +name: integration-tests-against-emulator +jobs: + units: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: 8 + - run: java -version + - run: .kokoro/build.sh + - run: sh .github/workflows/integration-tests-against-emulator.sh + env: + JOB_TYPE: test From 38b3390804da2745b34469b20da47bbdb3c6d8ab Mon Sep 17 00:00:00 2001 From: Shanika Kuruppu Date: Fri, 26 Jun 2020 14:07:52 +1000 Subject: [PATCH 2/2] fix: modify checked message to work with emulator --- .../src/test/java/com/google/cloud/spanner/it/ITWriteTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java index 1f084d5fdbf..d7a007eaf66 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITWriteTest.java @@ -612,7 +612,7 @@ public void incorrectType() { fail("Expected exception"); } catch (SpannerException ex) { assertThat(ex.getErrorCode()).isEqualTo(ErrorCode.FAILED_PRECONDITION); - assertThat(ex.getMessage()).contains("Expected STRING"); + assertThat(ex.getMessage()).contains("STRING"); } }