Skip to content

Commit f0d7ec4

Browse files
[Test] Rework detecting elasticsearch process in docker tests (#128013)
* [Test] Rework detecting elasticsearch process in docker tests This tweaks detecting the elasticsearch process id by using jps instead of ps which has been problematic in the past exceeding available COLUMN sizes due to es commandline invocation getting longer and longer * Remove few muted tests * Reuse ps for detecting processes but use pipe to find the right one jps doesnt work well with different users * Tweak java command running lookup to work with wolfi * Cleanup changes * [CI] Auto commit changes from spotless --------- Co-authored-by: elasticsearchmachine <[email protected]>
1 parent e586a01 commit f0d7ec4

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

muted-tests.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -447,33 +447,27 @@ tests:
447447
- class: org.elasticsearch.indices.stats.IndexStatsIT
448448
method: testThrottleStats
449449
issue: https://github.com/elastic/elasticsearch/issues/126359
450-
- class: org.elasticsearch.packaging.test.DockerTests
451-
method: test040JavaUsesTheOsProvidedKeystore
452-
issue: https://github.com/elastic/elasticsearch/issues/127437
450+
- class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests
451+
method: testRandomWithFilter
452+
issue: https://github.com/elastic/elasticsearch/issues/127963
453+
- class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests
454+
method: testSearchBoost
455+
issue: https://github.com/elastic/elasticsearch/issues/127969
456+
- class: org.elasticsearch.search.vectors.IVFKnnFloatVectorQueryTests
457+
method: testFindFewer
458+
issue: https://github.com/elastic/elasticsearch/issues/128002
453459
- class: org.elasticsearch.xpack.remotecluster.RemoteClusterSecurityRestIT
454460
method: testTaskCancellation
455461
issue: https://github.com/elastic/elasticsearch/issues/128009
456462
- class: org.elasticsearch.xpack.esql.action.CrossClusterQueryWithPartialResultsIT
457463
method: testOneRemoteClusterPartial
458464
issue: https://github.com/elastic/elasticsearch/issues/124055
459-
- class: org.elasticsearch.packaging.test.DockerTests
460-
method: test041AmazonCaCertsAreInTheKeystore
461-
issue: https://github.com/elastic/elasticsearch/issues/128007
462465
- class: org.elasticsearch.compute.aggregation.SampleDoubleAggregatorFunctionTests
463466
method: testSimpleWithCranky
464467
issue: https://github.com/elastic/elasticsearch/issues/128024
465468
- class: org.elasticsearch.xpack.esql.qa.multi_node.EsqlSpecIT
466469
method: test {lookup-join.MvJoinKeyOnTheLookupIndex ASYNC}
467470
issue: https://github.com/elastic/elasticsearch/issues/128030
468-
- class: org.elasticsearch.packaging.test.DockerTests
469-
method: test072RunEsAsDifferentUserAndGroup
470-
issue: https://github.com/elastic/elasticsearch/issues/128031
471-
- class: org.elasticsearch.packaging.test.DockerTests
472-
method: test042KeystorePermissionsAreCorrect
473-
issue: https://github.com/elastic/elasticsearch/issues/128019
474-
- class: org.elasticsearch.packaging.test.DockerTests
475-
method: test073RunEsAsDifferentUserAndGroupWithoutBindMounting
476-
issue: https://github.com/elastic/elasticsearch/issues/128044
477471
- class: org.elasticsearch.compute.aggregation.PercentileIntGroupingAggregatorFunctionTests
478472
method: testManyInitialManyPartialFinalRunner
479473
issue: https://github.com/elastic/elasticsearch/issues/128092

qa/packaging/src/test/java/org/elasticsearch/packaging/util/docker/Docker.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ public class Docker {
7575
public static final int STARTUP_SLEEP_INTERVAL_MILLISECONDS = 1000;
7676
public static final int STARTUP_ATTEMPTS_MAX = 30;
7777

78+
private static final String ELASTICSEARCH_FULL_CLASSNAME = "org.elasticsearch.bootstrap.Elasticsearch";
79+
private static final String FIND_ELASTICSEARCH_PROCESS = "for pid in $(ps -eo pid,comm | grep java | awk '\\''{print $1}'\\''); "
80+
+ "do cmdline=$(tr \"\\0\" \" \" < /proc/$pid/cmdline 2>/dev/null); [[ $cmdline == *"
81+
+ ELASTICSEARCH_FULL_CLASSNAME
82+
+ "* ]] && echo \"$pid: $cmdline\"; done";
83+
// The length of the command exceeds what we can use for COLUMNS so we use a pipe to detect the process we're looking for
84+
7885
/**
7986
* Tracks the currently running Docker image. An earlier implementation used a fixed container name,
8087
* but that appeared to cause problems with repeatedly destroying and recreating containers with
@@ -185,11 +192,8 @@ public static void waitForElasticsearchToStart() {
185192
try {
186193
// Give the container enough time for security auto-configuration or a chance to crash out
187194
Thread.sleep(STARTUP_SLEEP_INTERVAL_MILLISECONDS);
188-
189-
// Set COLUMNS so that `ps` doesn't truncate its output
190-
psOutput = dockerShell.run("bash -c 'COLUMNS=4000 ps ax'").stdout();
191-
192-
if (psOutput.contains("org.elasticsearch.bootstrap.Elasticsearch")) {
195+
psOutput = dockerShell.run("bash -c '" + FIND_ELASTICSEARCH_PROCESS + " | wc -l'").stdout();
196+
if (psOutput.contains("1")) {
193197
isElasticsearchRunning = true;
194198
break;
195199
}

0 commit comments

Comments
 (0)