@elastic/elasticsearch 8.7.0 → 8.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.buildkite/Dockerfile +14 -0
  2. package/.buildkite/functions/cleanup.sh +67 -0
  3. package/.buildkite/functions/imports.sh +60 -0
  4. package/.buildkite/functions/wait-for-container.sh +36 -0
  5. package/.buildkite/pipeline.yml +30 -0
  6. package/.buildkite/run-client.sh +31 -0
  7. package/.buildkite/run-elasticsearch.sh +152 -0
  8. package/.buildkite/run-tests.sh +16 -0
  9. package/catalog-info.yaml +49 -0
  10. package/free-report-junit.xml +3 -5388
  11. package/index.d.ts +1 -1
  12. package/lib/api/api/health_report.d.ts +3 -3
  13. package/lib/api/api/health_report.js +1 -0
  14. package/lib/api/api/health_report.js.map +1 -1
  15. package/lib/api/api/indices.d.ts +12 -0
  16. package/lib/api/api/indices.js +82 -0
  17. package/lib/api/api/indices.js.map +1 -1
  18. package/lib/api/api/logstash.js +10 -2
  19. package/lib/api/api/logstash.js.map +1 -1
  20. package/lib/api/api/ml.js +1 -1
  21. package/lib/api/api/ml.js.map +1 -1
  22. package/lib/api/api/rollup.js +2 -2
  23. package/lib/api/api/rollup.js.map +1 -1
  24. package/lib/api/api/search.js +1 -1
  25. package/lib/api/api/search.js.map +1 -1
  26. package/lib/api/api/search_application.d.ts +38 -0
  27. package/lib/api/api/search_application.js +217 -0
  28. package/lib/api/api/search_application.js.map +1 -0
  29. package/lib/api/api/security.js +1 -1
  30. package/lib/api/api/security.js.map +1 -1
  31. package/lib/api/api/snapshot.js +1 -1
  32. package/lib/api/api/snapshot.js.map +1 -1
  33. package/lib/api/api/transform.d.ts +3 -3
  34. package/lib/api/api/transform.js +1 -1
  35. package/lib/api/api/transform.js.map +1 -1
  36. package/lib/api/api/watcher.d.ts +6 -0
  37. package/lib/api/api/watcher.js +34 -0
  38. package/lib/api/api/watcher.js.map +1 -1
  39. package/lib/api/index.d.ts +4 -0
  40. package/lib/api/index.js +14 -2
  41. package/lib/api/index.js.map +1 -1
  42. package/lib/api/types.d.ts +363 -43
  43. package/lib/api/typesWithBodyKey.d.ts +370 -43
  44. package/lib/client.js +4 -1
  45. package/lib/client.js.map +1 -1
  46. package/lib/helpers.js +2 -1
  47. package/lib/helpers.js.map +1 -1
  48. package/package.json +3 -3
  49. package/platinum-report-junit.xml +7 -2502
@@ -0,0 +1,14 @@
1
+ ARG NODE_VERSION=${NODE_VERSION:-18}
2
+ FROM node:$NODE_VERSION
3
+
4
+ # Install required tools
5
+ RUN apt-get clean -y && \
6
+ apt-get -qy update && \
7
+ apt-get -y install zip && \
8
+ apt-get clean && \
9
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
10
+
11
+ WORKDIR /usr/src/app
12
+
13
+ COPY . .
14
+ RUN npm install --production=false
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Shared cleanup routines between different steps
4
+ #
5
+ # Please source .ci/functions/imports.sh as a whole not just this file
6
+ #
7
+ # Version 1.0.0
8
+ # - Initial version after refactor
9
+
10
+ function cleanup_volume {
11
+ if [[ "$(docker volume ls -q -f name=$1)" ]]; then
12
+ echo -e "\033[34;1mINFO:\033[0m Removing volume $1\033[0m"
13
+ (docker volume rm "$1") || true
14
+ fi
15
+ }
16
+ function container_running {
17
+ if [[ "$(docker ps -q -f name=$1)" ]]; then
18
+ return 0;
19
+ else return 1;
20
+ fi
21
+ }
22
+ function cleanup_node {
23
+ if container_running "$1"; then
24
+ echo -e "\033[34;1mINFO:\033[0m Removing container $1\033[0m"
25
+ (docker container rm --force --volumes "$1") || true
26
+ fi
27
+ if [[ -n "$1" ]]; then
28
+ echo -e "\033[34;1mINFO:\033[0m Removing volume $1-${suffix}-data\033[0m"
29
+ cleanup_volume "$1-${suffix}-data"
30
+ fi
31
+ }
32
+ function cleanup_network {
33
+ if [[ "$(docker network ls -q -f name=$1)" ]]; then
34
+ echo -e "\033[34;1mINFO:\033[0m Removing network $1\033[0m"
35
+ (docker network rm "$1") || true
36
+ fi
37
+ }
38
+
39
+ function cleanup_trap {
40
+ status=$?
41
+ set +x
42
+ if [[ "$DETACH" != "true" ]]; then
43
+ echo -e "\033[34;1mINFO:\033[0m clean the network if not detached (start and exit)\033[0m"
44
+ cleanup_all_in_network "$1"
45
+ fi
46
+ # status is 0 or SIGINT
47
+ if [[ "$status" == "0" || "$status" == "130" ]]; then
48
+ echo -e "\n\033[32;1mSUCCESS run-tests\033[0m"
49
+ exit 0
50
+ else
51
+ echo -e "\n\033[31;1mFAILURE during run-tests\033[0m"
52
+ exit ${status}
53
+ fi
54
+ };
55
+ function cleanup_all_in_network {
56
+
57
+ if [[ -z "$(docker network ls -q -f name="^$1\$")" ]]; then
58
+ echo -e "\033[34;1mINFO:\033[0m $1 is already deleted\033[0m"
59
+ return 0
60
+ fi
61
+ containers=$(docker network inspect -f '{{ range $key, $value := .Containers }}{{ printf "%s\n" .Name}}{{ end }}' $1)
62
+ while read -r container; do
63
+ cleanup_node "$container"
64
+ done <<< "$containers"
65
+ cleanup_network $1
66
+ echo -e "\033[32;1mSUCCESS:\033[0m Cleaned up and exiting\033[0m"
67
+ };
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Sets up all the common variables and imports relevant functions
4
+ #
5
+ # Version 1.0.1
6
+ # - Initial version after refactor
7
+ # - Validate STACK_VERSION asap
8
+
9
+ function require_stack_version() {
10
+ if [[ -z $STACK_VERSION ]]; then
11
+ echo -e "\033[31;1mERROR:\033[0m Required environment variable [STACK_VERSION] not set\033[0m"
12
+ exit 1
13
+ fi
14
+ }
15
+
16
+ require_stack_version
17
+
18
+ if [[ -z $es_node_name ]]; then
19
+ # only set these once
20
+ set -euo pipefail
21
+ export TEST_SUITE=${TEST_SUITE-free}
22
+ export RUNSCRIPTS=${RUNSCRIPTS-}
23
+ export DETACH=${DETACH-false}
24
+ export CLEANUP=${CLEANUP-false}
25
+
26
+ export es_node_name=instance
27
+ export elastic_password=changeme
28
+ export elasticsearch_image=elasticsearch
29
+ export elasticsearch_scheme="https"
30
+ if [[ $TEST_SUITE != "platinum" ]]; then
31
+ export elasticsearch_scheme="http"
32
+ fi
33
+ export elasticsearch_url=${elasticsearch_scheme}://elastic:${elastic_password}@${es_node_name}:9200
34
+ export external_elasticsearch_url=${elasticsearch_url/$es_node_name/localhost}
35
+ export elasticsearch_container="${elasticsearch_image}:${STACK_VERSION}"
36
+
37
+ export suffix=rest-test
38
+ export moniker=$(echo "$elasticsearch_container" | tr -C "[:alnum:]" '-')
39
+ export network_name=${moniker}${suffix}
40
+
41
+ export ssl_cert="${script_path}/certs/testnode.crt"
42
+ export ssl_key="${script_path}/certs/testnode.key"
43
+ export ssl_ca="${script_path}/certs/ca.crt"
44
+
45
+ fi
46
+
47
+ export script_path=$(dirname $(realpath -s $0))
48
+ source $script_path/functions/cleanup.sh
49
+ source $script_path/functions/wait-for-container.sh
50
+ trap "cleanup_trap ${network_name}" EXIT
51
+
52
+
53
+ if [[ "$CLEANUP" == "true" ]]; then
54
+ cleanup_all_in_network $network_name
55
+ exit 0
56
+ fi
57
+
58
+ echo -e "\033[34;1mINFO:\033[0m Creating network $network_name if it does not exist already \033[0m"
59
+ docker network inspect "$network_name" > /dev/null 2>&1 || docker network create "$network_name"
60
+
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Exposes a routine scripts can call to wait for a container if that container set up a health command
4
+ #
5
+ # Please source .ci/functions/imports.sh as a whole not just this file
6
+ #
7
+ # Version 1.0.1
8
+ # - Initial version after refactor
9
+ # - Make sure wait_for_contiainer is silent
10
+
11
+ function wait_for_container {
12
+ set +x
13
+ until ! container_running "$1" || (container_running "$1" && [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "starting" ]]); do
14
+ echo ""
15
+ docker inspect -f "{{range .State.Health.Log}}{{.Output}}{{end}}" ${1}
16
+ echo -e "\033[34;1mINFO:\033[0m waiting for node $1 to be up\033[0m"
17
+ sleep 2;
18
+ done;
19
+
20
+ # Always show logs if the container is running, this is very useful both on CI as well as while developing
21
+ if container_running $1; then
22
+ docker logs $1
23
+ fi
24
+
25
+ if ! container_running $1 || [[ "$(docker inspect -f "{{.State.Health.Status}}" ${1})" != "healthy" ]]; then
26
+ cleanup_all_in_network $2
27
+ echo
28
+ echo -e "\033[31;1mERROR:\033[0m Failed to start $1 in detached mode beyond health checks\033[0m"
29
+ echo -e "\033[31;1mERROR:\033[0m dumped the docker log before shutting the node down\033[0m"
30
+ return 1
31
+ else
32
+ echo
33
+ echo -e "\033[32;1mSUCCESS:\033[0m Detached and healthy: ${1} on docker network: ${network_name}\033[0m"
34
+ return 0
35
+ fi
36
+ }
@@ -0,0 +1,30 @@
1
+ steps:
2
+ - label: ":elasticsearch: :javascript: ES JavaScript ({{ matrix.nodejs }}) Test Suite: {{ matrix.suite }}"
3
+ agents:
4
+ provider: "gcp"
5
+ env:
6
+ NODE_VERSION: "{{ matrix.nodejs }}"
7
+ TEST_SUITE: "{{ matrix.suite }}"
8
+ STACK_VERSION: 8.8.0-SNAPSHOT
9
+ matrix:
10
+ setup:
11
+ suite:
12
+ - "free"
13
+ - "platinum"
14
+ nodejs:
15
+ - "16"
16
+ - "18"
17
+ - "20"
18
+ command: ./.buildkite/run-tests.sh
19
+ artifact_paths: "./junit-output/junit-*.xml"
20
+ - wait: ~
21
+ continue_on_failure: true
22
+ - label: ":junit: Test results"
23
+ agents:
24
+ provider: "gcp"
25
+ image: family/core-ubuntu-2204
26
+ plugins:
27
+ - junit-annotate#v2.4.1:
28
+ artifacts: "junit-output/junit-*.xml"
29
+ job-uuid-file-pattern: 'junit-(.*).xml'
30
+ fail-build-on-error: true
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Once called Elasticsearch should be up and running
4
+ #
5
+ script_path=$(dirname "$(realpath -s "$0")")
6
+ set -euo pipefail
7
+ repo=$(pwd)
8
+
9
+ export NODE_VERSION=${NODE_VERSION:-18}
10
+
11
+ echo "--- :javascript: Building Docker image"
12
+ docker build \
13
+ --file "$script_path/Dockerfile" \
14
+ --tag elastic/elasticsearch-js \
15
+ --build-arg NODE_VERSION="$NODE_VERSION" \
16
+ .
17
+
18
+ echo "--- :javascript: Running $TEST_SUITE tests"
19
+ mkdir -p "$repo/junit-output"
20
+ docker run \
21
+ --network="${network_name}" \
22
+ --env "TEST_ES_SERVER=${elasticsearch_url}" \
23
+ --env "ELASTIC_PASSWORD=${elastic_password}" \
24
+ --env "TEST_SUITE=${TEST_SUITE}" \
25
+ --env "ELASTIC_USER=elastic" \
26
+ --env "BUILDKITE=true" \
27
+ --volume "$repo/junit-output:/junit-output" \
28
+ --name elasticsearch-js \
29
+ --rm \
30
+ elastic/elasticsearch-js \
31
+ bash -c "npm run test:integration; [ -f ./$TEST_SUITE-report-junit.xml ] && mv ./$TEST_SUITE-report-junit.xml /junit-output/junit-$BUILDKITE_JOB_ID.xml || echo 'No JUnit artifact found'"
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Launch one or more Elasticsearch nodes via the Docker image,
4
+ # to form a cluster suitable for running the REST API tests.
5
+ #
6
+ # Export the STACK_VERSION variable, eg. '8.0.0-SNAPSHOT'.
7
+ # Export the TEST_SUITE variable, eg. 'free' or 'platinum' defaults to 'free'.
8
+ # Export the NUMBER_OF_NODES variable to start more than 1 node
9
+
10
+ # Version 1.6.1
11
+ # - Initial version of the run-elasticsearch.sh script
12
+ # - Deleting the volume should not dependent on the container still running
13
+ # - Fixed `ES_JAVA_OPTS` config
14
+ # - Moved to STACK_VERSION and TEST_VERSION
15
+ # - Refactored into functions and imports
16
+ # - Support NUMBER_OF_NODES
17
+ # - Added 5 retries on docker pull for fixing transient network errors
18
+ # - Added flags to make local CCR configurations work
19
+ # - Added action.destructive_requires_name=false as the default will be true in v8
20
+ # - Added ingest.geoip.downloader.enabled=false as it causes false positives in testing
21
+ # - Moved ELASTIC_PASSWORD and xpack.security.enabled to the base arguments for "Security On by default"
22
+ # - Use https only when TEST_SUITE is "platinum", when "free" use http
23
+ # - Set xpack.security.enabled=false for "free" and xpack.security.enabled=true for "platinum"
24
+
25
+ script_path=$(dirname $(realpath -s $0))
26
+ source $script_path/functions/imports.sh
27
+ set -euo pipefail
28
+
29
+ echo -e "\033[34;1mINFO:\033[0m Take down node if called twice with the same arguments (DETACH=true) or on separate terminals \033[0m"
30
+ cleanup_node $es_node_name
31
+
32
+ master_node_name=${es_node_name}
33
+ cluster_name=${moniker}${suffix}
34
+
35
+ # Set vm.max_map_count kernel setting to 262144
36
+ sudo sysctl -w vm.max_map_count=262144
37
+
38
+ declare -a volumes
39
+ environment=($(cat <<-END
40
+ --env ELASTIC_PASSWORD=$elastic_password
41
+ --env node.name=$es_node_name
42
+ --env cluster.name=$cluster_name
43
+ --env cluster.initial_master_nodes=$master_node_name
44
+ --env discovery.seed_hosts=$master_node_name
45
+ --env cluster.routing.allocation.disk.threshold_enabled=false
46
+ --env bootstrap.memory_lock=true
47
+ --env node.attr.testattr=test
48
+ --env path.repo=/tmp
49
+ --env repositories.url.allowed_urls=http://snapshot.test*
50
+ --env action.destructive_requires_name=false
51
+ --env ingest.geoip.downloader.enabled=false
52
+ --env cluster.deprecation_indexing.enabled=false
53
+ END
54
+ ))
55
+ if [[ "$TEST_SUITE" == "platinum" ]]; then
56
+ environment+=($(cat <<-END
57
+ --env xpack.security.enabled=true
58
+ --env xpack.license.self_generated.type=trial
59
+ --env xpack.security.http.ssl.enabled=true
60
+ --env xpack.security.http.ssl.verification_mode=certificate
61
+ --env xpack.security.http.ssl.key=certs/testnode.key
62
+ --env xpack.security.http.ssl.certificate=certs/testnode.crt
63
+ --env xpack.security.http.ssl.certificate_authorities=certs/ca.crt
64
+ --env xpack.security.transport.ssl.enabled=true
65
+ --env xpack.security.transport.ssl.verification_mode=certificate
66
+ --env xpack.security.transport.ssl.key=certs/testnode.key
67
+ --env xpack.security.transport.ssl.certificate=certs/testnode.crt
68
+ --env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt
69
+ END
70
+ ))
71
+ volumes+=($(cat <<-END
72
+ --volume $ssl_cert:/usr/share/elasticsearch/config/certs/testnode.crt
73
+ --volume $ssl_key:/usr/share/elasticsearch/config/certs/testnode.key
74
+ --volume $ssl_ca:/usr/share/elasticsearch/config/certs/ca.crt
75
+ END
76
+ ))
77
+ else
78
+ environment+=($(cat <<-END
79
+ --env node.roles=data,data_cold,data_content,data_frozen,data_hot,data_warm,ingest,master,ml,remote_cluster_client,transform
80
+ --env xpack.security.enabled=false
81
+ --env xpack.security.http.ssl.enabled=false
82
+ END
83
+ ))
84
+ fi
85
+
86
+ cert_validation_flags=""
87
+ if [[ "$TEST_SUITE" == "platinum" ]]; then
88
+ cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
89
+ fi
90
+
91
+ echo "--- :elasticsearch: Environment setup"
92
+ echo "TEST_SUITE: $TEST_SUITE"
93
+ echo "Elasticsearch URL: $elasticsearch_url"
94
+ echo "Elasticsearch External URL: $external_elasticsearch_url"
95
+
96
+
97
+ echo "--- :elasticsearch: Running container"
98
+ # Pull the container, retry on failures up to 5 times with
99
+ # short delays between each attempt. Fixes most transient network errors.
100
+ docker_pull_attempts=0
101
+ until [ "$docker_pull_attempts" -ge 5 ]
102
+ do
103
+ docker pull docker.elastic.co/elasticsearch/"$elasticsearch_container" && break
104
+ docker_pull_attempts=$((docker_pull_attempts+1))
105
+ echo "Failed to pull image, retrying in 10 seconds (retry $docker_pull_attempts/5)..."
106
+ sleep 10
107
+ done
108
+
109
+ NUMBER_OF_NODES=${NUMBER_OF_NODES-1}
110
+ http_port=9200
111
+ for (( i=0; i<$NUMBER_OF_NODES; i++, http_port++ )); do
112
+ node_name=${es_node_name}$i
113
+ node_url=${external_elasticsearch_url/9200/${http_port}}$i
114
+ if [[ "$i" == "0" ]]; then node_name=$es_node_name; fi
115
+ environment+=($(cat <<-END
116
+ --env node.name=$node_name
117
+ END
118
+ ))
119
+ echo "$i: $http_port $node_url "
120
+ volume_name=${node_name}-${suffix}-data
121
+ volumes+=($(cat <<-END
122
+ --volume $volume_name:/usr/share/elasticsearch/data${i}
123
+ END
124
+ ))
125
+
126
+ # make sure we detach for all but the last node if DETACH=false (default) so all nodes are started
127
+ local_detach="true"
128
+ if [[ "$i" == "$((NUMBER_OF_NODES-1))" ]]; then local_detach=$DETACH; fi
129
+ echo -e "\033[34;1mINFO:\033[0m Starting container $node_name \033[0m"
130
+ set -x
131
+ docker run \
132
+ --name "$node_name" \
133
+ --network "$network_name" \
134
+ --env "ES_JAVA_OPTS=-Xms1g -Xmx1g -da:org.elasticsearch.xpack.ccr.index.engine.FollowingEngineAssertions" \
135
+ "${environment[@]}" \
136
+ "${volumes[@]}" \
137
+ --publish "$http_port":9200 \
138
+ --ulimit nofile=65536:65536 \
139
+ --ulimit memlock=-1:-1 \
140
+ --detach="$local_detach" \
141
+ --health-cmd="curl $cert_validation_flags --fail $elasticsearch_url/_cluster/health || exit 1" \
142
+ --health-interval=2s \
143
+ --health-retries=20 \
144
+ --health-timeout=2s \
145
+ --rm \
146
+ docker.elastic.co/elasticsearch/"$elasticsearch_container";
147
+
148
+ set +x
149
+ if wait_for_container "$es_node_name" "$network_name"; then
150
+ echo -e "\033[32;1mSUCCESS:\033[0m Running on: $node_url\033[0m"
151
+ fi
152
+ done
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Script to run Elasticsearch container and Elasticsearch client integration tests on Buildkite
4
+ #
5
+ # Version 0.1
6
+ #
7
+ script_path=$(dirname "$(realpath -s "$0")")
8
+ source "$script_path/functions/imports.sh"
9
+
10
+ set -euo pipefail
11
+
12
+ echo "--- :elasticsearch: Starting Elasticsearch"
13
+ DETACH=true bash "$script_path/run-elasticsearch.sh"
14
+
15
+ echo "+++ :javascript: Run Client"
16
+ bash "$script_path/run-client.sh"
@@ -0,0 +1,49 @@
1
+ ---
2
+ # yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
3
+ apiVersion: backstage.io/v1alpha1
4
+ kind: Component
5
+ metadata:
6
+ name: elasticsearch-js
7
+ spec:
8
+ type: library
9
+ owner: group:clients-team
10
+ lifecycle: production
11
+
12
+ ---
13
+ # yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
14
+ apiVersion: backstage.io/v1alpha1
15
+ kind: Resource
16
+ metadata:
17
+ name: elasticsearch-js-integration-tests
18
+ description: Elasticsearch JavaScript client integration tests
19
+ spec:
20
+ type: buildkite-pipeline
21
+ owner: group:clients-team
22
+ system: buildkite
23
+ implementation:
24
+ apiVersion: buildkite.elastic.dev/v1
25
+ kind: Pipeline
26
+ metadata:
27
+ name: Elasticsearch JavaScript client integration tests
28
+ spec:
29
+ repository: elastic/elasticsearch-js
30
+ pipeline_file: .buildkite/pipeline.yml
31
+ teams:
32
+ clients-team:
33
+ access_level: MANAGE_BUILD_AND_READ
34
+ everyone:
35
+ access_level: READ_ONLY
36
+ provider_settings:
37
+ build_pull_requests: false
38
+ cancel_intermediate_builds: true
39
+ cancel_intermediate_builds_branch_filter: '!main'
40
+ schedules:
41
+ main_semi_daily:
42
+ branch: 'main'
43
+ cronline: '*/12 * * *'
44
+ 8_8_semi_daily:
45
+ branch: '8.8'
46
+ cronline: '*/12 * * *'
47
+ 8_7_daily:
48
+ branch: '8.7'
49
+ cronline: '@daily'