Skip to content

Commit

Permalink
Fix redshift and oracle acceptance tests (#10855)
Browse files Browse the repository at this point in the history
* parse jdbc parameters

* Also fix redshift

* other oracle source acceptance test

* This is & now

* This is & now

* This is & now

* This is & now

* This is & now

* also update nne

* increase sleep to 11 seconds

* Bump to 15 seconds

* gradlew format

* try to reformat

* gradlew format

* Run ./gradlew :airbyte-integrations:connector-templates:generator:testScaffoldTemplates --scan

* reset to master

* Revert "reset to master"

This reverts commit d6141ed.
  • Loading branch information
girarda committed Mar 5, 2022
1 parent f77fa8b commit adea13c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,8 @@ void testInterruptOrphanThreadFailure() {
3, TimeUnit.SECONDS,
10, TimeUnit.SECONDS));
try {
TimeUnit.SECONDS.sleep(10);
} catch (Exception e) {
TimeUnit.SECONDS.sleep(15);
} catch (final Exception e) {
throw new RuntimeException(e);
}
final List<Thread> runningThreads = ThreadUtils.getAllThreads().stream()
Expand All @@ -337,8 +337,8 @@ void testNoInterruptOrphanThreadFailure() {
3, TimeUnit.SECONDS,
10, TimeUnit.SECONDS));
try {
TimeUnit.SECONDS.sleep(10);
} catch (Exception e) {
TimeUnit.SECONDS.sleep(15);
} catch (final Exception e) {
throw new RuntimeException(e);
}
final List<Thread> runningThreads = ThreadUtils.getAllThreads().stream()
Expand All @@ -356,7 +356,7 @@ private void startSleepingThread(final List<Exception> caughtExceptions, final b
for (int tries = 0; tries < 3; tries++) {
try {
TimeUnit.MINUTES.sleep(5);
} catch (Exception e) {
} catch (final Exception e) {
LOGGER.info("Caught Exception", e);
caughtExceptions.add(e);
if (!ignoreInterrupt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
#


from typing import Any, Iterable, Mapping
from typing import Mapping, Any, Iterable

from airbyte_cdk import AirbyteLogger
from airbyte_cdk.destinations import Destination
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConfiguredAirbyteCatalog, Status
from airbyte_cdk.models import AirbyteConnectionStatus, ConfiguredAirbyteCatalog, AirbyteMessage, Status


class DestinationScaffoldDestinationPython(Destination):
def write(
self, config: Mapping[str, Any], configured_catalog: ConfiguredAirbyteCatalog, input_messages: Iterable[AirbyteMessage]
self,
config: Mapping[str, Any],
configured_catalog: ConfiguredAirbyteCatalog,
input_messages: Iterable[AirbyteMessage]
) -> Iterable[AirbyteMessage]:

"""
Expand Down Expand Up @@ -51,3 +54,6 @@ def check(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> AirbyteConn
return AirbyteConnectionStatus(status=Status.SUCCEEDED)
except Exception as e:
return AirbyteConnectionStatus(status=Status.FAILED, message=f"An exception occurred: {repr(e)}")



Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"airbyte-cdk",
]

TEST_REQUIREMENTS = ["pytest~=6.1"]
TEST_REQUIREMENTS = [
"pytest~=6.1"
]

setup(
name="destination_scaffold_destination_python",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.airbyte.commons.json.Jsons;
import io.airbyte.db.Databases;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcUtils;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -38,9 +39,9 @@ public void testEncrytion() throws SQLException {
clone.get("port").asText(),
clone.get("sid").asText()),
"oracle.jdbc.driver.OracleDriver",
"oracle.net.encryption_client=REQUIRED;" +
JdbcUtils.parseJdbcParameters("oracle.net.encryption_client=REQUIRED&" +
"oracle.net.encryption_types_client=( "
+ algorithm + " )");
+ algorithm + " )"));

final String network_service_banner =
"select network_service_banner from v$session_connect_info where sid in (select distinct sid from v$mystat)";
Expand Down Expand Up @@ -68,9 +69,9 @@ public void testCheckProtocol() throws SQLException {
clone.get("port").asText(),
clone.get("sid").asText()),
"oracle.jdbc.driver.OracleDriver",
"oracle.net.encryption_client=REQUIRED;" +
JdbcUtils.parseJdbcParameters("oracle.net.encryption_client=REQUIRED;" +
"oracle.net.encryption_types_client=( "
+ algorithm + " )");
+ algorithm + " )"));

final String network_service_banner = "SELECT sys_context('USERENV', 'NETWORK_PROTOCOL') as network_protocol FROM dual";
final List<JsonNode> collect = database.query(network_service_banner).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.airbyte.commons.resources.MoreResources;
import io.airbyte.db.Databases;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcUtils;
import io.airbyte.integrations.base.ssh.SshHelpers;
import io.airbyte.integrations.standardtest.source.SourceAcceptanceTest;
import io.airbyte.integrations.standardtest.source.TestDestinationEnv;
Expand Down Expand Up @@ -60,8 +61,8 @@ protected void setupEnvironment(final TestDestinationEnv environment) throws Exc
config.get("port").asText(),
config.get("sid").asText()),
"oracle.jdbc.driver.OracleDriver",
"oracle.net.encryption_client=REQUIRED;" +
"oracle.net.encryption_types_client=( 3DES168 )");
JdbcUtils.parseJdbcParameters("oracle.net.encryption_client=REQUIRED&" +
"oracle.net.encryption_types_client=( 3DES168 )"));

database.execute(connection -> {
connection.createStatement().execute("CREATE USER JDBC_SPACE IDENTIFIED BY JDBC_SPACE DEFAULT TABLESPACE USERS QUOTA UNLIMITED ON USERS");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.airbyte.commons.json.Jsons;
import io.airbyte.db.Databases;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcUtils;
import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
Expand All @@ -38,9 +39,9 @@ public void testEncrytion() throws SQLException {
clone.get("port").asText(),
clone.get("sid").asText()),
"oracle.jdbc.driver.OracleDriver",
"oracle.net.encryption_client=REQUIRED;" +
JdbcUtils.parseJdbcParameters("oracle.net.encryption_client=REQUIRED&" +
"oracle.net.encryption_types_client=( "
+ algorithm + " )");
+ algorithm + " )"));

final String network_service_banner =
"select network_service_banner from v$session_connect_info where sid in (select distinct sid from v$mystat)";
Expand Down Expand Up @@ -87,9 +88,9 @@ public void testCheckProtocol() throws SQLException {
clone.get("port").asText(),
clone.get("sid").asText()),
"oracle.jdbc.driver.OracleDriver",
"oracle.net.encryption_client=REQUIRED;" +
JdbcUtils.parseJdbcParameters("oracle.net.encryption_client=REQUIRED&" +
"oracle.net.encryption_types_client=( "
+ algorithm + " )");
+ algorithm + " )"));

final String network_service_banner = "SELECT sys_context('USERENV', 'NETWORK_PROTOCOL') as network_protocol FROM dual";
final List<JsonNode> collect = database.query(network_service_banner).collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public JsonNode toDatabaseConfig(final JsonNode redshiftConfig) {

addSsl(additionalProperties);

builder.put("connection_properties", String.join(";", additionalProperties));
builder.put("connection_properties", String.join("&", additionalProperties));

return Jsons.jsonNode(builder
.build());
Expand All @@ -74,15 +74,15 @@ private void addSsl(final List<String> additionalProperties) {
}

@Override
public List<TableInfo<CommonField<JDBCType>>> discoverInternal(JdbcDatabase database) throws Exception {
public List<TableInfo<CommonField<JDBCType>>> discoverInternal(final JdbcDatabase database) throws Exception {
if (schemas != null && !schemas.isEmpty()) {
// process explicitly selected (from UI) schemas
final List<TableInfo<CommonField<JDBCType>>> internals = new ArrayList<>();
for (String schema : schemas) {
for (final String schema : schemas) {
LOGGER.debug("Discovering schema: {}", schema);
internals.addAll(super.discoverInternal(database, schema));
}
for (TableInfo<CommonField<JDBCType>> info : internals) {
for (final TableInfo<CommonField<JDBCType>> info : internals) {
LOGGER.debug("Found table (schema: {}): {}", info.getNameSpace(), info.getName());
}
return internals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import io.airbyte.db.Databases;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcUtils;
import io.airbyte.integrations.source.redshift.RedshiftSource;

public class RedshiftSslSourceAcceptanceTest extends RedshiftSourceAcceptanceTest {
Expand All @@ -21,8 +22,8 @@ protected JdbcDatabase createDatabase(final JsonNode config) {
config.get("port").asText(),
config.get("database").asText()),
RedshiftSource.DRIVER_CLASS,
"ssl=true;" +
"sslfactory=com.amazon.redshift.ssl.NonValidatingFactory");
JdbcUtils.parseJdbcParameters("ssl=true&" +
"sslfactory=com.amazon.redshift.ssl.NonValidatingFactory"));
}

}

0 comments on commit adea13c

Please sign in to comment.