From 2f986c6de623c0e4fd2db3115f0d04d761751ceb Mon Sep 17 00:00:00 2001 From: pranavbhandari24 Date: Mon, 27 Mar 2023 13:55:34 -0400 Subject: [PATCH] [Integration Tests] Add annotations for JDBC to BigQuery Integration test. --- .../cloud/teleport/it/TemplateTestBase.java | 26 +++++++++---------- .../v2/templates/JdbcToBigQueryIT.java | 8 ++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/it/src/main/java/com/google/cloud/teleport/it/TemplateTestBase.java b/it/src/main/java/com/google/cloud/teleport/it/TemplateTestBase.java index 6a5cd5ccec..7c6172353a 100644 --- a/it/src/main/java/com/google/cloud/teleport/it/TemplateTestBase.java +++ b/it/src/main/java/com/google/cloud/teleport/it/TemplateTestBase.java @@ -232,30 +232,28 @@ private Template getTemplateAnnotation( String templateName = annotation.template(); Template[] templateAnnotations = templateClass.getAnnotationsByType(Template.class); if (templateAnnotations.length == 0) { - LOG.warn( - "Template mentioned in @TemplateIntegrationTest for {} does not contain a @Template" - + " annotation, skipping.", - getClass()); - return null; + throw new RuntimeException( + String.format( + "Template mentioned in @TemplateIntegrationTest for %s does not contain a @Template" + + " annotation.", + getClass())); } else if (templateAnnotations.length == 1) { return templateAnnotations[0]; } else if (templateName.isEmpty()) { - LOG.warn( - "Template mentioned in @TemplateIntegrationTest for {} contains multiple @Template" - + " annotations. Please provide templateName field in @TemplateIntegrationTest," - + " skipping.", - getClass()); - return null; + throw new RuntimeException( + String.format( + "Template mentioned in @TemplateIntegrationTest for %s contains multiple @Template" + + " annotations. Please provide templateName field in @TemplateIntegrationTest.", + getClass())); } for (Template template : templateAnnotations) { if (template.name().equals(templateName)) { return template; } } - LOG.warn( + throw new RuntimeException( "templateName does not match any Template annotations. Please recheck" - + " @TemplateIntegrationTest, skipping"); - return null; + + " @TemplateIntegrationTest."); } /** diff --git a/v2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/JdbcToBigQueryIT.java b/v2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/JdbcToBigQueryIT.java index 48ebad33e4..bcfd1dad55 100644 --- a/v2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/JdbcToBigQueryIT.java +++ b/v2/googlecloud-to-googlecloud/src/test/java/com/google/cloud/teleport/v2/templates/JdbcToBigQueryIT.java @@ -33,13 +33,21 @@ import com.google.cloud.teleport.it.launcher.PipelineLauncher.LaunchConfig; import com.google.cloud.teleport.it.launcher.PipelineLauncher.LaunchInfo; import com.google.cloud.teleport.it.launcher.PipelineOperator.Result; +import com.google.cloud.teleport.metadata.TemplateIntegrationTest; import java.io.IOException; import java.util.List; import java.util.Map; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +/** Integration test for {@link JdbcToBigQuery} Flex template. */ +@Category(TemplateIntegrationTest.class) +@TemplateIntegrationTest(JdbcToBigQuery.class) +@RunWith(JUnit4.class) public class JdbcToBigQueryIT extends TemplateTestBase { private static final String QUERY = "select * from %s";