Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10719] Destination Oracle: custom JDBC parameters #13841

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
daac436
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jun 15, 2022
92581fa
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jun 16, 2022
026d5c2
Merge branch 'master' into osheg/10719-destination-oracle-jdbc-url-pa…
alexandr-shegeda Jun 24, 2022
9ff19cb
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jun 24, 2022
1e551a0
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jun 24, 2022
a998887
Merge branch 'master' into osheg/10719-destination-oracle-jdbc-url-pa…
alexandr-shegeda Jun 25, 2022
aaf989d
Merge branch 'master' into osheg/10719-destination-oracle-jdbc-url-pa…
alexandr-shegeda Jun 27, 2022
4bd070a
Merge remote-tracking branch 'origin/master' into osheg/10719-destina…
alexandr-shegeda Jun 29, 2022
626363a
Merge branch 'master' into osheg/10719-destination-oracle-jdbc-url-pa…
alexandr-shegeda Jun 29, 2022
ed8b4c7
Merge branch 'master' into osheg/10719-destination-oracle-jdbc-url-pa…
alexandr-shegeda Jul 4, 2022
dc7fc33
Merge remote-tracking branch 'origin/master' into osheg/10719-destina…
alexandr-shegeda Jul 20, 2022
7d267c6
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jul 20, 2022
61552c4
Merge remote-tracking branch 'origin/master' into osheg/10719-destina…
alexandr-shegeda Jul 26, 2022
fdb2902
[10719] Destination Oracle: custom JDBC parameters
alexandr-shegeda Jul 26, 2022
b78c2a3
auto-bump connector version [ci skip]
octavia-squidington-iii Jul 27, 2022
0563aab
Merge remote-tracking branch 'origin/master' into osheg/10719-destina…
alexandr-shegeda Jul 27, 2022
7faa356
Merge remote-tracking branch 'origin/osheg/10719-destination-oracle-j…
alexandr-shegeda Jul 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
- name: Oracle
destinationDefinitionId: 3986776d-2319-4de9-8af8-db14c0996e72
dockerRepository: airbyte/destination-oracle
dockerImageTag: 0.1.18
dockerImageTag: 0.1.19
documentationUrl: https://docs.airbyte.io/integrations/destinations/oracle
icon: oracle.svg
releaseStage: alpha
Expand Down
14 changes: 11 additions & 3 deletions airbyte-config/init/src/main/resources/seed/destination_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3070,7 +3070,7 @@
supported_destination_sync_modes:
- "overwrite"
- "append"
- dockerImage: "airbyte/destination-oracle:0.1.18"
- dockerImage: "airbyte/destination-oracle:0.1.19"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/destinations/oracle"
connectionSpecification:
Expand All @@ -3082,6 +3082,7 @@
- "port"
- "username"
- "sid"
additionalProperties: true
properties:
host:
title: "Host"
Expand Down Expand Up @@ -3116,6 +3117,13 @@
type: "string"
airbyte_secret: true
order: 4
jdbc_url_params:
description: "Additional properties to pass to the JDBC URL string when\
\ connecting to the database formatted as 'key=value' pairs separated\
\ by the symbol '&'. (example: key1=value1&key2=value2&key3=value3)."
title: "JDBC URL Params"
type: "string"
order: 5
schema:
title: "Default Schema"
description: "The default schema is used as the target schema for all statements\
Expand All @@ -3127,13 +3135,13 @@
examples:
- "airbyte"
default: "airbyte"
order: 5
order: 6
encryption:
title: "Encryption"
type: "object"
description: "The encryption method which is used when communicating with\
\ the database."
order: 6
order: 7
oneOf:
- title: "Unencrypted"
description: "Data transfer will not be encrypted."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION destination-oracle-strict-encrypt

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.1.18
LABEL io.airbyte.version=0.1.19
LABEL io.airbyte.name=airbyte/destination-oracle-strict-encrypt
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@
"airbyte_secret": true,
"order": 4
},
"jdbc_url_params": {
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (example: key1=value1&key2=value2&key3=value3).",
"title": "JDBC URL Params",
"type": "string",
"order": 5
},
"schema": {
"title": "Default Schema",
"description": "The default schema is used as the target schema for all statements issued from the connection that do not explicitly specify a schema name. The usual value for this field is \"airbyte\". In Oracle, schemas and users are the same thing, so the \"user\" parameter is used as the login credentials and this is used for the default Airbyte message schema.",
"type": "string",
"examples": ["airbyte"],
"default": "airbyte",
"order": 5
"order": 6
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION destination-oracle

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.1.18
LABEL io.airbyte.version=0.1.19
LABEL io.airbyte.name=airbyte/destination-oracle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public class OracleDestination extends AbstractJdbcDestination implements Destin
private static final String KEY_STORE_PASS = RandomStringUtils.randomAlphanumeric(8);
public static final String ENCRYPTION_METHOD_KEY = "encryption_method";

public static final String JDBC_URL_PARAMS_KEY = "jdbc_url_params";

enum Protocol {
TCP,
TCPS
Expand Down Expand Up @@ -99,6 +101,9 @@ public JsonNode toJdbcConfig(final JsonNode config) {
if (config.has(JdbcUtils.PASSWORD_KEY)) {
configBuilder.put(JdbcUtils.PASSWORD_KEY, config.get(JdbcUtils.PASSWORD_KEY).asText());
}
if (config.has(JDBC_URL_PARAMS_KEY)) {
configBuilder.put(JDBC_URL_PARAMS_KEY, config.get(JDBC_URL_PARAMS_KEY));
}

return Jsons.jsonNode(configBuilder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,25 @@
"airbyte_secret": true,
"order": 4
},
"jdbc_url_params": {
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (example: key1=value1&key2=value2&key3=value3).",
"title": "JDBC URL Params",
"type": "string",
"order": 5
},
"schema": {
"title": "Default Schema",
"description": "The default schema is used as the target schema for all statements issued from the connection that do not explicitly specify a schema name. The usual value for this field is \"airbyte\". In Oracle, schemas and users are the same thing, so the \"user\" parameter is used as the login credentials and this is used for the default Airbyte message schema.",
"type": "string",
"examples": ["airbyte"],
"default": "airbyte",
"order": 5
"order": 6
},
"encryption": {
"title": "Encryption",
"type": "object",
"description": "The encryption method which is used when communicating with the database.",
"order": 6,
"order": 7,
"oneOf": [
{
"title": "Unencrypted",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package io.airbyte.integrations.destination.oracle;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -18,7 +20,7 @@
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this change doing and why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our main test suite is running on the Junit5 version, but the Test annotation was added from the Junit4 version, that's why it was not triggered by /test in the past, this update fixes the described issue


public class NneOracleDestinationAcceptanceTest extends UnencryptedOracleDestinationAcceptanceTest {

Expand Down Expand Up @@ -48,7 +50,7 @@ public void testEncryption() throws SQLException {
final List<JsonNode> collect = database.queryJsons(networkServiceBanner);

assertThat(collect.get(2).get("NETWORK_SERVICE_BANNER").asText(),
equals("Oracle Advanced Security: " + algorithm + " encryption"));
is(equalTo("AES256 Encryption service adapter for Linux: Version 18.0.0.0.0 - Production")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this PR change equals assertion to is(equalsTo()) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

equals was used not from the library for assertion, but from Object class, it means it did nothing previously

}

private Map<String, String> getAdditionalProperties(final String algorithm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

package io.airbyte.integrations.destination.oracle;

import static org.junit.jupiter.api.Assertions.assertTrue;
import static io.airbyte.integrations.util.HostPortResolver.resolveHost;
import static io.airbyte.integrations.util.HostPortResolver.resolvePort;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -22,11 +26,12 @@
import io.airbyte.integrations.standardtest.destination.DestinationAcceptanceTest;
import io.airbyte.integrations.standardtest.destination.comparator.TestDataComparator;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.jooq.DSLContext;
import org.junit.Test;
import org.junit.jupiter.api.Test;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above - not sure about the reason for changing the unit test library


public class UnencryptedOracleDestinationAcceptanceTest extends DestinationAcceptanceTest {

Expand All @@ -43,8 +48,8 @@ protected String getImageName() {
private JsonNode getConfig(final OracleContainer db) {

return Jsons.jsonNode(ImmutableMap.builder()
.put(JdbcUtils.HOST_KEY, db.getHost())
.put(JdbcUtils.PORT_KEY, db.getFirstMappedPort())
.put(JdbcUtils.HOST_KEY, resolveHost(db))
.put(JdbcUtils.PORT_KEY, resolvePort(db))
.put("sid", db.getSid())
.put(JdbcUtils.USERNAME_KEY, db.getUsername())
.put(JdbcUtils.PASSWORD_KEY, db.getPassword())
Expand All @@ -62,9 +67,9 @@ protected JsonNode getConfig() {

@Override
protected List<JsonNode> retrieveRecords(final TestDestinationEnv env,
final String streamName,
final String namespace,
final JsonNode streamSchema)
final String streamName,
final String namespace,
final JsonNode streamSchema)
throws Exception {
return retrieveRecordsFromTable(namingResolver.getRawTableName(streamName), namespace)
.stream()
Expand Down Expand Up @@ -105,8 +110,8 @@ protected boolean supportObjectDataTypeTest() {

@Override
protected List<JsonNode> retrieveNormalizedRecords(final TestDestinationEnv env,
final String streamName,
final String namespace)
final String streamName,
final String namespace)
throws Exception {
final String tableName = namingResolver.getIdentifier(streamName);
return retrieveRecordsFromTable(tableName, namespace);
Expand All @@ -123,11 +128,9 @@ private List<JsonNode> retrieveRecordsFromTable(final String tableName, final St
throws SQLException {
try (final DSLContext dslContext = getDSLContext(config)) {
final List<org.jooq.Record> result = getDatabase(dslContext)
.query(ctx -> ctx.fetch(
.query(ctx -> new ArrayList<>(ctx.fetch(
String.format("SELECT * FROM %s.%s ORDER BY %s ASC", schemaName, tableName,
OracleDestination.COLUMN_NAME_EMITTED_AT))
.stream()
.collect(Collectors.toList()));
OracleDestination.COLUMN_NAME_EMITTED_AT))));
return result
.stream()
.map(r -> r.formatJSON(JdbcUtils.getDefaultJSONFormat()))
Expand Down Expand Up @@ -194,8 +197,8 @@ public void testNoneEncryption() throws SQLException {
"select network_service_banner from v$session_connect_info where sid in (select distinct sid from v$mystat)";
final List<JsonNode> collect = database.queryJsons(networkServiceBanner);

assertTrue(collect.get(1).get("NETWORK_SERVICE_BANNER").asText()
.contains("Oracle Advanced Security: encryption"));
assertThat(collect.get(1).get("NETWORK_SERVICE_BANNER").asText(),
is(equalTo("Encryption service for Linux: Version 18.0.0.0.0 - Production")));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,35 @@ void testInvalidEncryptionMethod() {
assertThrows(RuntimeException.class, () -> destination.obtainConnectionProtocol(inputConfig));
}

@Test
void testEmptyExtraParams() {
final String extraParam = "";
JsonNode config = buildConfigWithExtraJdbcParameters(extraParam);
final JsonNode jdbcConfig = new OracleDestination().toJdbcConfig(config);
assertNotNull(jdbcConfig.get(OracleDestination.JDBC_URL_PARAMS_KEY).asText());
assertEquals(extraParam, jdbcConfig.get(OracleDestination.JDBC_URL_PARAMS_KEY).asText());
}

@Test
void testExtraParams() {
final String extraParam = "key1=value1&key2=value2&key3=value3";
JsonNode config = buildConfigWithExtraJdbcParameters(extraParam);
final JsonNode jdbcConfig = new OracleDestination().toJdbcConfig(config);
assertNotNull(jdbcConfig.get(OracleDestination.JDBC_URL_PARAMS_KEY).asText());
assertEquals(extraParam, jdbcConfig.get(OracleDestination.JDBC_URL_PARAMS_KEY).asText());

}

private JsonNode buildConfigWithExtraJdbcParameters(String extraParam) {

return Jsons.jsonNode(com.google.common.collect.ImmutableMap.of(
"host", "localhost",
"port", 1773,
"sid", "ORCL",
"database", "db",
"username", "username",
"password", "verysecure",
"jdbc_url_params", extraParam));
}

}
2 changes: 1 addition & 1 deletion deps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ connectors-testcontainers-pulsar = "1.16.2"
connectors-testcontainers-scylla = "1.16.2"
connectors-testcontainers-tidb = "1.16.3"
connectors-destination-testcontainers-clickhouse = "1.17.3"
connectors-destination-testcontainers-oracle-xe = "1.16.0"
connectors-destination-testcontainers-oracle-xe = "1.17.3"
connectors-source-testcontainers-clickhouse = "1.17.3"
platform-testcontainers = "1.17.1"

Expand Down
2 changes: 2 additions & 0 deletions docs/integrations/destinations/oracle.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ Airbite has the ability to connect to the Oracle source with 3 network connectiv

| Version | Date | Pull Request | Subject |
|:------------| :--- |:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------|
| 0.1.19 | 2022-07-26 | [\#10719](https://github.com/airbytehq/airbyte/pull/) | Destination Oracle: added custom JDBC parameters support. |
| 0.1.18 | 2022-07-14 | [\#14618](https://github.com/airbytehq/airbyte/pull/14618) | Removed additionalProperties: false from JDBC destination connectors |
| unpublished | 2022-05-17 | [12820](https://github.com/airbytehq/airbyte/pull/12820) | Improved 'check' operation performance |
| 0.1.16 | 2022-04-06 | [11514](https://github.com/airbytehq/airbyte/pull/11514) | Bump mina-sshd from 2.7.0 to 2.8.0 |
Expand All @@ -113,6 +114,7 @@ Airbite has the ability to connect to the Oracle source with 3 network connectiv

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:--------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------|
| 0.1.19 | 2022-07-26 | [\#10719](https://github.com/airbytehq/airbyte/pull/) | Destination Oracle: added custom JDBC parameters support. |
| 0.1.7 | 2022-07-14 | [\#14618](https://github.com/airbytehq/airbyte/pull/14618) | Removed additionalProperties: false from JDBC destination connectors |
| 0.1.5 | 2022-05-17 | [12820](https://github.com/airbytehq/airbyte/pull/12820) | Improved 'check' operation performance |
| 0.1.4 | 2022-02-25 | [10421](https://github.com/airbytehq/airbyte/pull/10421) | Refactor JDBC parameters handling and remove DBT support |
Expand Down