|
15 | 15 | import org.elasticsearch.common.settings.Settings; |
16 | 16 | import org.elasticsearch.common.time.DateFormatter; |
17 | 17 | import org.elasticsearch.common.time.FormatNames; |
| 18 | +import org.elasticsearch.core.SuppressForbidden; |
18 | 19 | import org.elasticsearch.repositories.fs.FsRepository; |
19 | 20 | import org.elasticsearch.test.cluster.ElasticsearchCluster; |
20 | 21 | import org.elasticsearch.test.cluster.local.distribution.DistributionType; |
@@ -45,7 +46,7 @@ public class LogsdbSnapshotRestoreIT extends ESRestTestCase { |
45 | 46 |
|
46 | 47 | private static ElasticsearchCluster cluster = ElasticsearchCluster.local() |
47 | 48 | .distribution(DistributionType.DEFAULT) |
48 | | - .setting("path.repo", () -> repoDirectory.getRoot().getPath()) |
| 49 | + .setting("path.repo", () -> getRepoPath()) |
49 | 50 | .setting("xpack.security.enabled", "false") |
50 | 51 | .setting("xpack.license.self_generated.type", "trial") |
51 | 52 | .build(); |
@@ -162,17 +163,15 @@ public void cleanup() throws Exception { |
162 | 163 | deleteDataStream("logs-my-test"); |
163 | 164 | } |
164 | 165 |
|
| 166 | + @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File") |
165 | 167 | static void snapshotAndRestore(String sourceMode, String arrayType, boolean sourceOnly) throws IOException { |
166 | 168 | String dataStreamName = "logs-my-test"; |
167 | 169 | String repositoryName = "my-repository"; |
168 | 170 | if (sourceOnly) { |
169 | | - var repositorySettings = Settings.builder() |
170 | | - .put("delegate_type", "fs") |
171 | | - .put("location", repoDirectory.getRoot().getPath()) |
172 | | - .build(); |
| 171 | + var repositorySettings = Settings.builder().put("delegate_type", "fs").put("location", getRepoPath()).build(); |
173 | 172 | registerRepository(repositoryName, "source", true, repositorySettings); |
174 | 173 | } else { |
175 | | - var repositorySettings = Settings.builder().put("location", repoDirectory.getRoot().getPath()).build(); |
| 174 | + var repositorySettings = Settings.builder().put("location", getRepoPath()).build(); |
176 | 175 | registerRepository(repositoryName, FsRepository.TYPE, true, repositorySettings); |
177 | 176 | } |
178 | 177 |
|
@@ -214,13 +213,10 @@ static void snapshotAndFail(String sourceMode, String arrayType, boolean sourceO |
214 | 213 | String dataStreamName = "logs-my-test"; |
215 | 214 | String repositoryName = "my-repository"; |
216 | 215 | if (sourceOnly) { |
217 | | - var repositorySettings = Settings.builder() |
218 | | - .put("delegate_type", "fs") |
219 | | - .put("location", repoDirectory.getRoot().getPath()) |
220 | | - .build(); |
| 216 | + var repositorySettings = Settings.builder().put("delegate_type", "fs").put("location", getRepoPath()).build(); |
221 | 217 | registerRepository(repositoryName, "source", true, repositorySettings); |
222 | 218 | } else { |
223 | | - var repositorySettings = Settings.builder().put("location", repoDirectory.getRoot().getPath()).build(); |
| 219 | + var repositorySettings = Settings.builder().put("location", getRepoPath()).build(); |
224 | 220 | registerRepository(repositoryName, FsRepository.TYPE, true, repositorySettings); |
225 | 221 | } |
226 | 222 |
|
@@ -338,4 +334,9 @@ public static void assertDocCount(RestClient client, String indexName, long docC |
338 | 334 | ); |
339 | 335 | } |
340 | 336 |
|
| 337 | + @SuppressForbidden(reason = "TemporaryFolder only has io.File methods, not nio.File") |
| 338 | + private static String getRepoPath() { |
| 339 | + return repoDirectory.getRoot().getPath(); |
| 340 | + } |
| 341 | + |
341 | 342 | } |
0 commit comments