Skip to content

Commit 6c3168a

Browse files
authored
Fix file settings service test on windows (elastic#115234) (elastic#115491)
Backport elastic#115234
1 parent 5bdeaa1 commit 6c3168a

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
@@ -385,9 +385,6 @@ tests:
385385
issue: https://github.com/elastic/elasticsearch/issues/114839
386386
- class: org.elasticsearch.xpack.security.authc.ldap.GroupMappingIT
387387
issue: https://github.com/elastic/elasticsearch/issues/115221
388-
- class: org.elasticsearch.reservedstate.service.FileSettingsServiceTests
389-
method: testProcessFileChanges
390-
issue: https://github.com/elastic/elasticsearch/issues/115280
391388
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
392389
method: test {yaml=reference/rest-api/usage/line_38}
393390
issue: https://github.com/elastic/elasticsearch/issues/113694

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)