-
Notifications
You must be signed in to change notification settings - Fork 5
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
Added e2e tests with snapshot and cdc- Draft PR #103
base: develop
Are you sure you want to change the base?
Changes from 4 commits
fd593c4
c173246
6442266
700cf89
28bcdf6
db19820
8106d03
5294941
38df210
3fed35f
3755349
9891050
62167e0
8472625
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# 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 to Big Query | ||
@ORACLE_SOURCE @BIGQUERY_TARGET | ||
Scenario: To verify replication of snapshot and cdc data from Oracle to Big Query successfully with Sanity test | ||
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: "dataset" 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 Source table is available and select it | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we seperate out wait for replication part so that we can compose a scenario where multiple operations can be performed in one go and then we can wait once? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we then separate wait for every operation i.e., insert,update and delete or shall we combine operations ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can combine too as that achieves the same thing |
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/* | ||
* 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("dataset"); | ||
public static String tableName = PluginPropertyUtils.pluginProp("sourceTable"); | ||
public static String schemaName = PluginPropertyUtils.pluginProp("schema"); | ||
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); | ||
Comment on lines
+62
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It helps view what's happening in ui, otherwise it shifts across pages so quickly. |
||
ElementHelper.clickOnElement(ReplicationLocators.next); | ||
} | ||
|
||
public static void clickOnOraclePlugin() { | ||
ElementHelper.clickOnElement(ReplicationLocators.oraclePlugin); | ||
} | ||
|
||
public static void selectTable() { | ||
String table = schemaName + "." + tableName; | ||
WaitHelper.waitForElementToBeDisplayed(ReplicationLocators.selectTable(table)); | ||
AssertionHelper.verifyElementDisplayed(ReplicationLocators.selectTable(table)); | ||
ElementHelper.clickOnElement(ReplicationLocators.selectTable(table)); | ||
} | ||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the error ignored? |
||
} | ||
} | ||
|
||
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("pipeline-initialization")); | ||
TimeUnit time = TimeUnit.SECONDS; | ||
time.sleep(defaultTimeout); | ||
ValidationHelper.waitForFlush(); | ||
// 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); | ||
SeleniumDriver.getDriver().navigate().refresh(); | ||
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); | ||
ValidationHelper.validateRecords(sourceOracleRecords, targetBigQueryRecords); | ||
} | ||
|
||
public static void insertRecordAndWait() | ||
throws InterruptedException, SQLException, ClassNotFoundException { | ||
OracleClient.insertRow(tableName, schemaName, datatypeValues); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
|
||
public static void deleteRecordAndWait() throws SQLException, ClassNotFoundException, InterruptedException { | ||
OracleClient.deleteRow(tableName, schemaName, deleteCondition); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
|
||
public static void updateRecordAndWait() throws SQLException, ClassNotFoundException, InterruptedException { | ||
OracleClient.updateRow(tableName, schemaName, updateCondition, updatedValue ); | ||
OracleClient.forceFlushCDC(); | ||
ValidationHelper.waitForFlush(); | ||
} | ||
} |
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; |
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.
I think it would be better to rename the file to SanityTests.feature to reflect the intent