@ExtendWith(value={ConnectorTestingExtension.class,TestLoggerExtension.class,TestCaseInvocationContextProvider.class}) @TestInstance(value=PER_CLASS) @Experimental public abstract class SourceTestSuiteBase<T> extends Object
All cases should have well-descriptive JavaDoc, including:
Constructor and Description |
---|
SourceTestSuiteBase() |
Modifier and Type | Method and Description |
---|---|
protected List<T> |
generateAndWriteTestData(int splitIndex,
ExternalContext<T> externalContext)
Generate a set of test records and write it to the given split writer.
|
void |
testIdleReader(TestEnvironment testEnv,
ExternalContext<T> externalContext)
Test connector source with an idle reader.
|
void |
testMultipleSplits(TestEnvironment testEnv,
ExternalContext<T> externalContext)
Test connector source with multiple splits in the external system
|
void |
testSourceSingleSplit(TestEnvironment testEnv,
ExternalContext<T> externalContext)
Test connector source with only one split in the external system.
|
void |
testTaskManagerFailure(TestEnvironment testEnv,
ExternalContext<T> externalContext,
ClusterControllable controller)
Test connector source with task manager failover.
|
@TestTemplate @DisplayName(value="Test source with single split") public void testSourceSingleSplit(TestEnvironment testEnv, ExternalContext<T> externalContext) throws Exception
This test will create one split in the external system, write test data into it, and consume back via a Flink job with 1 parallelism.
The number and order of records consumed by Flink need to be identical to the test data written to the external system in order to pass this test.
A bounded source is required for this test.
Exception
@TestTemplate @DisplayName(value="Test source with multiple splits") public void testMultipleSplits(TestEnvironment testEnv, ExternalContext<T> externalContext) throws Exception
This test will create 4 splits in the external system, write test data to all splits, and consume back via a Flink job with 4 parallelism.
The number and order of records in each split consumed by Flink need to be identical to the test data written into the external system to pass this test. There's no requirement for record order across splits.
A bounded source is required for this test.
Exception
@TestTemplate @DisplayName(value="Test source with at least one idle parallelism") public void testIdleReader(TestEnvironment testEnv, ExternalContext<T> externalContext) throws Exception
This test will create 4 split in the external system, write test data to all splits, and consume back via a Flink job with 5 parallelism, so at least one parallelism / source reader will be idle (assigned with no splits). If the split enumerator of the source doesn't signal NoMoreSplitsEvent to the idle source reader, the Flink job will never spin to FINISHED state.
The number and order of records in each split consumed by Flink need to be identical to the test data written into the external system to pass this test. There's no requirement for record order across splits.
A bounded source is required for this test.
Exception
@TestTemplate @DisplayName(value="Test TaskManager failure") public void testTaskManagerFailure(TestEnvironment testEnv, ExternalContext<T> externalContext, ClusterControllable controller) throws Exception
This test will create 1 split in the external system, write test record set A into the split, restart task manager to trigger job failover, write test record set B into the split, and terminate the Flink job finally.
The number and order of records consumed by Flink should be identical to A before the failover and B after the failover in order to pass the test.
An unbounded source is required for this test, since TaskManager failover will be triggered in the middle of the test.
Exception
protected List<T> generateAndWriteTestData(int splitIndex, ExternalContext<T> externalContext)
externalContext
- External contextCopyright © 2014–2023 The Apache Software Foundation. All rights reserved.