test/docker/run: Stop caching artifacts Trying to cache artifacts like this causes surprises where a different version of plugin or gerrit is being tested than expected. We don't expect a --gerrit-war often during normal plugin development, but add a default of bazel-bin/events.jar for the plugin jar option so that it doesn't have to be specified to run tests. Using the 'bazel test docker-tests' command is still better because it ensures the plugin version you're testing matches the tree you have checked out. Change-Id: I126c891c47c5919e9cb58c5b3bbb99414e827c6c
diff --git a/.gitignore b/.gitignore index 922d9e7..0503db2 100644 --- a/.gitignore +++ b/.gitignore
@@ -9,3 +9,4 @@ *.iml /.apt_generated/ /.apt_generated_tests/ +/test/docker/gerrit/artifacts
diff --git a/test/docker/docker-compose.yaml b/test/docker/docker-compose.yaml index 7014537..1bf956b 100755 --- a/test/docker/docker-compose.yaml +++ b/test/docker/docker-compose.yaml
@@ -4,9 +4,6 @@ gerrit-01: build: context: gerrit - args: - - GERRIT_WAR - - EVENTS_PLUGIN_JAR networks: - gerrit-net volumes:
diff --git a/test/docker/run.sh b/test/docker/run.sh index f323abd..f897104 100755 --- a/test/docker/run.sh +++ b/test/docker/run.sh
@@ -3,6 +3,7 @@ readlink -f / &> /dev/null || readlink() { greadlink "$@" ; } # for MacOS MYDIR=$(dirname -- "$(readlink -f -- "$0")") ARTIFACTS=$MYDIR/gerrit/artifacts +BAZEL_BUILT_JAR=$MYDIR/../../bazel-bin/events.jar die() { echo -e "\nERROR: $@" ; kill $$ ; exit 1 ; } # error_message @@ -28,18 +29,14 @@ This tool runs the plugin functional tests in a Docker environment built from the gerritcodereview/gerrit base Docker image. - The events plugin JAR and optionally a Gerrit WAR are expected to be in the - $ARTIFACTS dir; - however, the --events-plugin-jar and --gerrit-war switches may be used as - helpers to specify which files to copy there. - Options: --help|-h - --gerrit-war|-g path to Gerrit WAR file. Will likely not - function correctly if it's a different + --gerrit-war|-g optional path to Gerrit WAR file. Will likely + not function correctly if it's a different MAJOR.MINOR version than the image version in test/docker/gerrit/Dockerfile. - --events-plugin-jar|-e path to events plugin JAR file + --events-plugin-jar|-e optional path to events plugin JAR file + Defaults to $BAZEL_BUILT_JAR EOF @@ -64,6 +61,7 @@ cleanup() { docker-compose "${COMPOSE_ARGS[@]}" down -v --rmi local 2>/dev/null + rm -rf "$ARTIFACTS" } while (( "$#" )); do @@ -81,11 +79,12 @@ COMPOSE_ARGS=(--project-name "$PROJECT_NAME" -f "$COMPOSE_YAML") check_prerequisite mkdir -p -- "$ARTIFACTS" -[ -n "$EVENTS_PLUGIN_JAR" ] && cp -f -- "$EVENTS_PLUGIN_JAR" "$ARTIFACTS/events.jar" -if [ ! -e "$ARTIFACTS/events.jar" ] ; then - MISSING="Missing $ARTIFACTS/events.jar" - [ -n "$EVENTS_PLUGIN_JAR" ] && die "$MISSING, check for copy failure?" - usage "$MISSING, did you forget --events-plugin-jar?" +if [ -n "$EVENTS_PLUGIN_JAR" ] ; then + cp -f "$EVENTS_PLUGIN_JAR" "$ARTIFACTS/events.jar" +elif [ -e "$BAZEL_BUILT_JAR" ] ; then + cp -f "$BAZEL_BUILT_JAR" "$ARTIFACTS/events.jar" +else + usage "Cannot find plugin jar, did you forget --events-plugin-jar?" fi [ -n "$GERRIT_WAR" ] && cp -f -- "$GERRIT_WAR" "$ARTIFACTS/gerrit.war" ( trap cleanup EXIT SIGTERM