From 5c8ac3e179dc29cad5b06c505400db5cba37b976 Mon Sep 17 00:00:00 2001 From: priyabhatnagar Date: Mon, 23 Oct 2023 16:27:18 +0530 Subject: [PATCH] control center cdap --- .../controlcenter/ControlCenter.feature | 101 ++++++++++++++++++ .../controlcenter/runners/TestRunner.java | 37 +++++++ .../controlcenter/runners/package-info.java | 20 ++++ .../stepsdesign/TestSetupHooks.java | 87 +++++++++++++++ .../resources/errorMessage.properties | 1 + .../pluginDataCyAttributes.properties | 4 + .../resources/pluginParameters.properties | 7 ++ 7 files changed, 257 insertions(+) create mode 100644 cdap-e2e-tests/src/e2e-test/features/controlcenter/ControlCenter.feature create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/TestRunner.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/package-info.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/stepsdesign/TestSetupHooks.java create mode 100644 cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties create mode 100644 cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties diff --git a/cdap-e2e-tests/src/e2e-test/features/controlcenter/ControlCenter.feature b/cdap-e2e-tests/src/e2e-test/features/controlcenter/ControlCenter.feature new file mode 100644 index 000000000000..a0cfe26f9d27 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/features/controlcenter/ControlCenter.feature @@ -0,0 +1,101 @@ +# 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. + +@Controlcenter + +Feature: Controlcenter - Validate control center page flow + + Scenario: Verify user is able to click the control center tab and successfully navigates to control center page + Given Open Datafusion Project to configure pipeline + Then Click on the Hamburger bar on the left panel + Then Click on Control Center link from the hamburger menu + Then Verify that the user is navigated to control center page successfully + + @BQ_INSERT_INT_SOURCE_TEST @BQ_SINK_TEST + Scenario: Verify that user is able to create a pipeline and then validate the presence of created pipeline in control center. + Given Open Datafusion Project to configure pipeline + Then Click on the Hamburger bar on the left panel + Then Click on Control Center link from the hamburger menu + Then Click on the Plus Green Button to import the pipelines + Then Verify user is able to click on the create button to create a pipeline successfully + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "BigQuery" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "BigQuery" from the plugins list as: "Sink" + Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection + Then Navigate to the properties page of plugin: "BigQuery" + And Enter input plugin property: "referenceName" with value: "Reference" + And Replace input plugin property: "project" with value: "projectId" + And Enter input plugin property: "datasetProject" with value: "projectId" + And Replace input plugin property: "dataset" with value: "dataset" + Then Override Service account details if set in environment variables + And Enter input plugin property: "table" with value: "bqSourceTable" + Then Click on the Get Schema button + Then Validate "BigQuery" plugin properties + And Close the Plugin Properties page + Then Navigate to the properties page of plugin: "BigQuery2" + Then Replace input plugin property: "project" with value: "projectId" + Then Override Service account details if set in environment variables + Then Enter input plugin property: "datasetProject" with value: "projectId" + Then Enter input plugin property: "referenceName" with value: "BQReferenceName" + Then Enter input plugin property: "dataset" with value: "dataset" + Then Enter input plugin property: "table" with value: "bqTargetTable" + Then Validate "BigQuery" plugin properties + And Close the Plugin Properties page + Then Save the pipeline + Then Deploy the pipeline + Then Run the Pipeline in Runtime + Then Wait till pipeline is in running state + Then Verify the pipeline status is "Succeeded" + Then Click on the Hamburger bar on the left panel + Then Click on Control Center link from the hamburger menu + Then Verify the pipeline created successfully is present in control center page + + @BQ_INSERT_INT_SOURCE_TEST @BQ_SINK_TEST + Scenario: Verify that user is able to delete the created pipeline in control center successfully. + Given Open Datafusion Project to configure pipeline + Then Click on the Hamburger bar on the left panel + Then Click on Control Center link from the hamburger menu + Then Click on the Plus Green Button to import the pipelines + Then Verify user is able to click on the create button to create a pipeline successfully + When Expand Plugin group in the LHS plugins list: "Source" + When Select plugin: "BigQuery" from the plugins list as: "Source" + When Expand Plugin group in the LHS plugins list: "Sink" + When Select plugin: "BigQuery" from the plugins list as: "Sink" + Then Connect plugins: "BigQuery" and "BigQuery2" to establish connection + Then Navigate to the properties page of plugin: "BigQuery" + And Enter input plugin property: "referenceName" with value: "Reference" + And Replace input plugin property: "project" with value: "projectId" + And Enter input plugin property: "datasetProject" with value: "projectId" + And Replace input plugin property: "dataset" with value: "dataset" + Then Override Service account details if set in environment variables + And Enter input plugin property: "table" with value: "bqSourceTable" + Then Click on the Get Schema button + Then Validate "BigQuery" plugin properties + And Close the Plugin Properties page + Then Navigate to the properties page of plugin: "BigQuery2" + Then Replace input plugin property: "project" with value: "projectId" + Then Override Service account details if set in environment variables + Then Enter input plugin property: "datasetProject" with value: "projectId" + Then Enter input plugin property: "referenceName" with value: "BQReferenceName" + Then Enter input plugin property: "dataset" with value: "dataset" + Then Enter input plugin property: "table" with value: "bqTargetTable" + Then Validate "BigQuery" plugin properties + And Close the Plugin Properties page + Then Save the pipeline + Then Deploy the pipeline + Then Click on the Hamburger bar on the left panel + Then Click on Control Center link from the hamburger menu + Then Click on the delete icon of the created pipeline and pipeline should get deleted successfully + Then Verify the deleted pipeline is not present in the control center page diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/TestRunner.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/TestRunner.java new file mode 100644 index 000000000000..0633dedc0b64 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/TestRunner.java @@ -0,0 +1,37 @@ +/* + * 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.cdap.controlcenter.runners; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +/** + * Test Runner to execute controlcenter related test cases. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = {"src/e2e-test/features"}, + glue = {"io.cdap.cdap.controlcenter.stepsdesign", "stepsdesign"}, + tags = {"@Controlcenter"}, + plugin = {"pretty", "html:target/cucumber-html-report/controlcenter", + "json:target/cucumber-reports/cucumber-controlcenter.json", + "junit:target/cucumber-reports/cucumber-controlcenter.xml"} +) +public class TestRunner { + +} \ No newline at end of file diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/package-info.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/package-info.java new file mode 100644 index 000000000000..0b84865f722e --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/runners/package-info.java @@ -0,0 +1,20 @@ +/* + * 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 contains the runners for controlcenter features. + */ +package io.cdap.cdap.controlcenter.runners; diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/stepsdesign/TestSetupHooks.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/stepsdesign/TestSetupHooks.java new file mode 100644 index 000000000000..527e60cbcdfa --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/controlcenter/stepsdesign/TestSetupHooks.java @@ -0,0 +1,87 @@ +/* + * 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.cdap.controlcenter.stepsdesign; + +import com.google.cloud.bigquery.BigQueryException; +import io.cdap.e2e.utils.BigQueryClient; +import io.cdap.e2e.utils.PluginPropertyUtils; +import io.cucumber.java.After; +import io.cucumber.java.Before; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import stepsdesign.BeforeActions; + +import java.io.IOException; +import java.util.NoSuchElementException; +import java.util.UUID; + +public class TestSetupHooks { + public static String bqTargetTable = StringUtils.EMPTY; + public static String bqSourceTable = StringUtils.EMPTY; + public static String datasetName = PluginPropertyUtils.pluginProp("dataset"); + + @Before(order = 1, value = "@BQ_INSERT_INT_SOURCE_TEST") + public static void createSourceBQTable() throws IOException, InterruptedException { + bqSourceTable = "E2E_SOURCE_" + UUID.randomUUID().toString().replaceAll("-", "_"); + PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); + BeforeActions.scenario.write("BQ source table name - " + bqSourceTable); + BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqSourceTable + "` " + + "(ID INT64, Name STRING, Price FLOAT64, Customer_Exists BOOL)"); + try { + BigQueryClient.getSoleQueryResult("INSERT INTO `" + datasetName + "." + bqSourceTable + "` " + + "(ID, Name, Price,Customer_Exists)" + + "VALUES" + "(3, 'Rajan Kumar', 100.0, true)"); + } catch (NoSuchElementException e) { + // Insert query does not return any record. + // Iterator on TableResult values in getSoleQueryResult method throws NoSuchElementException + BeforeActions.scenario.write("Error inserting the record in the table" + e.getStackTrace()); + } + PluginPropertyUtils.addPluginProp(" bqSourceTable", bqSourceTable); + BeforeActions.scenario.write("BQ Source Table " + bqSourceTable + " updated successfully"); + } + + @After(order = 1, value = "@BQ_INSERT_INT_SOURCE_TEST") + public static void deleteTempSourceBQTable() throws IOException, InterruptedException { + BigQueryClient.dropBqQuery(bqSourceTable); + PluginPropertyUtils.removePluginProp("bqSourceTable"); + BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " deleted successfully"); + bqSourceTable = StringUtils.EMPTY; + } + + @Before(order = 1, value = "@BQ_SINK_TEST") + public static void setTempTargetBQTableName() { + bqTargetTable = "E2E_TARGET_" + UUID.randomUUID().toString().replaceAll("-", "_"); + PluginPropertyUtils.addPluginProp("bqTargetTable", bqTargetTable); + BeforeActions.scenario.write("BQ Target table name - " + bqTargetTable); + } + + @After(order = 1, value = "@BQ_SINK_TEST") + public static void deleteTempTargetBQTable() throws IOException, InterruptedException { + try { + BigQueryClient.dropBqQuery(bqTargetTable); + PluginPropertyUtils.removePluginProp("bqTargetTable"); + BeforeActions.scenario.write("BQ Target table - " + bqTargetTable + " deleted successfully"); + bqTargetTable = StringUtils.EMPTY; + } catch (BigQueryException e) { + if (e.getMessage().contains("Not found: Table")) { + BeforeActions.scenario.write("BQ Target Table " + bqTargetTable + " does not exist"); + } else { + Assert.fail(e.getMessage()); + } + } + } +} diff --git a/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties b/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties new file mode 100644 index 000000000000..87c8235075cd --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties @@ -0,0 +1 @@ +validationSuccessMessage=No errors found. diff --git a/cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties b/cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties new file mode 100644 index 000000000000..2b87fe417381 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties @@ -0,0 +1,4 @@ +projectId=project +datasetProjectId=datasetProject +referenceName=referenceName +table=table diff --git a/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties b/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties index f91925346d6d..3c7b01b1c4ce 100644 --- a/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties +++ b/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties @@ -2,4 +2,11 @@ clientName=cdap clientUrl=http://localhost:11011 serverUrl=https://placeholder.com/api # command to generate token: gcloud auth print-access-token + +## CONTROLCENTER-START serverAccessToken=placeholder +bqSourceTable=dummy +dataset=bq_automation +projectId=cdf-athena +datasetprojectId=cdf-athena +## CONTROLCENTER-END