-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added e2e tests with snapshot and cdc
- Loading branch information
Showing
15 changed files
with
1,008 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright © 2023 Cask Data, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
|
||
Feature: Oracle - Verify Oracle source data transfer | ||
|
||
# Scenario: Sanity test from Oracle to Big Query | ||
# Given Open DataFusion Project with replication to configure pipeline | ||
# When Enter input plugin property: "name" with value: "pipelineName" | ||
# And Click on the Next button | ||
# And Select Oracle as Source | ||
# Then Replace input plugin property: "host" with value: "host" for Credentials and Authorization related fields | ||
# Then Replace input plugin property: "port" with value: "port" for Credentials and Authorization related fields | ||
# Then Click plugin property: "region" | ||
# Then Click plugin property: "regionOption" | ||
# Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields | ||
# Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields | ||
# Then Replace input plugin property: "sid" with value: "database" for Credentials and Authorization related fields | ||
# Then Click on the Next button | ||
# Then Replace input plugin property: "loadInterval" with value: "loadInterval" | ||
# Then Click on the Next button | ||
# Then Validate Table is available and can be selected "ABC.E2E-sanity" | ||
# And Click on the Next button | ||
# And Click on the Next button | ||
# And Click on the Next button | ||
# Then Deploy the replication pipeline | ||
# And Run the replication Pipeline | ||
# Then Open the logs | ||
# And Wait till pipeline is in running state and check if no errors occurred | ||
# Then Verify expected Oracle records in target BigQuery table | ||
# And Capture raw logs | ||
# Then Close the pipeline logs and stop the pipeline | ||
|
||
@ORACLE_SOURCE | ||
Scenario: To verify snapshot and cdc from Oracle to Big Query successfully | ||
Given Open DataFusion Project with replication to configure pipeline | ||
When Enter input plugin property: "name" with value: "pipelineName" | ||
And Click on the Next button | ||
And Select Oracle as Source | ||
Then Replace input plugin property: "host" with value: "host" for Credentials and Authorization related fields | ||
Then Replace input plugin property: "port" with value: "port" for Credentials and Authorization related fields | ||
Then Click plugin property: "region" | ||
Then Click plugin property: "regionOption" | ||
Then Replace input plugin property: "user" with value: "username" for Credentials and Authorization related fields | ||
Then Replace input plugin property: "password" with value: "password" for Credentials and Authorization related fields | ||
Then Replace input plugin property: "sid" with value: "database" for Credentials and Authorization related fields | ||
Then Click on the Next button | ||
Then Replace input plugin property: "loadInterval" with value: "loadInterval" | ||
Then Click on the Next button | ||
Then Validate Table is available and can be selected "ABC.E2E1" | ||
And Click on the Next button | ||
And Click on the Next button | ||
And Click on the Next button | ||
Then Deploy the replication pipeline | ||
And Run the replication Pipeline | ||
Then Open the logs | ||
And Wait till pipeline is in running state and check if no errors occurred | ||
Then Verify expected Oracle records in target BigQuery table | ||
And Insert a record in the source table and wait for replication | ||
Then Verify expected Oracle records in target BigQuery table | ||
And Delete a record in the source table and wait for replication | ||
Then Verify expected Oracle records in target BigQuery table | ||
And Update a record in the source table and wait for replication | ||
Then Verify expected Oracle records in target BigQuery table | ||
And Capture raw logs | ||
Then Close the pipeline logs and stop the pipeline |
154 changes: 154 additions & 0 deletions
154
src/e2e-test/java/io.cdap.plugin/actions/ReplicationActions.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,154 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.cdap.plugin.actions; | ||
|
||
import io.cdap.e2e.pages.actions.CdfPipelineRunAction; | ||
import io.cdap.e2e.pages.locators.CdfPipelineRunLocators; | ||
import io.cdap.e2e.utils.*; | ||
import io.cdap.plugin.locators.ReplicationLocators; | ||
import io.cdap.plugin.utils.OracleClient; | ||
import io.cdap.plugin.utils.ValidationHelper; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.junit.Assert; | ||
import stepsdesign.BeforeActions; | ||
|
||
import java.io.IOException; | ||
import java.sql.SQLException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public class ReplicationActions { | ||
private static String parentWindow = StringUtils.EMPTY; | ||
private static final String projectId = PluginPropertyUtils.pluginProp("projectId"); | ||
private static final String database = PluginPropertyUtils.pluginProp("database"); | ||
public static String tableName = PluginPropertyUtils.pluginProp("sourceTable"); | ||
public static String schemaName = PluginPropertyUtils.pluginProp("schema"); | ||
public static String datatypeColumnNames = PluginPropertyUtils.pluginProp("datatypeColumnNames"); | ||
public static String datatypeValues = PluginPropertyUtils.pluginProp("datatypeValuesForInsertOperation"); | ||
public static String deleteCondition = PluginPropertyUtils.pluginProp("deleteRowCondition"); | ||
public static String updateCondition = PluginPropertyUtils.pluginProp("updateRowCondition"); | ||
public static String updatedValue = PluginPropertyUtils.pluginProp("updatedRow"); | ||
|
||
static { | ||
SeleniumHelper.getPropertiesLocators(ReplicationLocators.class); | ||
} | ||
public static void clickNextButton() throws InterruptedException { | ||
TimeUnit time = TimeUnit.SECONDS; | ||
time.sleep(1); | ||
ElementHelper.clickOnElement(ReplicationLocators.next); | ||
} | ||
public static void clickOnOraclePlugin() { | ||
ElementHelper.clickOnElement(ReplicationLocators.oraclePlugin); | ||
} | ||
|
||
public static void selectTable(String tableName) { | ||
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.selectTable(tableName)); | ||
AssertionHelper.verifyElementDisplayed(ReplicationLocators.selectTable(tableName)); | ||
ElementHelper.clickOnElement(ReplicationLocators.selectTable(tableName)); | ||
} | ||
|
||
public static void deployPipeline() { | ||
ElementHelper.clickOnElement(ReplicationLocators.deployPipeline); | ||
} | ||
|
||
public static void startPipeline() { | ||
ElementHelper.clickIfDisplayed(ReplicationLocators.start, ConstantsUtil.DEFAULT_TIMEOUT_SECONDS); | ||
} | ||
|
||
public static void runThePipeline() { | ||
startPipeline(); | ||
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.running); | ||
} | ||
|
||
public static void openAdvanceLogs() { | ||
ReplicationLocators.logs.click(); | ||
parentWindow = SeleniumDriver.getDriver().getWindowHandle(); | ||
ArrayList<String> tabs = new ArrayList(SeleniumDriver.getDriver().getWindowHandles()); | ||
SeleniumDriver.getDriver().switchTo().window(tabs.get(tabs.indexOf(parentWindow) + 1)); | ||
ReplicationLocators.advancedLogs.click(); | ||
} | ||
|
||
public static void captureRawLog() { | ||
//Capturing raw logs. | ||
try { | ||
String rawLogs = getRawLogs(); | ||
String logsSeparatorMessage = ConstantsUtil.LOGS_SEPARATOR_MESSAGE | ||
.replace("MESSAGE", "DEPLOYED PIPELINE RUNTIME LOGS"); | ||
BeforeActions.scenario.write(rawLogs); | ||
CdfPipelineRunAction.writeRawLogsToFile(BeforeActions.file, logsSeparatorMessage, rawLogs); | ||
} catch (Exception e) { | ||
BeforeActions.scenario.write("Exception in capturing logs : " + e); | ||
} | ||
} | ||
|
||
public static String getRawLogs() { | ||
CdfPipelineRunAction.viewRawLogs(); | ||
ArrayList<String> tabs = new ArrayList(SeleniumDriver.getDriver().getWindowHandles()); | ||
PageHelper.switchToWindow(tabs.indexOf(parentWindow) + 2); | ||
String logs = CdfPipelineRunLocators.logsTextbox.getText(); | ||
Assert.assertNotNull(logs); | ||
PageHelper.closeCurrentWindow(); | ||
return logs; | ||
} | ||
|
||
public static void waitTillPipelineIsRunningAndCheckForErrors() throws InterruptedException { | ||
//wait for datastream to startup | ||
int defaultTimeout = Integer.parseInt(PluginPropertyUtils.pluginProp("datastream.timeout")); | ||
TimeUnit time = TimeUnit.SECONDS; | ||
time.sleep(defaultTimeout); | ||
// Checking if an error message is displayed. | ||
Assert.assertFalse(ElementHelper.isElementDisplayed(ReplicationLocators.error)); | ||
} | ||
|
||
public static void closeTheLogsAndClickOnStopButton() { | ||
//As the logs get opened in a new window in this plugin so after closing them we have to switch to parent window. | ||
SeleniumDriver.getDriver().switchTo().window(parentWindow); | ||
//Stopping the pipeline | ||
ElementHelper.clickOnElement(ReplicationLocators.stop); | ||
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.stopped); | ||
} | ||
public static void verifyTargetBigQueryRecordMatchesExpectedOracleRecord() | ||
throws IOException, InterruptedException, SQLException, ClassNotFoundException { | ||
// Checking if an error message is displayed. | ||
Assert.assertFalse(ElementHelper.isElementDisplayed(ReplicationLocators.error)); | ||
|
||
List<Map<String, Object>> sourceOracleRecords = OracleClient.getOracleRecordsAsMap(tableName, schemaName); | ||
List<Map<String, Object>> targetBigQueryRecords = ValidationHelper.getBigQueryRecordsAsMap(projectId, database, tableName); //+ "_v1`" | ||
ValidationHelper.validateRecords(sourceOracleRecords, targetBigQueryRecords); | ||
} | ||
|
||
public static void insertRecordAndWait() | ||
throws IOException, InterruptedException, SQLException, ClassNotFoundException { //JCoException, | ||
OracleClient.insertRow(tableName,schemaName, datatypeColumnNames,datatypeValues); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
|
||
public static void deleteRecordAndWait() throws SQLException, ClassNotFoundException, IOException, InterruptedException { | ||
OracleClient.deleteRow(tableName,schemaName, deleteCondition); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
|
||
public static void updateRecordAndWait() throws SQLException, ClassNotFoundException, IOException, InterruptedException { | ||
OracleClient.updateRow(tableName,schemaName, updateCondition, updatedValue ); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/e2e-test/java/io.cdap.plugin/actions/package-info.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,17 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.cdap.plugin.actions; |
Oops, something went wrong.