Skip to content

Commit

Permalink
bring back bigquery integration tests (#1717)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgardens authored Jan 20, 2021
1 parent 4cc6560 commit 4d7a5e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {

integrationTestJavaImplementation project(':airbyte-integrations:bases:standard-destination-test')
integrationTestJavaImplementation files(project(':airbyte-integrations:bases:base-normalization').airbyteDocker.outputs)
integrationTestJavaImplementation project(':airbyte-integrations:connectors:destination-bigquery')

implementation files(project(':airbyte-integrations:bases:base-java').airbyteDocker.outputs)
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -181,8 +182,7 @@ private void tearDownBigQuery() {
tornDown = true;
}

// todo - same test as csv destination
// @Test
@Test
void testSpec() throws IOException {
final ConnectorSpecification actual = new BigQueryDestination().spec();
final String resourceString = MoreResources.readResource("spec.json");
Expand All @@ -191,24 +191,23 @@ void testSpec() throws IOException {
assertEquals(expected, actual);
}

// todo - same test as csv destination
// @Test
@Test
void testCheckSuccess() {
final AirbyteConnectionStatus actual = new BigQueryDestination().check(config);
final AirbyteConnectionStatus expected = new AirbyteConnectionStatus().withStatus(Status.SUCCEEDED);
assertEquals(expected, actual);
}

// @Test
@Test
void testCheckFailure() {
((ObjectNode) config).put(BigQueryDestination.CONFIG_PROJECT_ID, "fake");
final AirbyteConnectionStatus actual = new BigQueryDestination().check(config);
final AirbyteConnectionStatus expected = new AirbyteConnectionStatus().withStatus(Status.FAILED)
.withMessage("Access Denied: Project fake: User does not have bigquery.jobs.create permission in project fake.");
.withMessage("Access Denied: Project fake: User does not have bigquery.datasets.create permission in project fake.");
assertEquals(expected, actual);
}

// @Test
@Test
void testWriteSuccess() throws Exception {
final BigQueryDestination destination = new BigQueryDestination();
final DestinationConsumer<AirbyteMessage> consumer = destination.write(config, CATALOG);
Expand Down Expand Up @@ -237,8 +236,7 @@ void testWriteSuccess() throws Exception {
.collect(Collectors.toList()));
}

@SuppressWarnings("ResultOfMethodCallIgnored")
// @Test
@Test
void testWriteFailure() throws Exception {
// hack to force an exception to be thrown from within the consumer.
final AirbyteMessage spiedMessage = spy(MESSAGE_USERS1);
Expand Down Expand Up @@ -277,7 +275,12 @@ private Set<String> fetchNamesOfTablesInDb() throws InterruptedException {

private void assertTmpTablesNotPresent(List<String> tableNames) throws InterruptedException {
final Set<String> tmpTableNamePrefixes = tableNames.stream().map(name -> name + "_").collect(Collectors.toSet());
assertTrue(fetchNamesOfTablesInDb().stream().noneMatch(tableName -> tmpTableNamePrefixes.stream().anyMatch(tableName::startsWith)));
final Set<String> finalTableNames = tableNames.stream().map(name -> name + "_raw").collect(Collectors.toSet());
// search for table names that have the tmp table prefix but are not raw tables.
assertTrue(fetchNamesOfTablesInDb()
.stream()
.filter(tableName -> !finalTableNames.contains(tableName))
.noneMatch(tableName -> tmpTableNamePrefixes.stream().anyMatch(tableName::startsWith)));
}

private List<JsonNode> retrieveRecords(String tableName) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BigQueryIntegrationTest extends TestDestination {
public class BigQueryStandardTest extends TestDestination {

private static final Logger LOGGER = LoggerFactory.getLogger(BigQueryIntegrationTest.class);
private static final Logger LOGGER = LoggerFactory.getLogger(BigQueryStandardTest.class);

private static final Path CREDENTIALS_PATH = Path.of("secrets/credentials.json");

Expand Down

0 comments on commit 4d7a5e2

Please sign in to comment.