Skip to content

Commit

Permalink
CI: Refactor and clean up the test runner for "core" tests
Browse files Browse the repository at this point in the history
Use the same pattern as in the `tests-xpack.sh` runner, ie. run
the file directly on host, and execute commands with `docker exec`.

Also, clean up a little bit the `tests-xpack.sh` runner, removing
double quotes to prevent unwanted shell expansion, and passing
the `PACKAGE_PATH` environment variable.

(cherry picked from commit 4fbc97d)
  • Loading branch information
karmi committed Jul 5, 2019
1 parent 39b3652 commit 37ae3d1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .jenkins/run-tests
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ docker run \
status=100
case $TEST_SUITE in
"core" )
if docker exec --tty go-elasticsearch /bin/sh /go-elasticsearch/.jenkins/tests.sh; then
if bash .jenkins/tests-core.sh; then
status=$?
else
status=$?
fi
;;
"xpack" )
if time bash .jenkins/tests-xpack.sh; then
if bash .jenkins/tests-xpack.sh; then
status=$?
else
status=$?
Expand Down
25 changes: 25 additions & 0 deletions .jenkins/tests-core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

set -euo pipefail

TIMEFORMAT="(Duration: %0lR)"

echo -e "\033[1m>>>>> Cleaning up test files\033[0m"

docker exec go-elasticsearch /bin/sh -c 'rm -rf esapi/test/*_test.go'
docker exec go-elasticsearch /bin/sh -c 'rm -rf esapi/test/xpack'

echo -e "\033[1m>>>>> Generating the API registry\033[0m"

docker exec --workdir=/go-elasticsearch/internal/cmd/generate --env PACKAGE_PATH=/go-elasticsearch/esapi go-elasticsearch go generate ./...

echo -e "\033[1m>>>>> Generating the test files\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/internal/cmd/generate go-elasticsearch go run main.go tests --output '/go-elasticsearch/esapi/test' --input '/elasticsearch-source/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/test/**/*.y*ml'

echo -e "\033[1m>>>>> Running the tests\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/esapi/test go-elasticsearch /bin/sh -c 'gotestsum --format=short-verbose --junitfile=$WORKSPACE/TEST-integration-api-junit.xml -- -tags=integration -timeout=1h ./...'
status=$?

exit $status
22 changes: 13 additions & 9 deletions .jenkins/tests-xpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ set -euo pipefail

TIMEFORMAT="(Duration: %0lR)"

docker exec go-elasticsearch /bin/sh -c "rm -rf esapi/test/*_test.go"
docker exec go-elasticsearch /bin/sh -c "rm -rf rm -rf esapi/test/ml*"
echo -e "\033[1m>>>>> Cleaning up test files\033[0m"

docker exec --workdir=/go-elasticsearch/internal/cmd/generate go-elasticsearch go generate ./...
docker exec go-elasticsearch /bin/sh -c 'rm -rf esapi/test/*_test.go'
docker exec go-elasticsearch /bin/sh -c 'rm -rf rm -rf esapi/test/ml*'

echo -e "\033[1m>>>>> Generating the API registry\033[0m"

docker exec --workdir=/go-elasticsearch/internal/cmd/generate --env PACKAGE_PATH=/go-elasticsearch/esapi go-elasticsearch go generate ./...

echo -e "\033[1m>>>>> Generating the test files\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/internal/cmd/generate go-elasticsearch go run main.go apitests --output '/go-elasticsearch/esapi/test/xpack' --input '/elasticsearch-source/elasticsearch/x-pack/plugin/src/test/resources/rest-api-spec/test/**/*.yml'

Expand All @@ -16,28 +22,26 @@ time docker exec --tty --workdir=/go-elasticsearch/internal/cmd/generate go-elas
docker exec go-elasticsearch mkdir -p esapi/test/xpack/ml
docker exec go-elasticsearch mkdir -p esapi/test/xpack/ml-crud

docker exec go-elasticsearch /bin/sh -c "mv esapi/test/xpack/xpack_ml* esapi/test/xpack/ml/"
docker exec go-elasticsearch /bin/sh -c 'mv esapi/test/xpack/xpack_ml* esapi/test/xpack/ml/'
docker exec go-elasticsearch mv esapi/test/xpack/ml/xpack_ml__jobs_crud_test.go esapi/test/xpack/ml-crud/

# -----

echo -e "\033[1m>>>>> XPACK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
echo -e "\033[1m>>>>> Running tests: XPACK >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/esapi/test go-elasticsearch /bin/sh -c 'gotestsum --format=short-verbose --junitfile=$WORKSPACE/TEST-integration-api-xpack-junit.xml -- --tags=integration --timeout=1h -v xpack/*_test.go'
status1=$?

docker container rm --force --volumes es1 > /dev/null 2>&1
make cluster-clean cluster version=elasticsearch:8.0.0-SNAPSHOT detached=true

echo -e "\033[1m>>>>> XPACK ML >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
echo -e "\033[1m>>>>> Running tests: XPACK ML >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/esapi/test go-elasticsearch /bin/sh -c 'gotestsum --format=short-verbose --junitfile=$WORKSPACE/TEST-integration-api-xpack-ml-junit.xml -- --tags=integration --timeout=1h -v ./xpack/ml/*_test.go'
status2=$?

docker container rm --force --volumes es1 > /dev/null 2>&1
make cluster-clean cluster version=elasticsearch:8.0.0-SNAPSHOT detached=true

echo -e "\033[1m>>>>> XPACK ML CRUD >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"
echo -e "\033[1m>>>>> Running tests: XPACK ML CRUD >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\033[0m"

time docker exec --tty --workdir=/go-elasticsearch/esapi/test go-elasticsearch /bin/sh -c 'gotestsum --format=short-verbose --junitfile=$WORKSPACE/TEST-integration-api-xpack-ml-crud-junit.xml -- --tags=integration --timeout=1h -v ./xpack/ml-crud/*_test.go'
status3=$?
Expand Down
24 changes: 0 additions & 24 deletions .jenkins/tests.sh

This file was deleted.

0 comments on commit 37ae3d1

Please sign in to comment.