Skip to content

Commit

Permalink
[Integration Tests] Add annotations for JDBC to BigQuery Integration …
Browse files Browse the repository at this point in the history
…test.
  • Loading branch information
pranavbhandari24 committed Mar 27, 2023
1 parent e7dbfec commit 2f986c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
26 changes: 12 additions & 14 deletions it/src/main/java/com/google/cloud/teleport/it/TemplateTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 2f986c6

Please sign in to comment.