org.apache.flink.streaming.connectors.elasticsearch.testutils.SourceSinkDataTestKit Java Examples
The following examples show how to use
org.apache.flink.streaming.connectors.elasticsearch.testutils.SourceSinkDataTestKit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests whether the Elasticsearch sink fails when there is no cluster to connect to. */ public void runInvalidElasticsearchClusterTest() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", "invalid-cluster-name"); source.addSink(createElasticsearchSinkForNode( 1, "invalid-cluster-name", new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test"), "123.123.123.123")); // incorrect ip address try { env.execute("Elasticsearch Sink Test"); } catch (JobExecutionException expectedException) { // test passes return; } fail(); }
Example #2
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests whether the Elasticsearch sink fails when there is no cluster to connect to. */ public void runInvalidElasticsearchClusterTest() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); source.addSink(createElasticsearchSinkForNode( 1, "invalid-cluster-name", SourceSinkDataTestKit.getJsonSinkFunction("test"), "123.123.123.123")); // incorrect ip address try { env.execute("Elasticsearch Sink Test"); } catch (JobExecutionException expectedException) { // every ES version throws a different exception in case of timeouts, so don't bother asserting on the exception // test passes return; } fail(); }
Example #3
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
private void runElasticSearchSinkTest(String index, Function<String, ElasticsearchSinkFunction<Tuple2<Integer, String>>> functionFactory) throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); source.addSink(createElasticsearchSinkForEmbeddedNode( 1, CLUSTER_NAME, functionFactory.apply(index))); env.execute("Elasticsearch Sink Test"); // verify the results Client client = elasticsearchResource.getClient(); SourceSinkDataTestKit.verifyProducedSinkData(client, index); client.close(); }
Example #4
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is empty. */ public void runEmptyAddressesTest() throws Exception { Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", CLUSTER_NAME); try { createElasticsearchSink( 1, CLUSTER_NAME, Collections.emptyList(), new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test")); } catch (IllegalArgumentException expectedException) { // test passes return; } fail(); }
Example #5
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is {@code null}. */ public void runNullAddressesTest() throws Exception { Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", CLUSTER_NAME); try { createElasticsearchSink( 1, CLUSTER_NAME, null, new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test")); } catch (IllegalArgumentException | NullPointerException expectedException) { // test passes return; } fail(); }
Example #6
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink works properly. */ public void runElasticsearchSinkTest() throws Exception { final String index = "elasticsearch-sink-test-index"; final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); source.addSink(createElasticsearchSinkForEmbeddedNode( 1, CLUSTER_NAME, new SourceSinkDataTestKit.TestElasticsearchSinkFunction(index))); env.execute("Elasticsearch Sink Test"); // verify the results Client client = embeddedNodeEnv.getClient(); SourceSinkDataTestKit.verifyProducedSinkData(client, index); client.close(); }
Example #7
Source File: ElasticsearchSinkTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests whether the Elasticsearch sink fails when there is no cluster to connect to. */ public void runInvalidElasticsearchClusterTest() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", "invalid-cluster-name"); source.addSink(createElasticsearchSinkForNode( 1, "invalid-cluster-name", new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test"), "123.123.123.123")); // incorrect ip address try { env.execute("Elasticsearch Sink Test"); } catch (JobExecutionException expectedException) { // test passes return; } fail(); }
Example #8
Source File: ElasticsearchSinkTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is empty. */ public void runEmptyAddressesTest() throws Exception { Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", CLUSTER_NAME); try { createElasticsearchSink( 1, CLUSTER_NAME, Collections.emptyList(), new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test")); } catch (IllegalArgumentException expectedException) { // test passes return; } fail(); }
Example #9
Source File: ElasticsearchSinkTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is {@code null}. */ public void runNullAddressesTest() throws Exception { Map<String, String> userConfig = new HashMap<>(); userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", CLUSTER_NAME); try { createElasticsearchSink( 1, CLUSTER_NAME, null, new SourceSinkDataTestKit.TestElasticsearchSinkFunction("test")); } catch (IllegalArgumentException | NullPointerException expectedException) { // test passes return; } fail(); }
Example #10
Source File: ElasticsearchSinkTestBase.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Tests that the Elasticsearch sink works properly. */ public void runElasticsearchSinkTest() throws Exception { final String index = "elasticsearch-sink-test-index"; final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); source.addSink(createElasticsearchSinkForEmbeddedNode( 1, CLUSTER_NAME, new SourceSinkDataTestKit.TestElasticsearchSinkFunction(index))); env.execute("Elasticsearch Sink Test"); // verify the results Client client = embeddedNodeEnv.getClient(); SourceSinkDataTestKit.verifyProducedSinkData(client, index); client.close(); }
Example #11
Source File: ElasticsearchSinkITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that behaviour of the deprecated {@link IndexRequestBuilder} constructor works properly. */ @Test public void testDeprecatedIndexRequestBuilderVariant() throws Exception { final String index = "index-req-builder-test-index"; final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); DataStreamSource<Tuple2<Integer, String>> source = env.addSource(new SourceSinkDataTestKit.TestDataSourceFunction()); Map<String, String> userConfig = new HashMap<>(); // This instructs the sink to emit after every element, otherwise they would be buffered userConfig.put(ElasticsearchSinkBase.CONFIG_KEY_BULK_FLUSH_MAX_ACTIONS, "1"); userConfig.put("cluster.name", CLUSTER_NAME); userConfig.put("node.local", "true"); List<TransportAddress> transports = new ArrayList<>(); transports.add(new LocalTransportAddress("1")); source.addSink(new ElasticsearchSink<>( userConfig, transports, new TestIndexRequestBuilder(index)) ); env.execute("Elasticsearch Deprecated IndexRequestBuilder Bridge Test"); // verify the results Client client = embeddedNodeEnv.getClient(); SourceSinkDataTestKit.verifyProducedSinkData(client, index); client.close(); }
Example #12
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is {@code null}. */ public void runNullAddressesTest() throws Exception { try { createElasticsearchSink( 1, CLUSTER_NAME, null, SourceSinkDataTestKit.getJsonSinkFunction("test")); } catch (IllegalArgumentException | NullPointerException expectedException) { // test passes return; } fail(); }
Example #13
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 5 votes |
/** * Tests that the Elasticsearch sink fails eagerly if the provided list of addresses is empty. */ public void runEmptyAddressesTest() throws Exception { try { createElasticsearchSink( 1, CLUSTER_NAME, Collections.emptyList(), SourceSinkDataTestKit.getJsonSinkFunction("test")); } catch (IllegalArgumentException expectedException) { // test passes return; } fail(); }
Example #14
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the Elasticsearch sink works properly with json. */ public void runElasticsearchSinkTest() throws Exception { runElasticSearchSinkTest("elasticsearch-sink-test-json-index", SourceSinkDataTestKit::getJsonSinkFunction); }
Example #15
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the Elasticsearch sink works properly with cbor. */ public void runElasticsearchSinkCborTest() throws Exception { runElasticSearchSinkTest("elasticsearch-sink-test-cbor-index", SourceSinkDataTestKit::getCborSinkFunction); }
Example #16
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the Elasticsearch sink works properly with smile. */ public void runElasticsearchSinkSmileTest() throws Exception { runElasticSearchSinkTest("elasticsearch-sink-test-smile-index", SourceSinkDataTestKit::getSmileSinkFunction); }
Example #17
Source File: ElasticsearchSinkTestBase.java From flink with Apache License 2.0 | 4 votes |
/** * Tests that the Elasticsearch sink works properly with yaml. */ public void runElasticsearchSinkYamlTest() throws Exception { runElasticSearchSinkTest("elasticsearch-sink-test-yaml-index", SourceSinkDataTestKit::getYamlSinkFunction); }