@@ -1154,7 +1154,7 @@ public void testOrphanStreamConfigIsPopulatedWithArn() {
1154
1154
}
1155
1155
1156
1156
@ Test
1157
- public void testMismatchingArnRegionAndKinesisClientRegionThrowsException () {
1157
+ public void testMismatchingArnRegionAndKinesisClientRegionOnSchedulerConstructionThrowsException () {
1158
1158
final Region streamArnRegion = Region .US_WEST_1 ;
1159
1159
Assert .assertNotEquals (streamArnRegion , kinesisClient .serviceClientConfiguration ().region ());
1160
1160
@@ -1169,6 +1169,35 @@ public void testMismatchingArnRegionAndKinesisClientRegionThrowsException() {
1169
1169
leaseManagementConfig , lifecycleConfig , metricsConfig , processorConfig , retrievalConfig ));
1170
1170
}
1171
1171
1172
+ @ Test
1173
+ public void testDynamicallyAddedStreamsWithRegionMismatchingKinesisClientRegionAreIgnored () throws Exception {
1174
+ final Region mismatchingStreamRegion = Region .US_WEST_1 ;
1175
+ final Region kinesisClientRegion = kinesisClient .serviceClientConfiguration ().region ();
1176
+ Assert .assertNotEquals (mismatchingStreamRegion , kinesisClientRegion );
1177
+
1178
+ final StreamIdentifier streamWithMismatchingRegion = StreamIdentifier .multiStreamInstance (
1179
+ Arn .fromString (constructStreamArnStr (mismatchingStreamRegion , TEST_ACCOUNT , "stream-1" )), TEST_EPOCH );
1180
+
1181
+ final StreamIdentifier streamWithMatchingRegion = StreamIdentifier .multiStreamInstance (
1182
+ Arn .fromString (constructStreamArnStr (kinesisClientRegion , TEST_ACCOUNT , "stream-2" )), TEST_EPOCH );
1183
+
1184
+ when (multiStreamTracker .streamConfigList ()).thenReturn (
1185
+ Collections .emptyList (), // returned on scheduler construction
1186
+ Arrays .asList ( // returned on stream sync
1187
+ new StreamConfig (streamWithMismatchingRegion , TEST_INITIAL_POSITION ),
1188
+ new StreamConfig (streamWithMatchingRegion , TEST_INITIAL_POSITION )));
1189
+ retrievalConfig = new RetrievalConfig (kinesisClient , multiStreamTracker , applicationName )
1190
+ .retrievalFactory (retrievalFactory );
1191
+ scheduler = spy (new Scheduler (checkpointConfig , coordinatorConfig ,
1192
+ leaseManagementConfig , lifecycleConfig , metricsConfig , processorConfig , retrievalConfig ));
1193
+ when (scheduler .shouldSyncStreamsNow ()).thenReturn (true );
1194
+
1195
+ final Set <StreamIdentifier > syncedStreams = scheduler .checkAndSyncStreamShardsAndLeases ();
1196
+ final Set <StreamIdentifier > currentStreamConfigMapKeys = scheduler .currentStreamConfigMap ().keySet ();
1197
+ assertFalse (Sets .union (currentStreamConfigMapKeys , syncedStreams ).contains (streamWithMismatchingRegion ));
1198
+ assertTrue (Sets .union (currentStreamConfigMapKeys , syncedStreams ).contains (streamWithMatchingRegion ));
1199
+ }
1200
+
1172
1201
private static String constructStreamIdentifierSer (long accountId , String streamName ) {
1173
1202
return String .join (":" , String .valueOf (accountId ), streamName , String .valueOf (TEST_EPOCH ));
1174
1203
}
0 commit comments