From 31d2558cef5bb96712dba8a4804b226b19bef02a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 24 Jun 2025 12:49:07 -0700 Subject: [PATCH 1/2] Handle createLink post security manager in StoreRecoveryTests When running under security manager an assumptionw as made that failing to create a hard link due to security exception implied hard links were supported. Now that security manager is gone, the code to create a hard link in StoreRecoveryTests executes. But in the case of windows, BasicFileAttributes.fileKey does not return a unique object that can be used to verify a link exists. Yet the fact createLink returned is enough to trust the jdk was able to create a link. closes #124104 --- muted-tests.yml | 3 --- .../org/elasticsearch/index/shard/StoreRecoveryTests.java | 7 +------ 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 9e97373941ca5..e0fb6b1246d92 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -253,9 +253,6 @@ tests: - class: org.elasticsearch.packaging.test.DockerTests method: test012SecurityCanBeDisabled issue: https://github.com/elastic/elasticsearch/issues/116636 -- class: org.elasticsearch.index.shard.StoreRecoveryTests - method: testAddIndices - issue: https://github.com/elastic/elasticsearch/issues/124104 - class: org.elasticsearch.smoketest.MlWithSecurityIT method: test {yaml=ml/data_frame_analytics_crud/Test get stats on newly created config} issue: https://github.com/elastic/elasticsearch/issues/121726 diff --git a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java index bc3b44b908246..59533a38ec554 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java @@ -254,12 +254,7 @@ public boolean hardLinksSupported(Path path) throws IOException { try { Files.createFile(path.resolve("foo.bar")); Files.createLink(path.resolve("test"), path.resolve("foo.bar")); - BasicFileAttributes destAttr = Files.readAttributes(path.resolve("test"), BasicFileAttributes.class); - BasicFileAttributes sourceAttr = Files.readAttributes(path.resolve("foo.bar"), BasicFileAttributes.class); - // we won't get here - no permission ;) - return destAttr.fileKey() != null && destAttr.fileKey().equals(sourceAttr.fileKey()); - } catch (SecurityException ex) { - return true; // if we run into that situation we know it's supported. + return true; // createLink returning without exception means hard links are supported } catch (UnsupportedOperationException ex) { return false; } From 65227cf395296336b5f28161b17ebe9d3f13ac94 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine Date: Tue, 24 Jun 2025 20:02:34 +0000 Subject: [PATCH 2/2] [CI] Auto commit changes from spotless --- .../java/org/elasticsearch/index/shard/StoreRecoveryTests.java | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java index 59533a38ec554..18240fa24414b 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java @@ -44,7 +44,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Map; import java.util.function.Predicate;