forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Shivansh Arora <[email protected]>
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/ClusterStateIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.upgrades; | ||
|
||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
|
||
import java.util.Map; | ||
|
||
public class ClusterStateIT extends AbstractRollingTestCase{ | ||
public void testTemplateMetadataUpgrades() throws Exception { | ||
if (CLUSTER_TYPE == ClusterType.OLD) { | ||
String templateName = "my_template"; | ||
Request putIndexTemplate = new Request("PUT", "_template/" + templateName); | ||
putIndexTemplate.setJsonEntity("{\"index_patterns\": [\"pattern-1\", \"log-*\"]}"); | ||
client().performRequest(putIndexTemplate); | ||
verifyTemplateMetadataInClusterState(); | ||
} else { | ||
verifyTemplateMetadataInClusterState(); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private static void verifyTemplateMetadataInClusterState() throws Exception { | ||
Request request = new Request("GET", "_cluster/state/metadata"); | ||
Response response = client().performRequest(request); | ||
assertOK(response); | ||
Map<String, Object> metadata = (Map<String, Object>) entityAsMap(response).get("metadata"); | ||
assertNotNull(metadata.get("templates")); | ||
} | ||
} |