Skip to content

Commit

Permalink
Source-oracle: fixed tests + checkstyle (#13997)
Browse files Browse the repository at this point in the history
* Source-oracle: fixed tests + checkstyle
  • Loading branch information
etsybaev committed Jun 22, 2022
1 parent e4d3d60 commit eedb740
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 26 deletions.
Expand Up @@ -76,7 +76,7 @@ public JsonNode toJdbcConfig(final JsonNode config) {
.put("schema", schema);

if (config.has(JDBC_URL_PARAMS_KEY)) {
//configBuilder.put("connection_properties", config.get(JDBC_URL_PARAMS_KEY));
// configBuilder.put("connection_properties", config.get(JDBC_URL_PARAMS_KEY));
configBuilder.put(JDBC_URL_PARAMS_KEY, config.get(JDBC_URL_PARAMS_KEY));
}

Expand Down
Expand Up @@ -191,24 +191,24 @@ void testExtraParams() {

private JsonNode buildConfigNoJdbcParameters() {
return Jsons.jsonNode(com.google.common.collect.ImmutableMap.of(
"ssl_method", "ssl_method",
"host", "localhost",
"port", "1773",
"database", "db",
"username", "username",
"password", "verysecure"));
"ssl_method", "ssl_method",
"host", "localhost",
"port", "1773",
"database", "db",
"username", "username",
"password", "verysecure"));
}

private JsonNode buildConfigWithExtraJdbcParameters(String extraParam) {

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

}
Expand Up @@ -33,7 +33,6 @@
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.joda.time.DateTime;

public class SnowflakeGcsStagingSqlOperations extends SnowflakeSqlOperations implements StagingOperations {
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-dockerhub/main.py
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#


Expand Down
@@ -1,6 +1,7 @@
#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

import logging
from typing import Any, Iterable, List, Mapping, Optional, Tuple
from urllib.parse import urlparse
Expand Down
@@ -1,5 +1,5 @@
#
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#

from unittest.mock import MagicMock
Expand All @@ -9,7 +9,9 @@

def test_check_connection():
source = SourceDockerhub()
logger_mock, config_mock = MagicMock(), {"docker_username": "airbyte"} # shouldnt actually ping network request in test but we will skip for now
logger_mock, config_mock = MagicMock(), {
"docker_username": "airbyte"
} # shouldnt actually ping network request in test but we will skip for now
assert source.check_connection(logger_mock, config_mock) == (True, None)


Expand Down
Expand Up @@ -88,7 +88,7 @@
}
}
},
"bid_strategy" : {
"bid_strategy": {
"type": ["null", "string"]
},
"bid_amount": {
Expand Down
@@ -1,10 +1,10 @@
{
"start_date": "2021-08-01",
"account_ids": [1,2],
"account_ids": [1, 2],
"credentials": {
"auth_method": "oAuth2.0",
"client_id": "client_id",
"client_secret": "client_secret",
"refresh_token": "refresh_token"
}
}
}
Expand Up @@ -77,7 +77,8 @@ static void init() {
ID_VALUE_5 = new BigDecimal(5);

ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g")
.withEnv("NLS_DATE_FORMAT", "YYYY-MM-DD");
.withEnv("NLS_DATE_FORMAT", "YYYY-MM-DD")
.withEnv("RELAX_SECURITY", "1");
ORACLE_DB.start();
}

Expand Down Expand Up @@ -115,6 +116,17 @@ public void tearDownOracle() throws Exception {
Thread.sleep(1000);
}

protected void incrementalDateCheck() throws Exception {
// https://stackoverflow.com/questions/47712930/resultset-meta-data-return-timestamp-instead-of-date-oracle-jdbc
// Oracle DATE is a java.sql.Timestamp (java.sql.Types.TIMESTAMP) as far as JDBC (and the SQL
// standard) is concerned as it has both a date and time component.
incrementalCursorCheck(
COL_UPDATED_AT,
"2005-10-18T00:00:00.000000Z",
"2006-10-19T00:00:00.000000Z",
Lists.newArrayList(getTestMessages().get(1), getTestMessages().get(2)));
}

void cleanUpTables() throws SQLException {
final Connection conn = DriverManager.getConnection(
ORACLE_DB.getJdbcUrl(),
Expand Down
Expand Up @@ -37,7 +37,8 @@ public class OracleSourceDatatypeTest extends AbstractSourceDatabaseTypeTest {

@Override
protected Database setupDatabase() throws Exception {
container = new OracleContainer("epiclabs/docker-oracle-xe-11g");
container = new OracleContainer("epiclabs/docker-oracle-xe-11g")
.withEnv("RELAX_SECURITY", "1");
container.start();

config = Jsons.jsonNode(ImmutableMap.builder()
Expand Down
Expand Up @@ -76,7 +76,8 @@ static void init() {
ID_VALUE_5 = new BigDecimal(5);

ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g")
.withEnv("NLS_DATE_FORMAT", "YYYY-MM-DD");
.withEnv("NLS_DATE_FORMAT", "YYYY-MM-DD")
.withEnv("RELAX_SECURITY", "1");
ORACLE_DB.start();
}

Expand All @@ -97,6 +98,17 @@ public void setup() throws Exception {
super.setup();
}

protected void incrementalDateCheck() throws Exception {
// https://stackoverflow.com/questions/47712930/resultset-meta-data-return-timestamp-instead-of-date-oracle-jdbc
// Oracle DATE is a java.sql.Timestamp (java.sql.Types.TIMESTAMP) as far as JDBC (and the SQL
// standard) is concerned as it has both a date and time component.
incrementalCursorCheck(
COL_UPDATED_AT,
"2005-10-18T00:00:00.000000Z",
"2006-10-19T00:00:00.000000Z",
Lists.newArrayList(getTestMessages().get(1), getTestMessages().get(2)));
}

@AfterEach
public void tearDownOracle() throws Exception {
// ORA-12519
Expand Down
Expand Up @@ -58,7 +58,8 @@ class OracleSourceTest {

@BeforeAll
static void init() {
ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g");
ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g")
.withEnv("RELAX_SECURITY", "1");
ORACLE_DB.start();
}

Expand Down
Expand Up @@ -45,7 +45,8 @@ static void init() {
COL_ID_TYPE = "NUMBER(38,0)";
INSERT_STATEMENT = "INTO id_and_name (id, name) VALUES (%s,'picard-%s')";

ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g");
ORACLE_DB = new OracleContainer("epiclabs/docker-oracle-xe-11g")
.withEnv("RELAX_SECURITY", "1");
ORACLE_DB.start();
}

Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/oracle.md
Expand Up @@ -132,6 +132,7 @@ Airbite has the ability to connect to the Oracle source with 3 network connectiv

| Version | Date | Pull Request | Subject |
|:--------| :--- | :--- |:------------------------------------------------|
| 0.3.16 | 2022-06-22 | [13997](https://github.com/airbytehq/airbyte/pull/13997) | Fixed tests |
| 0.3.15 | 2022-04-29 | [12480](https://github.com/airbytehq/airbyte/pull/12480) | Query tables with adaptive fetch size to optimize JDBC memory consumption |
| 0.3.14 | 2022-02-21 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Fixed cursor for old connectors that use non-microsecond format. Now connectors work with both formats |
| 0.3.13 | 2022-02-18 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Updated timestamp transformation with microseconds |
Expand Down

0 comments on commit eedb740

Please sign in to comment.