8
8
9
9
package org .opensearch .plugin .kafka ;
10
10
11
+ import org .junit .Assert ;
11
12
import org .opensearch .action .admin .cluster .node .info .NodeInfo ;
12
13
import org .opensearch .action .admin .cluster .node .info .NodesInfoRequest ;
13
14
import org .opensearch .action .admin .cluster .node .info .NodesInfoResponse ;
14
15
import org .opensearch .action .admin .cluster .node .info .PluginsAndModules ;
15
16
import org .opensearch .action .search .SearchResponse ;
17
+ import org .opensearch .client .Request ;
16
18
import org .opensearch .cluster .metadata .IndexMetadata ;
17
19
import org .opensearch .common .settings .Settings ;
18
20
import org .opensearch .index .query .RangeQueryBuilder ;
19
21
import org .opensearch .indices .pollingingest .PollingIngestStats ;
20
22
import org .opensearch .plugins .PluginInfo ;
21
23
import org .opensearch .test .OpenSearchIntegTestCase ;
22
- import org .junit . Assert ;
24
+ import org .opensearch . transport . client . Requests ;
23
25
26
+ import java .util .Arrays ;
24
27
import java .util .List ;
25
28
import java .util .concurrent .TimeUnit ;
26
29
import java .util .function .Function ;
27
30
import java .util .stream .Collectors ;
28
31
import java .util .stream .Stream ;
29
32
30
- import static org .hamcrest .Matchers .is ;
31
33
import static org .awaitility .Awaitility .await ;
34
+ import static org .hamcrest .Matchers .is ;
32
35
33
36
/**
34
37
* Integration test for Kafka ingestion
@@ -53,30 +56,17 @@ public void testPluginsAreInstalled() {
53
56
);
54
57
}
55
58
56
- public void testKafkaIngestion () {
59
+ public void testKafkaIngestion () throws Exception {
57
60
produceData ("1" , "name1" , "24" );
58
61
produceData ("2" , "name2" , "20" );
59
-
60
- createIndex (
61
- "test" ,
62
- Settings .builder ()
63
- .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , 1 )
64
- .put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , 0 )
65
- .put ("ingestion_source.type" , "kafka" )
66
- .put ("ingestion_source.pointer.init.reset" , "earliest" )
67
- .put ("ingestion_source.param.topic" , "test" )
68
- .put ("ingestion_source.param.bootstrap_servers" , kafka .getBootstrapServers ())
69
- .put ("index.replication.type" , "SEGMENT" )
70
- .build (),
71
- "{\" properties\" :{\" name\" :{\" type\" : \" text\" },\" age\" :{\" type\" : \" integer\" }}}}"
72
- );
62
+ createIndexWithDefaultSettings (1 , 0 );
73
63
74
64
RangeQueryBuilder query = new RangeQueryBuilder ("age" ).gte (21 );
75
65
await ().atMost (10 , TimeUnit .SECONDS ).untilAsserted (() -> {
76
- refresh ("test" );
77
- SearchResponse response = client ().prepareSearch ("test" ).setQuery (query ).get ();
66
+ refresh (indexName );
67
+ SearchResponse response = client ().prepareSearch (indexName ).setQuery (query ).get ();
78
68
assertThat (response .getHits ().getTotalHits ().value (), is (1L ));
79
- PollingIngestStats stats = client ().admin ().indices ().prepareStats ("test" ).get ().getIndex ("test" ).getShards ()[0 ]
69
+ PollingIngestStats stats = client ().admin ().indices ().prepareStats (indexName ).get ().getIndex (indexName ).getShards ()[0 ]
80
70
.getPollingIngestStats ();
81
71
assertNotNull (stats );
82
72
assertThat (stats .getMessageProcessorStats ().getTotalProcessedCount (), is (2L ));
@@ -141,4 +131,10 @@ public void testKafkaIngestion_RewindByOffset() {
141
131
assertThat (response .getHits ().getTotalHits ().value (), is (1L ));
142
132
});
143
133
}
134
+
135
+ public void testCloseIndex () throws Exception {
136
+ createIndexWithDefaultSettings (1 , 0 );
137
+ ensureGreen (indexName );
138
+ client ().admin ().indices ().close (Requests .closeIndexRequest (indexName )).get ();
139
+ }
144
140
}
0 commit comments