|
10 | 10 | # - $NODE_JS_VERSION
|
11 | 11 | #
|
12 | 12 |
|
| 13 | +set -eo pipefail |
| 14 | + |
13 | 15 | set +x
|
14 | 16 | export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID")
|
15 | 17 | export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov)
|
16 | 18 | unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN
|
17 | 19 | set -x
|
18 | 20 |
|
19 |
| -ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-oss |
| 21 | +function cleanup { |
| 22 | + docker container rm --force --volumes elasticsearch-oss > /dev/null 2>&1 || true |
| 23 | + docker container rm --force --volumes elasticsearch-platinum > /dev/null 2>&1 || true |
| 24 | + docker container rm --force --volumes elasticsearch-js-oss > /dev/null 2>&1 || true |
| 25 | + docker container rm --force --volumes elasticsearch-js-platinum > /dev/null 2>&1 || true |
| 26 | + docker network rm esnet-oss > /dev/null |
| 27 | + docker network rm esnet-platinum > /dev/null |
| 28 | +} |
| 29 | + |
| 30 | +trap cleanup EXIT |
| 31 | + |
| 32 | +# create network and volume |
| 33 | +docker network create esnet-oss |
| 34 | +docker network create esnet-platinum |
| 35 | + |
| 36 | +# create client image |
| 37 | +docker build \ |
| 38 | + --file .ci/Dockerfile \ |
| 39 | + --tag elastic/elasticsearch-js \ |
| 40 | + --build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \ |
| 41 | + . |
| 42 | + |
| 43 | +# run elasticsearch oss |
| 44 | +docker run \ |
| 45 | + --rm \ |
| 46 | + --env "node.attr.testattr=test" \ |
| 47 | + --env "path.repo=/tmp" \ |
| 48 | + --env "repositories.url.allowed_urls=http://snapshot.*" \ |
| 49 | + --env "discovery.type=single-node" \ |
| 50 | + --network=esnet-oss \ |
| 51 | + --name=elasticsearch-oss \ |
| 52 | + --detach \ |
| 53 | + docker.elastic.co/elasticsearch/elasticsearch-oss:${ELASTICSEARCH_VERSION} |
| 54 | + |
| 55 | +# run elasticsearch platinum |
| 56 | +repo=$(pwd) |
| 57 | +testnodecrt="/.ci/certs/testnode.crt" |
| 58 | +testnodekey="/.ci/certs/testnode.key" |
| 59 | +cacrt="/.ci/certs/ca.crt" |
| 60 | + |
| 61 | +docker run \ |
| 62 | + --rm \ |
| 63 | + --env "node.attr.testattr=test" \ |
| 64 | + --env "path.repo=/tmp" \ |
| 65 | + --env "repositories.url.allowed_urls=http://snapshot.*" \ |
| 66 | + --env "discovery.type=single-node" \ |
| 67 | + --env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ |
| 68 | + --env "ELASTIC_PASSWORD=changeme" \ |
| 69 | + --env "xpack.security.enabled=true" \ |
| 70 | + --env "xpack.license.self_generated.type=trial" \ |
| 71 | + --env "xpack.security.http.ssl.enabled=true" \ |
| 72 | + --env "xpack.security.http.ssl.verification_mode=certificate" \ |
| 73 | + --env "xpack.security.http.ssl.key=certs/testnode.key" \ |
| 74 | + --env "xpack.security.http.ssl.certificate=certs/testnode.crt" \ |
| 75 | + --env "xpack.security.http.ssl.certificate_authorities=certs/ca.crt" \ |
| 76 | + --env "xpack.security.transport.ssl.enabled=true" \ |
| 77 | + --env "xpack.security.transport.ssl.key=certs/testnode.key" \ |
| 78 | + --env "xpack.security.transport.ssl.certificate=certs/testnode.crt" \ |
| 79 | + --env "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt" \ |
| 80 | + --volume "$repo$testnodecrt:/usr/share/elasticsearch/config/certs/testnode.crt" \ |
| 81 | + --volume "$repo$testnodekey:/usr/share/elasticsearch/config/certs/testnode.key" \ |
| 82 | + --volume "$repo$cacrt:/usr/share/elasticsearch/config/certs/ca.crt" \ |
| 83 | + --network=esnet-platinum \ |
| 84 | + --name=elasticsearch-platinum \ |
| 85 | + --detach \ |
| 86 | + docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION} |
| 87 | + |
| 88 | +# run the client unit and oss integration test |
| 89 | +docker run \ |
| 90 | + --network=esnet-oss \ |
| 91 | + --env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \ |
| 92 | + --env "CODECOV_TOKEN" \ |
| 93 | + --volume $repo:/usr/src/app \ |
| 94 | + --volume /usr/src/app/node_modules \ |
| 95 | + --name elasticsearch-js-oss \ |
| 96 | + --rm \ |
| 97 | + elastic/elasticsearch-js \ |
| 98 | + npm run ci |
| 99 | + |
| 100 | +# run the client platinium integration test |
| 101 | +docker run \ |
| 102 | + --network=esnet-platinum \ |
| 103 | + --env "TEST_ES_SERVER=https://elastic:changeme@elasticsearch-platinum:9200" \ |
| 104 | + --volume $repo:/usr/src/app \ |
| 105 | + --volume /usr/src/app/node_modules \ |
| 106 | + --name elasticsearch-js-platinum \ |
| 107 | + --rm \ |
| 108 | + elastic/elasticsearch-js \ |
| 109 | + npm run test:integration |
20 | 110 |
|
21 |
| -ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-platinum |
|
0 commit comments