66 lines
1.8 KiB
Bash
Executable File
66 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
#
|
|
# Runs the client tests via Docker with the expectation that the required
|
|
# environment variables have already been exported before running this script.
|
|
#
|
|
# The required environment variables include:
|
|
#
|
|
# - $ELASTICSEARCH_VERSION
|
|
# - $NODE_JS_VERSION
|
|
#
|
|
|
|
set -eo pipefail
|
|
|
|
set +x
|
|
export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
|
|
export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov)
|
|
unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN
|
|
set -x
|
|
|
|
function cleanup {
|
|
docker container rm --force --volumes elasticsearch-oss > /dev/null 2>&1 || true
|
|
docker container rm --force --volumes elasticsearch-js-oss > /dev/null 2>&1 || true
|
|
docker network rm esnet-oss > /dev/null
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# create network and volume
|
|
docker network create esnet-oss
|
|
|
|
# create client image
|
|
docker build \
|
|
--file .ci/Dockerfile \
|
|
--tag elastic/elasticsearch-js \
|
|
--build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \
|
|
.
|
|
|
|
# run elasticsearch oss
|
|
docker run \
|
|
--rm \
|
|
--env "node.attr.testattr=test" \
|
|
--env "path.repo=/tmp" \
|
|
--env "repositories.url.allowed_urls=http://snapshot.*" \
|
|
--env "discovery.zen.ping.unicast.hosts=elasticsearch" \
|
|
--env "xpack.security.enabled=false" \
|
|
--env "xpack.monitoring.enabled=false" \
|
|
--env "xpack.ml.enabled=false" \
|
|
--env ES_JAVA_OPTS="-Xms1g -Xmx1g" \
|
|
--network=esnet-oss \
|
|
--name=elasticsearch-oss \
|
|
--detach \
|
|
docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}
|
|
|
|
# run the client unit and oss integration test
|
|
docker run \
|
|
--network=esnet-oss \
|
|
--env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \
|
|
--env "CODECOV_TOKEN" \
|
|
--volume $(pwd):/usr/src/app \
|
|
--volume /usr/src/app/node_modules \
|
|
--name elasticsearch-js-oss \
|
|
--rm \
|
|
elastic/elasticsearch-js \
|
|
npm run ci
|