Skip to content

Commit c7c8a28

Browse files
committed
Updated run-elasticsearch script and Cleanup YAML tests
1 parent 8cfc951 commit c7c8a28

File tree

4 files changed

+52
-30
lines changed

4 files changed

+52
-30
lines changed

.ci/functions/imports.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ if [[ -z $es_node_name ]]; then
2626
export es_node_name=instance
2727
export elastic_password=changeme
2828
export elasticsearch_image=elasticsearch
29-
export elasticsearch_url=https://elastic:${elastic_password}@${es_node_name}:9200
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
3034
export external_elasticsearch_url=${elasticsearch_url/$es_node_name/localhost}
3135
export elasticsearch_container="${elasticsearch_image}:${STACK_VERSION}"
3236

.ci/run-elasticsearch.sh

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Export the TEST_SUITE variable, eg. 'free' or 'platinum' defaults to 'free'.
88
# Export the NUMBER_OF_NODES variable to start more than 1 node
99

10-
# Version 1.3.0
10+
# Version 1.6.1
1111
# - Initial version of the run-elasticsearch.sh script
1212
# - Deleting the volume should not dependent on the container still running
1313
# - Fixed `ES_JAVA_OPTS` config
@@ -17,6 +17,10 @@
1717
# - Added 5 retries on docker pull for fixing transient network errors
1818
# - Added flags to make local CCR configurations work
1919
# - 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"
2024

2125
script_path=$(dirname $(realpath -s $0))
2226
source $script_path/functions/imports.sh
@@ -30,6 +34,7 @@ cluster_name=${moniker}${suffix}
3034

3135
declare -a volumes
3236
environment=($(cat <<-END
37+
--env ELASTIC_PASSWORD=$elastic_password
3338
--env node.name=$es_node_name
3439
--env cluster.name=$cluster_name
3540
--env cluster.initial_master_nodes=$master_node_name
@@ -39,31 +44,45 @@ environment=($(cat <<-END
3944
--env node.attr.testattr=test
4045
--env path.repo=/tmp
4146
--env repositories.url.allowed_urls=http://snapshot.test*
42-
--env ingest.geoip.downloader.enabled=false
4347
--env action.destructive_requires_name=false
44-
--env ELASTIC_PASSWORD=$elastic_password
45-
--env xpack.license.self_generated.type=trial
46-
--env xpack.security.enabled=true
47-
--env xpack.security.http.ssl.enabled=true
48-
--env xpack.security.http.ssl.verification_mode=certificate
49-
--env xpack.security.http.ssl.key=certs/testnode.key
50-
--env xpack.security.http.ssl.certificate=certs/testnode.crt
51-
--env xpack.security.http.ssl.certificate_authorities=certs/ca.crt
52-
--env xpack.security.transport.ssl.enabled=true
53-
--env xpack.security.transport.ssl.verification_mode=certificate
54-
--env xpack.security.transport.ssl.key=certs/testnode.key
55-
--env xpack.security.transport.ssl.certificate=certs/testnode.crt
56-
--env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt
48+
--env ingest.geoip.downloader.enabled=false
49+
--env cluster.deprecation_indexing.enabled=false
5750
END
5851
))
59-
volumes+=($(cat <<-END
60-
--volume $ssl_cert:/usr/share/elasticsearch/config/certs/testnode.crt
61-
--volume $ssl_key:/usr/share/elasticsearch/config/certs/testnode.key
62-
--volume $ssl_ca:/usr/share/elasticsearch/config/certs/ca.crt
52+
if [[ "$TEST_SUITE" == "platinum" ]]; then
53+
environment+=($(cat <<-END
54+
--env xpack.security.enabled=true
55+
--env xpack.license.self_generated.type=trial
56+
--env xpack.security.http.ssl.enabled=true
57+
--env xpack.security.http.ssl.verification_mode=certificate
58+
--env xpack.security.http.ssl.key=certs/testnode.key
59+
--env xpack.security.http.ssl.certificate=certs/testnode.crt
60+
--env xpack.security.http.ssl.certificate_authorities=certs/ca.crt
61+
--env xpack.security.transport.ssl.enabled=true
62+
--env xpack.security.transport.ssl.verification_mode=certificate
63+
--env xpack.security.transport.ssl.key=certs/testnode.key
64+
--env xpack.security.transport.ssl.certificate=certs/testnode.crt
65+
--env xpack.security.transport.ssl.certificate_authorities=certs/ca.crt
66+
END
67+
))
68+
volumes+=($(cat <<-END
69+
--volume $ssl_cert:/usr/share/elasticsearch/config/certs/testnode.crt
70+
--volume $ssl_key:/usr/share/elasticsearch/config/certs/testnode.key
71+
--volume $ssl_ca:/usr/share/elasticsearch/config/certs/ca.crt
72+
END
73+
))
74+
else
75+
environment+=($(cat <<-END
76+
--env xpack.security.enabled=false
77+
--env xpack.security.http.ssl.enabled=false
6378
END
6479
))
80+
fi
6581

66-
cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
82+
cert_validation_flags=""
83+
if [[ "$TEST_SUITE" == "platinum" ]]; then
84+
cert_validation_flags="--insecure --cacert /usr/share/elasticsearch/config/certs/ca.crt --resolve ${es_node_name}:443:127.0.0.1"
85+
fi
6786

6887
# Pull the container, retry on failures up to 5 times with
6988
# short delays between each attempt. Fixes most transient network errors.

.ci/run-repository.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ script_path=$(dirname $(realpath -s $0))
99
source $script_path/functions/imports.sh
1010
set -euo pipefail
1111

12-
PHP_VERSION=${PHP_VERSION-7.4-cli}
12+
PHP_VERSION=${PHP_VERSION-8.0-cli}
1313
ELASTICSEARCH_URL=${ELASTICSEARCH_URL-"$elasticsearch_url"}
1414
elasticsearch_container=${elasticsearch_container-}
1515

tests/Elasticsearch/Tests/Utility.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ private static function ensureNoInitializingShards(Client $client): void
189189
*/
190190
private static function wipeCluster(Client $client): void
191191
{
192-
if (self::$hasRollups) {
192+
if (self::$hasXPack) {
193193
self::wipeRollupJobs($client);
194194
self::waitForPendingRollupTasks($client);
195195
}
196-
self::deleteAllSLMPolicies($client);
196+
if (version_compare(self::getVersion($client), '7.3.99') > 0) {
197+
self::deleteAllSLMPolicies($client);
198+
}
197199

198200
// Clean up searchable snapshots indices before deleting snapshots and repositories
199201
if (self::$hasXPack && version_compare(self::getVersion($client), '7.7.99') > 0) {
@@ -212,14 +214,11 @@ private static function wipeCluster(Client $client): void
212214

213215
self::wipeClusterSettings($client);
214216

215-
if (self::$hasIlm) {
217+
if (self::$hasXPack) {
216218
self::deleteAllILMPolicies($client);
217219
}
218-
if (self::$hasCcr) {
219-
self::deleteAllAutoFollowPatterns($client);
220-
}
221220
if (self::$hasXPack) {
222-
self::deleteAllTasks($client);
221+
self::deleteAllAutoFollowPatterns($client);
223222
}
224223

225224
self::deleteAllNodeShutdownMetadata($client);
@@ -421,7 +420,7 @@ private static function wipeAllIndices(Client $client): void
421420
'expand_wildcards' => $expand
422421
]);
423422
} catch (Exception $e) {
424-
if ($e->getCode() != '404') {
423+
if (!in_array($e->getCode(), ['404'])) {
425424
throw $e;
426425
}
427426
}

0 commit comments

Comments
 (0)