Skip to content

Commit

Permalink
Destination snowflake: disable broken tests (airbytehq#29402)
Browse files Browse the repository at this point in the history
* move test out of base class

* add setup instructions

* also grant privileges to the default role

* change owner

* username

* ffs

* am dummb
  • Loading branch information
edgao authored and harrytou committed Sep 1, 2023
1 parent f156acf commit cc66a76
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
11 changes: 11 additions & 0 deletions airbyte-integrations/connectors/destination-snowflake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,14 @@ DROP USER IF EXISTS INTEGRATION_TEST_USER_DESTINATION;
DROP ROLE IF EXISTS INTEGRATION_TESTER_DESTINATION;
DROP WAREHOUSE IF EXISTS INTEGRATION_TEST_WAREHOUSE_DESTINATION;
```

### Setup for various error-case users:
Log in as the `INTEGRATION_TEST_USER_DESTINATION` user, and run this:
```sql
drop schema if exists INTEGRATION_TEST_DESTINATION.TEXT_SCHEMA;
create schema INTEGRATION_TEST_DESTINATION.TEXT_SCHEMA;
grant ownership on schema INTEGRATION_TEST_DESTINATION.TEXT_SCHEMA to role INTEGRATION_TESTER_DESTINATION revoke current grants;
grant all privileges on schema INTEGRATION_TEST_DESTINATION.TEXT_SCHEMA to role NO_ACTIVE_WAREHOUSE_ROLE;
```

These tests are currently disabled (`testCheckWithNoProperStagingPermissionConnection`, `testCheckWithNoActiveWarehouseConnection`). Their test users keep breaking (i.e. becoming the schema owner) because our tests are tearing down `TEXT_SCHEMA` after every test.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private List<JsonNode> retrieveRecordsFromTable(final String tableName, final St

// for each test we create a new schema in the database. run the test in there and then remove it.
@Override
protected void setup(final TestDestinationEnv testEnv, HashSet<String> TEST_SCHEMAS) throws Exception {
protected void setup(final TestDestinationEnv testEnv, final HashSet<String> TEST_SCHEMAS) throws Exception {
final String schemaName = Strings.addRandomSuffix("integration_test", "_", 5);
final String createSchemaQuery = String.format("CREATE SCHEMA %s", schemaName);
TEST_SCHEMAS.add(schemaName);
Expand All @@ -187,30 +187,19 @@ protected void setup(final TestDestinationEnv testEnv, HashSet<String> TEST_SCHE
}

@Override
protected void tearDown(final TestDestinationEnv testEnv, HashSet<String> TEST_SCHEMAS) throws Exception {
protected void tearDown(final TestDestinationEnv testEnv, final HashSet<String> TEST_SCHEMAS) throws Exception {
String dropSchemaQuery = String.format("DROP SCHEMA IF EXISTS %s", config.get("schema").asText());
database.execute(dropSchemaQuery);

for (String schema : TEST_SCHEMAS) {
for (final String schema : TEST_SCHEMAS) {
dropSchemaQuery = String.format("DROP SCHEMA IF EXISTS %s", schema);
database.execute(dropSchemaQuery);
}

DataSourceFactory.close(dataSource);
}

@Test
public void testCheckWithNoActiveWarehouseConnection() throws Exception {
// Config to user(creds) that has no warehouse assigned
final JsonNode config = Jsons.deserialize(IOs.readFile(
Path.of("secrets/internal_staging_config_no_active_warehouse.json")));

final StandardCheckConnectionOutput standardCheckConnectionOutput = runCheck(config);

assertEquals(Status.FAILED, standardCheckConnectionOutput.getStatus());
assertThat(standardCheckConnectionOutput.getMessage()).contains(NO_ACTIVE_WAREHOUSE_ERR_MSG);
}

@Disabled("See README for why this test is disabled")
@Test
public void testCheckWithNoTextSchemaPermissionConnection() throws Exception {
// Config to user (creds) that has no permission to schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ArgumentsSource;
Expand All @@ -36,6 +37,7 @@ public JsonNode getStaticConfig() {
return internalStagingConfig;
}

@Disabled("See README for why this test is disabled")
@Test
public void testCheckWithNoProperStagingPermissionConnection() throws Exception {
// Config to user (creds) that has no permission to write
Expand All @@ -48,6 +50,19 @@ public void testCheckWithNoProperStagingPermissionConnection() throws Exception
assertThat(standardCheckConnectionOutput.getMessage()).contains(NO_USER_PRIVILEGES_ERR_MSG);
}

@Disabled("See README for why this test is disabled")
@Test
public void testCheckWithNoActiveWarehouseConnection() throws Exception {
// Config to user(creds) that has no warehouse assigned
final JsonNode config = Jsons.deserialize(IOs.readFile(
Path.of("secrets/internal_staging_config_no_active_warehouse.json")));

final StandardCheckConnectionOutput standardCheckConnectionOutput = runCheck(config);

assertEquals(Status.FAILED, standardCheckConnectionOutput.getStatus());
assertThat(standardCheckConnectionOutput.getMessage()).contains(NO_ACTIVE_WAREHOUSE_ERR_MSG);
}

@ParameterizedTest
@ArgumentsSource(DataArgumentsProvider.class)
public void testSyncWithNormalizationWithKeyPairAuth(final String messagesFilename, final String catalogFilename) throws Exception {
Expand Down

0 comments on commit cc66a76

Please sign in to comment.