|
42 | 42 | import co.elastic.clients.elasticsearch.indices.GetMappingResponse;
|
43 | 43 | import co.elastic.clients.elasticsearch.indices.IndexState;
|
44 | 44 | import co.elastic.clients.elasticsearch.model.ModelTestCase;
|
| 45 | +import co.elastic.clients.elasticsearch.snapshot.CreateRepositoryResponse; |
| 46 | +import co.elastic.clients.elasticsearch.snapshot.CreateSnapshotResponse; |
45 | 47 | import co.elastic.clients.json.JsonpMapper;
|
46 | 48 | import co.elastic.clients.json.jsonb.JsonbJsonpMapper;
|
47 | 49 | import co.elastic.clients.transport.ElasticsearchTransport;
|
@@ -76,17 +78,19 @@ public class RequestTest extends Assert {
|
76 | 78 |
|
77 | 79 | @BeforeClass
|
78 | 80 | public static void setup() {
|
79 |
| - container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.15.1") |
| 81 | + container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.16.2") |
80 | 82 | .withEnv("ES_JAVA_OPTS", "-Xms256m -Xmx256m")
|
| 83 | + .withEnv("path.repo", "/tmp") // for snapshots |
81 | 84 | .withStartupTimeout(Duration.ofSeconds(30))
|
82 | 85 | .withPassword("changeme");
|
83 | 86 | container.start();
|
| 87 | + int port = container.getMappedPort(9200); |
84 | 88 |
|
85 | 89 | BasicCredentialsProvider credsProv = new BasicCredentialsProvider();
|
86 | 90 | credsProv.setCredentials(
|
87 | 91 | AuthScope.ANY, new UsernamePasswordCredentials("elastic", "changeme")
|
88 | 92 | );
|
89 |
| - restClient = RestClient.builder(new HttpHost("localhost", container.getMappedPort(9200))) |
| 93 | + restClient = RestClient.builder(new HttpHost("localhost", port)) |
90 | 94 | .setHttpClientConfigCallback(hc -> hc.setDefaultCredentialsProvider(credsProv))
|
91 | 95 | .build();
|
92 | 96 | transport = new RestClientTransport(restClient, mapper);
|
@@ -394,6 +398,30 @@ public void testDefaultIndexSettings() throws IOException {
|
394 | 398 | assertNull(settings.get(index).defaults());
|
395 | 399 | }
|
396 | 400 |
|
| 401 | + @Test |
| 402 | + public void testSnapshotCreation() throws IOException { |
| 403 | + // https://github.com/elastic/elasticsearch-java/issues/74 |
| 404 | + // https://github.com/elastic/elasticsearch/issues/82358 |
| 405 | + |
| 406 | + CreateRepositoryResponse repo = client.snapshot().createRepository(b1 -> b1 |
| 407 | + .name("test") |
| 408 | + .type("fs") |
| 409 | + .settings(b2 -> b2 |
| 410 | + .location("/tmp/test-repo") |
| 411 | + ) |
| 412 | + ); |
| 413 | + |
| 414 | + assertTrue(repo.acknowledged()); |
| 415 | + |
| 416 | + CreateSnapshotResponse snapshot = client.snapshot().create(b -> b |
| 417 | + .repository("test") |
| 418 | + .snapshot("1") |
| 419 | + .waitForCompletion(true) |
| 420 | + ); |
| 421 | + |
| 422 | + assertNotNull(snapshot.snapshot()); |
| 423 | + } |
| 424 | + |
397 | 425 | @Test
|
398 | 426 | public void testValueBodyResponse() throws Exception {
|
399 | 427 | DiskUsageResponse resp = client.indices().diskUsage(b -> b
|
|
0 commit comments