Skip to content

Commit e211f26

Browse files
committed
review feedback
1 parent df35d10 commit e211f26

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/RunningSnapshotIT.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
import com.carrotsearch.randomizedtesting.annotations.Name;
1313

1414
import org.elasticsearch.client.Request;
15+
import org.elasticsearch.common.Strings;
1516
import org.elasticsearch.common.settings.Settings;
1617
import org.elasticsearch.test.rest.ObjectPath;
1718

1819
import java.io.IOException;
1920
import java.util.Collection;
2021

22+
import static org.elasticsearch.upgrades.SnapshotBasedRecoveryIT.indexDocs;
23+
import static org.hamcrest.Matchers.empty;
2124
import static org.hamcrest.Matchers.equalTo;
2225
import static org.hamcrest.Matchers.not;
2326

@@ -34,18 +37,22 @@ public void testRunningSnapshotCompleteAfterUpgrade() throws Exception {
3437
final var nodeIds = getNodesInfo(client()).keySet();
3538

3639
if (isOldCluster()) {
40+
registerRepository(repositoryName, "fs", randomBoolean(), Settings.builder().put("location", "backup").build());
3741
// create an index to have one shard per node
3842
createIndex(indexName, indexSettings(3, 0).put("index.routing.allocation.total_shards_per_node", 1).build());
3943
ensureGreen(indexName);
44+
if (randomBoolean()) {
45+
indexDocs(indexName, between(10, 50));
46+
}
4047
flush(indexName, true);
4148
// Signal shutdown to prevent snapshot from being completed
4249
putShutdownMetadata(nodeIds);
43-
registerRepository(repositoryName, "fs", randomBoolean(), Settings.builder().put("location", "backup").build());
4450
createSnapshot(repositoryName, snapshotName, false);
4551
assertRunningSnapshot(repositoryName, snapshotName);
4652
} else {
4753
if (isUpgradedCluster()) {
4854
deleteShutdownMetadata(nodeIds);
55+
assertNoShutdownMetadata(nodeIds);
4956
ensureGreen(indexName);
5057
assertBusy(() -> assertCompletedSnapshot(repositoryName, snapshotName));
5158
} else {
@@ -73,6 +80,13 @@ private void deleteShutdownMetadata(Collection<String> nodeIds) throws IOExcepti
7380
}
7481
}
7582

83+
private void assertNoShutdownMetadata(Collection<String> nodeIds) throws IOException {
84+
final ObjectPath responsePath = assertOKAndCreateObjectPath(
85+
client().performRequest(new Request("GET", "/_nodes/" + Strings.collectionToCommaDelimitedString(nodeIds) + "/shutdown"))
86+
);
87+
assertThat(responsePath.evaluate("nodes"), empty());
88+
}
89+
7690
private void assertRunningSnapshot(String repositoryName, String snapshotName) throws IOException {
7791
final Request request = new Request("GET", "/_snapshot/" + repositoryName + "/_current");
7892
final ObjectPath responsePath = assertOKAndCreateObjectPath(client().performRequest(request));

qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/SnapshotBasedRecoveryIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private static Map<String, Object> search(String index, QueryBuilder query) thro
233233
return responseAsMap;
234234
}
235235

236-
private void indexDocs(String indexName, int numDocs) throws IOException {
236+
static void indexDocs(String indexName, int numDocs) throws IOException {
237237
final StringBuilder bulkBody = new StringBuilder();
238238
for (int i = 0; i < numDocs; i++) {
239239
bulkBody.append("{\"index\":{\"_id\":\"").append(i).append("\"}}\n");

server/src/test/java/org/elasticsearch/snapshots/SnapshotsInProgressSerializationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public void testSerializationBwc() throws IOException {
9191
final var oldVersion = TransportVersionUtils.getPreviousVersion(TransportVersions.PROJECT_ID_IN_SNAPSHOT);
9292
final BytesStreamOutput out = new BytesStreamOutput();
9393
out.setTransportVersion(oldVersion);
94-
final Custom orig = createTestInstance(() -> randomSnapshot(ProjectId.DEFAULT));
95-
orig.writeTo(out);
94+
final Custom original = createTestInstance(() -> randomSnapshot(ProjectId.DEFAULT));
95+
original.writeTo(out);
9696

9797
final var in = out.bytes().streamInput();
9898
in.setTransportVersion(oldVersion);
9999
final SnapshotsInProgress fromStream = new SnapshotsInProgress(in);
100-
assertThat(fromStream, equalTo(orig));
100+
assertThat(fromStream, equalTo(original));
101101
}
102102

103103
public void testDiffSerializationBwc() throws IOException {

0 commit comments

Comments
 (0)