org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils Java Examples

The following examples show how to use org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils. 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: KinesisDataFetcherTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testIfNoShardsAreFoundShouldThrowException() throws Exception {
	List<String> fakeStreams = new LinkedList<>();
	fakeStreams.add("fakeStream1");
	fakeStreams.add("fakeStream2");

	HashMap<String, String> subscribedStreamsToLastSeenShardIdsUnderTest =
		KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(fakeStreams);

	TestableKinesisDataFetcher<String> fetcher =
		new TestableKinesisDataFetcher<>(
			fakeStreams,
			new TestSourceContext<>(),
			TestUtils.getStandardProperties(),
			new KinesisDeserializationSchemaWrapper<>(new SimpleStringSchema()),
			10,
			2,
			new AtomicReference<>(),
			new LinkedList<>(),
			subscribedStreamsToLastSeenShardIdsUnderTest,
			FakeKinesisBehavioursFactory.noShardsFoundForRequestedStreamsBehaviour());

	fetcher.runFetcher(); // this should throw RuntimeException
}
 
Example #2
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnixTimestampForValidateOptionDateProperty() {
	String unixTimestamp = "1459799926.480";

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP, unixTimestamp);

	try {
		KinesisConfigUtil.validateConsumerConfiguration(testConfig);
	} catch (Exception e) {
		e.printStackTrace();
		fail();
	}
}
 
Example #3
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDateStringForValidateOptionDateProperty() {
	String timestamp = "2016-04-04T19:58:46.480-00:00";

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP, timestamp);

	try {
		KinesisConfigUtil.validateConsumerConfiguration(testConfig);
	} catch (Exception e) {
		e.printStackTrace();
		fail();
	}
}
 
Example #4
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testDateStringForValidateOptionDateProperty() {
	String timestamp = "2016-04-04T19:58:46.480-00:00";

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP, timestamp);

	try {
		KinesisConfigUtil.validateConsumerConfiguration(testConfig);
	} catch (Exception e) {
		e.printStackTrace();
		fail();
	}
}
 
Example #5
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testUnixTimestampForValidateOptionDateProperty() {
	String unixTimestamp = "1459799926.480";

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP, unixTimestamp);

	try {
		KinesisConfigUtil.validateConsumerConfiguration(testConfig);
	} catch (Exception e) {
		e.printStackTrace();
		fail();
	}
}
 
Example #6
Source File: KinesisDataFetcherTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test(expected = RuntimeException.class)
public void testIfNoShardsAreFoundShouldThrowException() throws Exception {
	List<String> fakeStreams = new LinkedList<>();
	fakeStreams.add("fakeStream1");
	fakeStreams.add("fakeStream2");

	HashMap<String, String> subscribedStreamsToLastSeenShardIdsUnderTest =
		KinesisDataFetcher.createInitialSubscribedStreamsToLastDiscoveredShardsState(fakeStreams);

	TestableKinesisDataFetcher<String> fetcher =
		new TestableKinesisDataFetcher<>(
			fakeStreams,
			new TestSourceContext<>(),
			TestUtils.getStandardProperties(),
			new KinesisDeserializationSchemaWrapper<>(new SimpleStringSchema()),
			10,
			2,
			new AtomicReference<>(),
			new LinkedList<>(),
			subscribedStreamsToLastSeenShardIdsUnderTest,
			FakeKinesisBehavioursFactory.noShardsFoundForRequestedStreamsBehaviour());

	fetcher.runFetcher(); // this should throw RuntimeException
}
 
Example #7
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testStreamInitPositionTypeSetToAtTimestampButNoInitTimestampSetInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Please set value for initial timestamp ('"
			+ ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP + "') when using AT_TIMESTAMP initial position.");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #8
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetRecordsIntervalMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for getRecords sleep interval in milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETRECORDS_INTERVAL_MILLIS, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #9
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetShardIteratorBackoffMaxMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation max backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_MAX, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #10
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetShardIteratorBackoffBaseMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation base backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_BASE, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #11
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForListShardsBackoffBaseMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for list shards operation base backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.LIST_SHARDS_BACKOFF_BASE, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #12
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetRecordsBackoffMaxMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get records operation max backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETRECORDS_BACKOFF_MAX, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #13
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetRecordsBackoffBaseMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get records operation base backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETRECORDS_BACKOFF_BASE, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #14
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableIntForGetRecordsMaxCountInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for maximum records per getRecords shard operation");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETRECORDS_MAX, "unparsableInt");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #15
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableIntForGetRecordsRetriesInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for maximum retry attempts for getRecords shard operation");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETRECORDS_RETRIES, "unparsableInt");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #16
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableDoubleForListShardsBackoffExponentialConstantInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for list shards operation backoff exponential constant");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.LIST_SHARDS_BACKOFF_EXPONENTIAL_CONSTANT, "unparsableDouble");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #17
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForListShardsBackoffMaxMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for list shards operation max backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.LIST_SHARDS_BACKOFF_MAX, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #18
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableIntForGetShardIteratorRetriesInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for maximum retry attempts for getShardIterator shard operation");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_RETRIES, "unparsableInt");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #19
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnrecognizableStreamInitPositionTypeInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid initial position in stream");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "wrongInitPosition");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #20
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnrecognizableCredentialProviderTypeInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid AWS Credential Provider Type");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(AWSConfigConstants.AWS_CREDENTIALS_PROVIDER, "wrongProviderType");

	KinesisConfigUtil.validateAwsConfiguration(testConfig);
}
 
Example #21
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForShardDiscoveryIntervalMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for shard discovery sleep interval in milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_DISCOVERY_INTERVAL_MILLIS, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #22
Source File: FlinkKinesisProducerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testConfigureWithNonSerializableCustomPartitionerFails() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("The provided custom partitioner is not serializable");

	new FlinkKinesisProducer<>(new SimpleStringSchema(), TestUtils.getStandardProperties())
		.setCustomPartitioner(new NonSerializableCustomPartitioner());
}
 
Example #23
Source File: FlinkKinesisProducerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateWithNonSerializableDeserializerFails() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("The provided serialization schema is not serializable");

	new FlinkKinesisProducer<>(new NonSerializableSerializationSchema(), TestUtils.getStandardProperties());
}
 
Example #24
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableDoubleForGetShardIteratorBackoffExponentialConstantInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation backoff exponential constant");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_EXPONENTIAL_CONSTANT, "unparsableDouble");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #25
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForShardDiscoveryIntervalMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for shard discovery sleep interval in milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_DISCOVERY_INTERVAL_MILLIS, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #26
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableDoubleForGetShardIteratorBackoffExponentialConstantInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation backoff exponential constant");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_EXPONENTIAL_CONSTANT, "unparsableDouble");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #27
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetShardIteratorBackoffMaxMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation max backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_MAX, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #28
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableLongForGetShardIteratorBackoffBaseMillisInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for get shard iterator operation base backoff milliseconds");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_BACKOFF_BASE, "unparsableLong");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #29
Source File: KinesisConfigUtilTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableIntForGetShardIteratorRetriesInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for maximum retry attempts for getShardIterator shard operation");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.SHARD_GETITERATOR_RETRIES, "unparsableInt");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}
 
Example #30
Source File: KinesisConfigUtilTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testUnparsableDateForInitialTimestampInConfig() {
	exception.expect(IllegalArgumentException.class);
	exception.expectMessage("Invalid value given for initial timestamp for AT_TIMESTAMP initial position in stream.");

	Properties testConfig = TestUtils.getStandardProperties();
	testConfig.setProperty(ConsumerConfigConstants.AWS_CREDENTIALS_PROVIDER, "BASIC");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_POSITION, "AT_TIMESTAMP");
	testConfig.setProperty(ConsumerConfigConstants.STREAM_INITIAL_TIMESTAMP, "unparsableDate");

	KinesisConfigUtil.validateConsumerConfiguration(testConfig);
}