|
@@ -49,6 +49,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
|
|
import java.util.function.Function;
|
|
|
|
|
|
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
|
|
|
+import static org.hamcrest.Matchers.allOf;
|
|
|
+import static org.hamcrest.Matchers.containsString;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.greaterThan;
|
|
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
|
@@ -246,6 +248,34 @@ public abstract class AbstractSearchableSnapshotsRestTestCase extends ESRestTest
|
|
|
randomFrom(Boolean.TRUE, Boolean.FALSE, null)
|
|
|
);
|
|
|
assertThat(extractValue(searchResults, "hits.total.value"), equalTo(numDocs));
|
|
|
+
|
|
|
+ // takes a snapshot of the searchable snapshot index into the source-only repository should fail
|
|
|
+ String sourceOnlySnapshot = "source-only-snap-" + randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
|
|
+ final Request request = new Request(HttpPut.METHOD_NAME, "_snapshot/" + WRITE_REPOSITORY_NAME + '/' + sourceOnlySnapshot);
|
|
|
+ request.addParameter("wait_for_completion", "true");
|
|
|
+ request.setJsonEntity("""
|
|
|
+ {
|
|
|
+ "include_global_state": false,
|
|
|
+ "indices" : "%s"
|
|
|
+ }
|
|
|
+ """.formatted(indexName));
|
|
|
+
|
|
|
+ final Response response = adminClient().performRequest(request);
|
|
|
+ assertThat(response.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
|
|
|
+
|
|
|
+ final List<Map<String, Object>> failures = extractValue(responseAsMap(response), "snapshot.failures");
|
|
|
+ assertThat(failures, notNullValue());
|
|
|
+ assertThat(failures.size(), greaterThan(0));
|
|
|
+ for (Map<String, Object> failure : failures) {
|
|
|
+ assertThat(extractValue(failure, "status"), equalTo(RestStatus.INTERNAL_SERVER_ERROR.toString()));
|
|
|
+ assertThat(
|
|
|
+ extractValue(failure, "reason"),
|
|
|
+ allOf(
|
|
|
+ containsString("is not a regular index"),
|
|
|
+ containsString("cannot be snapshotted into a source-only repository")
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|
|
|
}, true);
|
|
|
}
|