-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5886a9f
commit 43c1334
Showing
20 changed files
with
1,155 additions
and
1 deletion.
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
91 changes: 91 additions & 0 deletions
91
wrangler-core/src/e2e-test/features/Wrangler/RunTime.feature
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,91 @@ | ||
# 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. | ||
|
||
@Wrangler | ||
Feature: Wrangler - Run time scenarios | ||
|
||
@BQ_SOURCE_TEST @BQ_SINK_TEST | ||
Scenario: To verify User is able to run a pipeline using the copy count and delete directives in the wrangler plugin | ||
Given Open Datafusion Project to configure pipeline | ||
Then Click on the Plus Green Button to import the pipelines | ||
Then Select the json files for importing the pipelines for the plugin "Directive_copy_drop_count_setcolmn" | ||
Then Navigate to the properties page of plugin: "BigQueryTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Replace input plugin property: "table" with value: "bqSourceTable" | ||
Then Click on the Get Schema button | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Navigate to the properties page of plugin: "BigQuery2" | ||
Then Replace input plugin property: "table" with value: "bqTargetTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Rename the pipeline | ||
Then Deploy the pipeline | ||
Then Run the Pipeline in Runtime | ||
Then Wait till pipeline is in running state | ||
Then Open and capture logs | ||
Then Verify the pipeline status is "Succeeded" | ||
Then Close the pipeline logs | ||
Then Validate The Data From BQ To BQ With Actual And Expected File for: "ExpectedDirective_copy_drop_count_setcolmn" | ||
|
||
@BQ_SOURCE_TEST @BQ_SINK_TEST | ||
Scenario: To verify User is able to run a pipeline using the fill null and send to error directives in the wrangler plugin | ||
Given Open Datafusion Project to configure pipeline | ||
Then Click on the Plus Green Button to import the pipelines | ||
Then Select the json files for importing the pipelines for the plugin "Directive_Fillempty_sendtoerror" | ||
Then Navigate to the properties page of plugin: "BigQueryTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Replace input plugin property: "table" with value: "bqSourceTable" | ||
Then Click on the Get Schema button | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Navigate to the properties page of plugin: "BigQuery2" | ||
Then Replace input plugin property: "table" with value: "bqTargetTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Rename the pipeline | ||
Then Deploy the pipeline | ||
Then Run the Pipeline in Runtime | ||
Then Wait till pipeline is in running state | ||
Then Open and capture logs | ||
Then Verify the pipeline status is "Succeeded" | ||
Then Close the pipeline logs | ||
Then Validate The Data From BQ To BQ With Actual And Expected File for: "ExpectedDirective_Fillempty_sendtoerror" | ||
|
||
@BQ_SOURCE_TEST @BQ_SINK_TEST | ||
Scenario: To verify User is able to run a pipeline using the Format,concatenate,title case and copy column directives in the wrangler plugin | ||
Given Open Datafusion Project to configure pipeline | ||
Then Click on the Plus Green Button to import the pipelines | ||
Then Select the json files for importing the pipelines for the plugin "Directive_Concatenate_titlecase" | ||
Then Navigate to the properties page of plugin: "BigQueryTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Replace input plugin property: "table" with value: "bqSourceTable" | ||
Then Click on the Get Schema button | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Navigate to the properties page of plugin: "BigQuery2" | ||
Then Replace input plugin property: "table" with value: "bqTargetTable" | ||
Then Replace input plugin property: "dataset" with value: "dataset" | ||
Then Click on the Validate button | ||
Then Close the Plugin Properties page | ||
Then Rename the pipeline | ||
Then Deploy the pipeline | ||
Then Run the Pipeline in Runtime | ||
Then Wait till pipeline is in running state | ||
Then Open and capture logs | ||
Then Verify the pipeline status is "Succeeded" | ||
Then Close the pipeline logs | ||
Then Validate The Data From BQ To BQ With Actual And Expected File for: "ExpectedDirective_Concatenate_titlecase" |
127 changes: 127 additions & 0 deletions
127
wrangler-core/src/e2e-test/java/io/cdap/plugin/common/stepsdesign/TestSetupHooks.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,127 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package io.cdap.plugin.common.stepsdesign; | ||
|
||
import com.google.cloud.bigquery.BigQueryException; | ||
import com.google.cloud.storage.Blob; | ||
import com.google.cloud.storage.StorageException; | ||
import io.cdap.e2e.utils.BigQueryClient; | ||
import io.cdap.e2e.utils.PluginPropertyUtils; | ||
import io.cdap.e2e.utils.StorageClient; | ||
import io.cucumber.java.After; | ||
import io.cucumber.java.Before; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.junit.Assert; | ||
import stepsdesign.BeforeActions; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.sql.SQLException; | ||
import java.util.NoSuchElementException; | ||
import java.util.UUID; | ||
|
||
import static io.cdap.e2e.pages.locators.CdfGCSLocators.filePath; | ||
|
||
/** | ||
* BQ test hooks. | ||
*/ | ||
public class TestSetupHooks { | ||
|
||
@Before(order = 1, value = "@BQ_SINK_TEST") | ||
public static void setTempTargetBQTableName() { | ||
String bqTargetTableName = "E2E_TARGET_" + UUID.randomUUID().toString().replaceAll("-", "_"); | ||
PluginPropertyUtils.addPluginProp("bqTargetTable", bqTargetTableName); | ||
BeforeActions.scenario.write("BQ Target table name - " + bqTargetTableName); | ||
} | ||
|
||
@After(order = 1, value = "@BQ_SINK_TEST") | ||
public static void deleteTempTargetBQTable() throws IOException, InterruptedException { | ||
String bqTargetTableName = PluginPropertyUtils.pluginProp("bqTargetTable"); | ||
try { | ||
BigQueryClient.dropBqQuery(bqTargetTableName); | ||
BeforeActions.scenario.write("BQ Target table - " + bqTargetTableName + " deleted successfully"); | ||
PluginPropertyUtils.removePluginProp("bqTargetTable"); | ||
} catch (BigQueryException e) { | ||
if (e.getMessage().contains("Not found: Table")) { | ||
BeforeActions.scenario.write("BQ Target Table " + bqTargetTableName + " does not exist"); | ||
} else { | ||
Assert.fail(e.getMessage()); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Create BigQuery table. | ||
*/ | ||
@Before(order = 1, value = "@BQ_SOURCE_TEST") | ||
public static void createTempSourceBQTable() throws IOException, InterruptedException { | ||
createSourceBQTableWithQueries(PluginPropertyUtils.pluginProp("CreateBQTableQueryFile"), | ||
PluginPropertyUtils.pluginProp("InsertBQDataQueryFile")); | ||
} | ||
|
||
@After(order = 1, value = "@BQ_SOURCE_TEST") | ||
public static void deleteTempSourceBQTable() throws IOException, InterruptedException { | ||
String bqSourceTable = PluginPropertyUtils.pluginProp("bqSourceTable"); | ||
BigQueryClient.dropBqQuery(bqSourceTable); | ||
BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully"); | ||
PluginPropertyUtils.removePluginProp("bqSourceTable"); | ||
} | ||
|
||
private static void createSourceBQTableWithQueries(String bqCreateTableQueryFile, String bqInsertDataQueryFile) | ||
throws IOException, InterruptedException { | ||
String bqSourceTable = "E2E_SOURCE_" + UUID.randomUUID().toString().substring(0, 5).replaceAll("-", | ||
"_"); | ||
|
||
String createTableQuery = StringUtils.EMPTY; | ||
try { | ||
createTableQuery = new String(Files.readAllBytes(Paths.get(TestSetupHooks.class.getResource | ||
("/" + bqCreateTableQueryFile).toURI())) | ||
, StandardCharsets.UTF_8); | ||
createTableQuery = createTableQuery.replace("DATASET", PluginPropertyUtils.pluginProp("dataset")) | ||
.replace("TABLE_NAME", bqSourceTable); | ||
} catch (Exception e) { | ||
BeforeActions.scenario.write("Exception in reading " + bqCreateTableQueryFile + " - " + e.getMessage()); | ||
Assert.fail("Exception in BigQuery testdata prerequisite setup " + | ||
"- error in reading create table query file " + e.getMessage()); | ||
} | ||
|
||
String insertDataQuery = StringUtils.EMPTY; | ||
try { | ||
insertDataQuery = new String(Files.readAllBytes(Paths.get(TestSetupHooks.class.getResource | ||
("/" + bqInsertDataQueryFile).toURI())) | ||
, StandardCharsets.UTF_8); | ||
insertDataQuery = insertDataQuery.replace("DATASET", PluginPropertyUtils.pluginProp("dataset")) | ||
.replace("TABLE_NAME", bqSourceTable); | ||
} catch (Exception e) { | ||
BeforeActions.scenario.write("Exception in reading " + bqInsertDataQueryFile + " - " + e.getMessage()); | ||
Assert.fail("Exception in BigQuery testdata prerequisite setup " + | ||
"- error in reading insert data query file " + e.getMessage()); | ||
} | ||
BigQueryClient.getSoleQueryResult(createTableQuery); | ||
try { | ||
BigQueryClient.getSoleQueryResult(insertDataQuery); | ||
} catch (NoSuchElementException e) { | ||
// Insert query does not return any record. | ||
// Iterator on TableResult values in getSoleQueryResult method throws NoSuchElementException | ||
} | ||
PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); | ||
BeforeActions.scenario.write("BQ Source Table " + bqSourceTable + " created successfully"); | ||
} | ||
} |
Oops, something went wrong.