|
16 | 16 | import org.opensearch.index.query.RangeQueryBuilder;
|
17 | 17 | import org.opensearch.test.InternalTestCluster;
|
18 | 18 | import org.opensearch.test.OpenSearchIntegTestCase;
|
| 19 | +import org.opensearch.transport.client.Requests; |
19 | 20 |
|
20 | 21 | import java.nio.file.Path;
|
21 | 22 | import java.util.Arrays;
|
@@ -46,20 +47,7 @@ public void testSegmentReplicationWithRemoteStore() throws Exception {
|
46 | 47 |
|
47 | 48 | internalCluster().startClusterManagerOnlyNode();
|
48 | 49 | final String nodeA = internalCluster().startDataOnlyNode();
|
49 |
| - |
50 |
| - createIndex( |
51 |
| - indexName, |
52 |
| - Settings.builder() |
53 |
| - .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
54 |
| - .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) |
55 |
| - .put("ingestion_source.type", "kafka") |
56 |
| - .put("ingestion_source.pointer.init.reset", "earliest") |
57 |
| - .put("ingestion_source.param.topic", topicName) |
58 |
| - .put("ingestion_source.param.bootstrap_servers", kafka.getBootstrapServers()) |
59 |
| - .put("index.replication.type", "SEGMENT") |
60 |
| - .build(), |
61 |
| - mapping |
62 |
| - ); |
| 50 | + createIndexWithDefaultSettings(1, 1); |
63 | 51 |
|
64 | 52 | ensureYellowAndNoInitializingShards(indexName);
|
65 | 53 | final String nodeB = internalCluster().startDataOnlyNode();
|
@@ -117,6 +105,56 @@ public void testSegmentReplicationWithRemoteStore() throws Exception {
|
117 | 105 | waitForSearchableDocs(6, Arrays.asList(nodeB, nodeC));
|
118 | 106 | }
|
119 | 107 |
|
| 108 | + public void testCloseIndex() throws Exception { |
| 109 | + produceData("1", "name1", "24"); |
| 110 | + produceData("2", "name2", "20"); |
| 111 | + internalCluster().startClusterManagerOnlyNode(); |
| 112 | + final String nodeA = internalCluster().startDataOnlyNode(); |
| 113 | + final String nodeB = internalCluster().startDataOnlyNode(); |
| 114 | + |
| 115 | + createIndexWithDefaultSettings(1, 1); |
| 116 | + ensureGreen(indexName); |
| 117 | + waitForSearchableDocs(2, Arrays.asList(nodeA, nodeB)); |
| 118 | + client().admin().indices().close(Requests.closeIndexRequest(indexName)).get(); |
| 119 | + } |
| 120 | + |
| 121 | + public void testErrorStrategy() throws Exception { |
| 122 | + produceData("1", "name1", "25"); |
| 123 | + // malformed message |
| 124 | + produceData("2", "", ""); |
| 125 | + produceData("3", "name3", "25"); |
| 126 | + |
| 127 | + internalCluster().startClusterManagerOnlyNode(); |
| 128 | + final String node = internalCluster().startDataOnlyNode(); |
| 129 | + |
| 130 | + createIndex( |
| 131 | + indexName, |
| 132 | + Settings.builder() |
| 133 | + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) |
| 134 | + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) |
| 135 | + .put("ingestion_source.type", "kafka") |
| 136 | + .put("ingestion_source.error_strategy", "block") |
| 137 | + .put("ingestion_source.pointer.init.reset", "earliest") |
| 138 | + .put("ingestion_source.param.topic", topicName) |
| 139 | + .put("ingestion_source.param.bootstrap_servers", kafka.getBootstrapServers()) |
| 140 | + .put("index.replication.type", "SEGMENT") |
| 141 | + .build(), |
| 142 | + "{\"properties\":{\"name\":{\"type\": \"text\"},\"age\":{\"type\": \"integer\"}}}}" |
| 143 | + ); |
| 144 | + |
| 145 | + ensureGreen(indexName); |
| 146 | + waitForState(() -> "block".equalsIgnoreCase(getSettings(indexName, "index.ingestion_source.error_strategy"))); |
| 147 | + waitForSearchableDocs(1, Arrays.asList(node)); |
| 148 | + |
| 149 | + client().admin() |
| 150 | + .indices() |
| 151 | + .prepareUpdateSettings(indexName) |
| 152 | + .setSettings(Settings.builder().put("ingestion_source.error_strategy", "drop")) |
| 153 | + .get(); |
| 154 | + waitForState(() -> "drop".equalsIgnoreCase(getSettings(indexName, "index.ingestion_source.error_strategy"))); |
| 155 | + waitForSearchableDocs(2, Arrays.asList(node)); |
| 156 | + } |
| 157 | + |
120 | 158 | private void verifyRemoteStoreEnabled(String node) {
|
121 | 159 | GetSettingsResponse settingsResponse = client(node).admin().indices().prepareGetSettings(indexName).get();
|
122 | 160 | String remoteStoreEnabled = settingsResponse.getIndexToSettings().get(indexName).get("index.remote_store.enabled");
|
|
0 commit comments