|
25 | 25 | import org.elasticsearch.packaging.util.Installation;
|
26 | 26 | import org.elasticsearch.packaging.util.Platforms;
|
27 | 27 | import org.elasticsearch.packaging.util.ServerUtils;
|
| 28 | +import org.elasticsearch.packaging.util.Shell; |
28 | 29 | import org.elasticsearch.packaging.util.Shell.Result;
|
29 | 30 | import org.junit.After;
|
30 | 31 | import org.junit.Before;
|
|
45 | 46 | import static org.elasticsearch.packaging.util.Docker.existsInContainer;
|
46 | 47 | import static org.elasticsearch.packaging.util.Docker.getContainerLogs;
|
47 | 48 | import static org.elasticsearch.packaging.util.Docker.getImageLabels;
|
| 49 | +import static org.elasticsearch.packaging.util.Docker.getImageName; |
48 | 50 | import static org.elasticsearch.packaging.util.Docker.getJson;
|
49 | 51 | import static org.elasticsearch.packaging.util.Docker.mkDirWithPrivilegeEscalation;
|
50 | 52 | import static org.elasticsearch.packaging.util.Docker.removeContainer;
|
@@ -524,12 +526,17 @@ public void test100NoCoreFilesInImage() {
|
524 | 526 | /**
|
525 | 527 | * Check that there are no files with a GID other than 0.
|
526 | 528 | */
|
527 |
| - public void test101AllFilesAreGroupZero() throws Exception { |
528 |
| - // We wait for Elasticsearch to finish starting up in order to avoid the situation where `find` traverses the filesystem |
529 |
| - // and sees files in a directory listing, which have disappeared by the time `find` tries to examine them. This periodically |
530 |
| - // happened with the keystore, for example. |
531 |
| - waitForElasticsearch(installation); |
532 |
| - final String findResults = sh.run("find . -not -gid 0").stdout; |
| 529 | + public void test101AllFilesAreGroupZero() { |
| 530 | + // Run a `find` command in a new container without Elasticsearch running, so |
| 531 | + // that the results aren't subject to sporadic failures from files appearing / |
| 532 | + // disappearing while `find` is traversing the filesystem. |
| 533 | + // |
| 534 | + // We also create a file under `data/` to ensure that files are created with the |
| 535 | + // expected group. |
| 536 | + final Shell localSh = new Shell(); |
| 537 | + final String findResults = localSh.run( |
| 538 | + "docker run --rm --tty " + getImageName(distribution) + " bash -c ' touch data/test && find . -not -gid 0 ' " |
| 539 | + ).stdout; |
533 | 540 |
|
534 | 541 | assertThat("Found some files whose GID != 0", findResults, is(emptyString()));
|
535 | 542 | }
|
|
0 commit comments