Skip to content

Commit 8357887

Browse files
masseykejoegallo
andauthored
Fixing DatabaseNodeServiceIT testNonGzippedDatabase and testGzippedDatabase race condition (#115463)
Co-authored-by: Joe Gallo <[email protected]>
1 parent 38a19bf commit 8357887

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/DatabaseNodeServiceIT.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,21 @@ public class DatabaseNodeServiceIT extends AbstractGeoIpIT {
4646
public void testNonGzippedDatabase() throws Exception {
4747
String databaseType = "GeoLite2-Country";
4848
String databaseFileName = databaseType + ".mmdb";
49-
// making the dabase name unique so we know we're not using another one:
49+
// making the database name unique so we know we're not using another one:
5050
String databaseName = randomAlphaOfLength(20) + "-" + databaseFileName;
5151
byte[] mmdbBytes = getBytesForFile(databaseFileName);
5252
final DatabaseNodeService databaseNodeService = internalCluster().getInstance(DatabaseNodeService.class);
5353
assertNull(databaseNodeService.getDatabase(databaseName));
5454
int numChunks = indexData(databaseName, mmdbBytes);
55-
retrieveDatabase(databaseNodeService, databaseName, mmdbBytes, numChunks);
56-
assertBusy(() -> assertNotNull(databaseNodeService.getDatabase(databaseName)));
57-
assertValidDatabase(databaseNodeService, databaseName, databaseType);
55+
/*
56+
* If DatabaseNodeService::checkDatabases runs it will sometimes (rarely) remove the database we are using in this test while we
57+
* are trying to assert things about it. So if it does then we 'just' try again.
58+
*/
59+
assertBusy(() -> {
60+
retrieveDatabase(databaseNodeService, databaseName, mmdbBytes, numChunks);
61+
assertNotNull(databaseNodeService.getDatabase(databaseName));
62+
assertValidDatabase(databaseNodeService, databaseName, databaseType);
63+
});
5864
}
5965

6066
/*
@@ -64,16 +70,22 @@ public void testNonGzippedDatabase() throws Exception {
6470
public void testGzippedDatabase() throws Exception {
6571
String databaseType = "GeoLite2-Country";
6672
String databaseFileName = databaseType + ".mmdb";
67-
// making the dabase name unique so we know we're not using another one:
73+
// making the database name unique so we know we're not using another one:
6874
String databaseName = randomAlphaOfLength(20) + "-" + databaseFileName;
6975
byte[] mmdbBytes = getBytesForFile(databaseFileName);
7076
byte[] gzipBytes = gzipFileBytes(databaseName, mmdbBytes);
7177
final DatabaseNodeService databaseNodeService = internalCluster().getInstance(DatabaseNodeService.class);
7278
assertNull(databaseNodeService.getDatabase(databaseName));
7379
int numChunks = indexData(databaseName, gzipBytes);
74-
retrieveDatabase(databaseNodeService, databaseName, gzipBytes, numChunks);
75-
assertBusy(() -> assertNotNull(databaseNodeService.getDatabase(databaseName)));
76-
assertValidDatabase(databaseNodeService, databaseName, databaseType);
80+
/*
81+
* If DatabaseNodeService::checkDatabases runs it will sometimes (rarely) remove the database we are using in this test while we
82+
* are trying to assert things about it. So if it does then we 'just' try again.
83+
*/
84+
assertBusy(() -> {
85+
retrieveDatabase(databaseNodeService, databaseName, gzipBytes, numChunks);
86+
assertNotNull(databaseNodeService.getDatabase(databaseName));
87+
assertValidDatabase(databaseNodeService, databaseName, databaseType);
88+
});
7789
}
7890

7991
/*

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,6 @@ tests:
182182
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
183183
method: test {categorize.Categorize SYNC}
184184
issue: https://github.com/elastic/elasticsearch/issues/113722
185-
- class: org.elasticsearch.ingest.geoip.DatabaseNodeServiceIT
186-
method: testNonGzippedDatabase
187-
issue: https://github.com/elastic/elasticsearch/issues/113821
188-
- class: org.elasticsearch.ingest.geoip.DatabaseNodeServiceIT
189-
method: testGzippedDatabase
190-
issue: https://github.com/elastic/elasticsearch/issues/113752
191185
- class: org.elasticsearch.threadpool.SimpleThreadPoolIT
192186
method: testThreadPoolMetrics
193187
issue: https://github.com/elastic/elasticsearch/issues/108320

0 commit comments

Comments
 (0)