From ab24b66039af8db9d7faaf8d770940f4ad78aa72 Mon Sep 17 00:00:00 2001 From: lucienlu-aws <132623944+lucienlu-aws@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:56:05 -0700 Subject: [PATCH] Skip cross account tests if no cross account credentials are provided (#1321) --- .../amazon/kinesis/application/TestConsumer.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java index 5bfb928af..47e879041 100644 --- a/amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java +++ b/amazon-kinesis-client/src/test/java/software/amazon/kinesis/application/TestConsumer.java @@ -44,6 +44,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import static org.junit.Assume.assumeTrue; + @Slf4j public class TestConsumer { public final KCLAppConfig consumerConfig; @@ -79,8 +81,9 @@ public TestConsumer(KCLAppConfig consumerConfig) throws Exception { public void run() throws Exception { + // Skip cross account tests if no cross account credentials are provided if (consumerConfig.isCrossAccount()) { - verifyCrossAccountCreds(); + assumeTrue(consumerConfig.getCrossAccountCredentialsProvider() != null); } final StreamExistenceManager streamExistenceManager = new StreamExistenceManager(this.consumerConfig); @@ -126,13 +129,6 @@ public void run() throws Exception { } } - private void verifyCrossAccountCreds() { - if (consumerConfig.getCrossAccountCredentialsProvider() == null) { - throw new RuntimeException("To run cross account integration tests, pass in an AWS profile with -D" + - KCLAppConfig.CROSS_ACCOUNT_PROFILE_PROPERTY); - } - } - private void cleanTestResources(StreamExistenceManager streamExistenceManager, LeaseTableManager leaseTableManager) throws Exception { log.info("----------Before starting, Cleaning test environment----------"); log.info("----------Deleting all lease tables in account----------");