Skip to content

Commit

Permalink
Add remote state test for context field in metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Mohit Godwani <[email protected]>
  • Loading branch information
mgodwan committed Sep 3, 2024
1 parent e8a0e05 commit ab0cbea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected Settings nodeSettings(int nodeOrdinal) {

public void testPublication() throws Exception {
// create cluster with multi node (3 master + 2 data)
prepareCluster(3, 2, INDEX_NAME, 1, 2);
prepareClusterWithDefaultContext(3, 2, INDEX_NAME, 1, 2);
ensureStableCluster(5);
ensureGreen(INDEX_NAME);
// update settings on a random node
Expand Down Expand Up @@ -141,15 +141,22 @@ public void testPublication() throws Exception {
Settings settings = clusterService().getSettings();
logger.info("settings : {}", settings);
for (Client client : clients()) {
ClusterStateResponse response = client.admin().cluster().prepareState().clear().setMetadata(true).get();
ClusterStateResponse response = client.admin().cluster().prepareState().clear()
.setMetadata(true)
.setLocal(true)
.get();

String refreshSetting = response.getState()
.metadata()
.settings()
.get(RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey());

assertEquals(new Context("testcontext"), response.getState()
.metadata().indices().get(INDEX_NAME).context());
assertEquals("10mb", refreshSetting);


// Verify context is present in metadata
assertEquals(new Context(CONTEXT_NAME), response.getState()
.metadata().indices().get(INDEX_NAME).context());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,22 @@ protected void restore(boolean restoreAllShards, String... indices) {

protected void prepareCluster(int numClusterManagerNodes, int numDataOnlyNodes, String indices, int replicaCount, int shardCount) {
internalCluster().startClusterManagerOnlyNodes(numClusterManagerNodes);
internalCluster().startDataOnlyNodes(numDataOnlyNodes);
for (String index : indices.split(",")) {
createIndex(index, remoteStoreIndexSettings(replicaCount, shardCount));
ensureYellowAndNoInitializingShards(index);
ensureGreen(index);
}
}

// Adding context template to the cluster
protected void prepareClusterWithDefaultContext(int numClusterManagerNodes, int numDataOnlyNodes, String indices, int replicaCount, int shardCount) {
internalCluster().startClusterManagerOnlyNodes(numClusterManagerNodes);

// Adding context template to the cluster
addTemplateForContext(CONTEXT_NAME);

internalCluster().startDataOnlyNodes(numDataOnlyNodes);

for (String index : indices.split(",")) {
// Ensure index is created with additional metadata field.
assertAcked(prepareCreate(index)
Expand Down

0 comments on commit ab0cbea

Please sign in to comment.