-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
🎉 Destination Oracle - Added support for connection via ssh tunnel #6370
Merged
VitaliiMaltsev
merged 9 commits into
master
from
vmaltsev/5969-oracle-destination-ssh-tunnel
Sep 28, 2021
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1a6ea4d
Oracle destination with ssh tunneling
3783c88
add ssh key integration testing for Oracle destination
75f0aa7
fix checkstyle
98a3f26
Merge branch 'master' into vmaltsev/5969-oracle-destination-ssh-tunnel
0a61b3c
add container approach to Oracle Destination Integration Tests
9870d24
add container approach to Oracle Destination Integration Tests
6314486
add container approach to Oracle Source Integration Tests/ delete sec…
36deae3
Oracle Destination - bump version to 0.1.8
36bd14a
remove oracle ssh secrets from ci_credentials.sh
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ava/io/airbyte/integrations/destination/oracle/SshKeyOracleDestinationAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class SshKeyOracleDestinationAcceptanceTest extends SshOracleDestinationAcceptanceTest { | ||
|
||
@Override | ||
public Path getConfigFilePath() { | ||
return Path.of("secrets/ssh-key-config.json"); | ||
} | ||
|
||
} |
149 changes: 149 additions & 0 deletions
149
...n/java/io/airbyte/integrations/destination/oracle/SshOracleDestinationAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import io.airbyte.commons.functional.CheckedFunction; | ||
import io.airbyte.commons.io.IOs; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.db.Database; | ||
import io.airbyte.db.Databases; | ||
import io.airbyte.integrations.base.JavaBaseConstants; | ||
import io.airbyte.integrations.base.ssh.SshTunnel; | ||
import io.airbyte.integrations.destination.ExtendedNameTransformer; | ||
import io.airbyte.integrations.standardtest.destination.DestinationAcceptanceTest; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.jooq.JSONFormat; | ||
|
||
public abstract class SshOracleDestinationAcceptanceTest extends DestinationAcceptanceTest { | ||
|
||
private static final JSONFormat JSON_FORMAT = new JSONFormat().recordFormat(JSONFormat.RecordFormat.OBJECT); | ||
|
||
private final ExtendedNameTransformer namingResolver = new OracleNameTransformer(); | ||
|
||
private final String schemaName = "TEST_" + RandomStringUtils.randomAlphabetic(6).toUpperCase(); | ||
|
||
public abstract Path getConfigFilePath(); | ||
|
||
@Override | ||
protected String getImageName() { | ||
return "airbyte/destination-oracle:dev"; | ||
} | ||
|
||
@Override | ||
protected JsonNode getConfig() { | ||
final JsonNode config = getConfigFromSecretsFile(); | ||
((ObjectNode) config).put("schema", schemaName); | ||
return config; | ||
} | ||
|
||
private JsonNode getConfigFromSecretsFile() { | ||
return Jsons.deserialize(IOs.readFile(getConfigFilePath())); | ||
} | ||
|
||
@Override | ||
protected JsonNode getFailCheckConfig() throws Exception { | ||
final JsonNode clone = Jsons.clone(getConfig()); | ||
((ObjectNode) clone).put("password", "wrong password"); | ||
return clone; | ||
} | ||
|
||
@Override | ||
protected List<JsonNode> retrieveRecords(TestDestinationEnv testEnv, String streamName, String namespace, JsonNode streamSchema) throws Exception { | ||
List<JsonNode> jsonNodes = retrieveRecordsFromTable(namingResolver.getRawTableName(streamName), namespace); | ||
return jsonNodes | ||
.stream() | ||
.map(r -> Jsons.deserialize(r.get(JavaBaseConstants.COLUMN_NAME_DATA.toUpperCase()).asText())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private List<JsonNode> retrieveRecordsFromTable(final String tableName, final String schemaName) throws Exception { | ||
final JsonNode config = getConfig(); | ||
return SshTunnel.sshWrap( | ||
config, | ||
OracleDestination.HOST_KEY, | ||
OracleDestination.PORT_KEY, | ||
(CheckedFunction<JsonNode, List<JsonNode>, Exception>) mangledConfig -> getDatabaseFromConfig(mangledConfig) | ||
.query( | ||
ctx -> ctx | ||
.fetch(String.format("SELECT * FROM %s.%s ORDER BY %s ASC", schemaName, tableName, OracleDestination.COLUMN_NAME_EMITTED_AT))) | ||
.stream() | ||
.map(r -> r.formatJSON(JSON_FORMAT)) | ||
.map(Jsons::deserialize) | ||
.collect(Collectors.toList())); | ||
} | ||
|
||
@Override | ||
protected void setup(TestDestinationEnv testEnv) throws Exception { | ||
SshTunnel.sshWrap( | ||
getConfig(), | ||
OracleDestination.HOST_KEY, | ||
OracleDestination.PORT_KEY, | ||
mangledConfig -> { | ||
Database databaseFromConfig = getDatabaseFromConfig(mangledConfig); | ||
databaseFromConfig.query(ctx -> ctx.fetch(String.format("CREATE USER %s IDENTIFIED BY %s", schemaName, schemaName))); | ||
databaseFromConfig.query(ctx -> ctx.fetch(String.format("GRANT CREATE TABLE TO %s", schemaName))); | ||
databaseFromConfig.query(ctx -> ctx.fetch(String.format("ALTER USER %s quota unlimited on USERS", schemaName))); | ||
}); | ||
} | ||
|
||
private Database getDatabaseFromConfig(final JsonNode config) { | ||
return Databases.createDatabase( | ||
config.get("username").asText(), | ||
config.get("password").asText(), | ||
String.format("jdbc:oracle:thin:@//%s:%s/%s", | ||
config.get("host").asText(), | ||
config.get("port").asText(), | ||
config.get("sid").asText()), | ||
"oracle.jdbc.driver.OracleDriver", | ||
null); | ||
} | ||
|
||
@Override | ||
protected void tearDown(TestDestinationEnv testEnv) throws Exception { | ||
SshTunnel.sshWrap( | ||
getConfig(), | ||
OracleDestination.HOST_KEY, | ||
OracleDestination.PORT_KEY, | ||
mangledConfig -> { | ||
getDatabaseFromConfig(mangledConfig).query(ctx -> ctx.fetch(String.format("DROP USER %s CASCADE", schemaName))); | ||
}); | ||
} | ||
|
||
@Override | ||
protected boolean supportsDBT() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean implementsNamespaces() { | ||
return true; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...o/airbyte/integrations/destination/oracle/SshPasswordOracleDestinationAcceptanceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle; | ||
|
||
import java.nio.file.Path; | ||
|
||
public class SshPasswordOracleDestinationAcceptanceTest extends SshOracleDestinationAcceptanceTest { | ||
|
||
@Override | ||
public Path getConfigFilePath() { | ||
return Path.of("secrets/ssh-pwd-config.json"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we instead use the approach you took in #5811 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, i'll modify on container approach once #6312 will be merged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada I changed the integration tests for the bastion container approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sherifnada also how do you think maybe we need to create separate tasks to also change the integration tests for Oracle Source, MySQL Source and Destination, MSSQL Source and Destination with docker bastion container?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VitaliiMaltsev yup let's create issues on the backlog to do this, and make sure with the team that any new SSH implementations follow the bastion approach
cc @alexandr-shegeda