Skip to content

Commit 4a20067

Browse files
authored
Fix file settings service test on windows (elastic#115234) (elastic#115502)
Backports elastic#115234
1 parent 4f3de83 commit 4a20067

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ tests:
338338
- class: org.elasticsearch.xpack.inference.TextEmbeddingCrudIT
339339
method: testPutE5Small_withPlatformSpecificVariant
340340
issue: https://github.com/elastic/elasticsearch/issues/113950
341-
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceTests
342-
method: testProcessFileChanges
343-
issue: https://github.com/elastic/elasticsearch/issues/115280
344341
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
345342
issue: https://github.com/elastic/elasticsearch/issues/115315
346343
- class: org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT

server/src/test/java/org/elasticsearch/reservedstate/service/FileSettingsServiceTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testProcessFileChanges() throws Exception {
250250
fileSettingsService.start();
251251
fileSettingsService.clusterChanged(new ClusterChangedEvent("test", clusterService.state(), ClusterState.EMPTY_STATE));
252252
// second file change; contents still don't matter
253-
writeTestFile(fileSettingsService.watchedFile(), "{}");
253+
overwriteTestFile(fileSettingsService.watchedFile(), "{}");
254254

255255
// wait for listener to be called (once for initial processing, once for subsequent update)
256256
assertTrue(latch.await(20, TimeUnit.SECONDS));
@@ -355,6 +355,12 @@ public void testHandleSnapshotRestoreResetsMetadata() throws Exception {
355355
private void writeTestFile(Path path, String contents) throws IOException {
356356
Path tempFilePath = createTempFile();
357357
Files.writeString(tempFilePath, contents);
358-
Files.move(tempFilePath, path, StandardCopyOption.ATOMIC_MOVE);
358+
Files.move(tempFilePath, path, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
359+
}
360+
361+
private void overwriteTestFile(Path path, String contents) throws IOException {
362+
Path tempFilePath = createTempFile();
363+
Files.writeString(tempFilePath, contents);
364+
Files.move(tempFilePath, path, StandardCopyOption.REPLACE_EXISTING);
359365
}
360366
}

0 commit comments

Comments
 (0)