From 51b27e36253142b7d0646b673b38f9eb656c7f38 Mon Sep 17 00:00:00 2001 From: suryakumari Date: Fri, 22 Sep 2023 19:03:04 +0530 Subject: [PATCH] SystemAdmin feature scenarios addition --- .github/workflows/e2e.yml | 102 ++++++++++++ cdap-e2e-tests/pom.xml | 2 +- .../systemadmin/SysAdminDesignTime.feature | 64 ++++++++ .../SysAdminDesignTimeValidation.feature | 48 ++++++ .../systemadmin/SysAdminRunTime.feature | 149 ++++++++++++++++++ .../common/common/TestRunnerRequired.java | 36 +++++ .../common/common/package-info.java | 20 +++ .../common/stepsdesign/TestSetupHooks.java | 94 +++++++++++ .../common/stepsdesign/package-info.java | 20 +++ .../cdap/systemadmin/runners/TestRunner.java | 36 +++++ .../systemadmin/runners/package-info.java | 20 +++ .../resources/errorMessage.properties | 7 +- .../pluginDataCyAttributes.properties | 20 ++- .../resources/pluginParameters.properties | 19 +++ 14 files changed, 634 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/e2e.yml create mode 100644 cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTime.feature create mode 100644 cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTimeValidation.feature create mode 100644 cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminRunTime.feature create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/TestRunnerRequired.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/package-info.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/TestSetupHooks.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/package-info.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/TestRunner.java create mode 100644 cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/package-info.java diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000000..d840cf2d0c9a --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,102 @@ +# 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. + +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven +# Note: Any changes to this workflow would be used only after merging into develop +name: Build e2e tests + +on: + push: + branches: [ develop, release/** ] + pull_request: + branches: [ develop, release/** ] + types: [opened, synchronize, reopened, labeled] + workflow_dispatch: + +jobs: + build: + runs-on: k8s-runner-e2e + # We allow builds: + # 1) When triggered manually + # 2) When it's a merge into a branch + # 3) For PRs that are labeled as build and + # - It's a code change + # - A build label was just added + # A bit complex, but prevents builds when other labels are manipulated + if: > + github.event_name == 'workflow_dispatch' + || github.event_name == 'push' + || (contains(github.event.pull_request.labels.*.name, 'build') + && (github.event.action != 'labeled' || github.event.label.name == 'build') + ) + strategy: + matrix: + tests: [ cdap-e2e-tests ] + fail-fast: false + steps: + # Pinned 1.0.0 version + - uses: actions/checkout@v3 + with: + path: plugin + + - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 + # Pinned version 2.11.1 + if: github.event_name != 'workflow_dispatch' && github.event_name != 'push' + id: filter + with: + working-directory: plugin + filters: | + e2e-test: + - '**/e2e-test/**' + + - name: Checkout e2e test repo + uses: actions/checkout@v3 + with: + repository: cdapio/cdap-e2e-tests + path: e2e + + - name: Cache + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ github.workflow }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven-${{ github.workflow }} + + - name: Run required e2e tests + if: github.event_name != 'workflow_dispatch' && github.event_name != 'push' && steps.filter.outputs.e2e-test == 'false' + run: python3 e2e/src/main/scripts/run_cdap_e2e_test.py --testRunner TestRunnerRequired.java --cdapBranch "${{ github.event.pull_request.base.ref }}" + + - name: Run all e2e tests + if: github.event_name == 'workflow_dispatch' || github.event_name == 'push' || steps.filter.outputs.e2e-test == 'true' + run: python3 e2e/src/main/scripts/run_cdap_e2e_test.py --testRunner TestRunnerRequired.java --cdapBranch "${{ github.event.pull_request.base.ref }}" + + - name: Upload report + uses: actions/upload-artifact@v3 + if: always() + with: + name: Cucumber report - ${{ matrix.tests }} + path: ./plugin/${{ matrix.tests }}/target/cucumber-reports + + - name: Upload debug files + uses: actions/upload-artifact@v3 + if: always() + with: + name: Debug files - ${{ matrix.tests }} + path: ./**/target/e2e-debug + + - name: Upload files to GCS + uses: google-github-actions/upload-cloud-storage@v0 + if: always() + with: + path: ./plugin/cdap-e2e-tests/target/cucumber-reports + destination: e2e-tests-cucumber-reports/${{ github.event.repository.name }}/${{ github.ref }} \ No newline at end of file diff --git a/cdap-e2e-tests/pom.xml b/cdap-e2e-tests/pom.xml index 86dc1236d868..7756d0add8ab 100644 --- a/cdap-e2e-tests/pom.xml +++ b/cdap-e2e-tests/pom.xml @@ -69,7 +69,7 @@ integration-test - verify + diff --git a/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTime.feature b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTime.feature new file mode 100644 index 000000000000..e03153ba3b7a --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTime.feature @@ -0,0 +1,64 @@ +# +# 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. +# + +@Sysadmin +Feature: Sysadmin - Validate system admin page design time scenarios + + Background: + Given Open Datafusion Project to configure pipeline + When Open "System Admin" menu + Then Click on the Configuration link on the System admin page + + @Sysadmin @SysAdminRequired + Scenario:Validate user is able to create new system preferences and able to delete the added system preferences successfully + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Set system preferences with key: "keyValue" and value: "systemPreferences1" + Then Click on the Save & Close preferences button + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Delete the preferences + Then Click on the Save & Close preferences button + Then Verify the system admin page is navigated successfully + + Scenario:Validate user is able to add multiple system preferences inside system admin successfully + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Set system preferences with key: "keyValue" and value: "systemPreferences2" + Then Click on the Save & Close preferences button + Then Click on edit system preferences + Then Delete the preferences + Then Delete the preferences + Then Click on the Save & Close preferences button + Then Verify the system admin page is navigated successfully + + Scenario:Validate user is able to successfully reload system artifacts using reload + Then Click on Reload System Artifacts from the System admin page + Then Click on Reload button on popup to reload the System Artifacts successfully + Then Verify the system admin page is navigated successfully + + Scenario:Validate user is able to open compute profile page and create a compute profile for selected provisioner + Then Click on the Compute Profile from the System admin page + Then Click on create compute profile button + Then Select a provisioner: "remoteHadoopProvisioner" for the compute profile + Then Verify the Create a Profile page is loaded for selected provisioner + Then Enter input plugin property: "profileLabel" with value: "validProfile" + Then Enter textarea plugin property: "profileDescription" with value: "validDescription" + Then Enter input plugin property: "host" with value: "testHost" + Then Enter input plugin property: "user" with value: "testUser" + Then Enter textarea plugin property: "sshKey" with value: "testSSHKey" + Then Click on: "Create" button in the properties + Then Verify the created compute profile: "validProfile" is displayed in system compute profile list diff --git a/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTimeValidation.feature b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTimeValidation.feature new file mode 100644 index 000000000000..052cf49f756f --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminDesignTimeValidation.feature @@ -0,0 +1,48 @@ +# +# 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. +# + +@Sysadmin +Feature: Sysadmin - Validate system admin page design time validation scenarios + + Background: + Given Open Datafusion Project to configure pipeline + When Open "System Admin" menu + Then Click on the Configuration link on the System admin page + + @SysAdminRequired + Scenario:Validate user is able reset the system preferences added inside system admin successfully + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Set system preferences with key: "keyValue" and value: "systemPreferences1" + Then Reset the preferences + Then Verify the reset is successful for added preferences + + Scenario:To verify the validation error message with invalid profile name + Then Click on the Compute Profile from the System admin page + Then Click on create compute profile button + Then Select a provisioner: "existingDataProc" for the compute profile + Then Enter input plugin property: "profileLabel" with value: "invalidProfile" + Then Enter textarea plugin property: "profileDescription" with value: "validDescription" + Then Enter input plugin property: "clusterName" with value: "validClusterName" + Then Click on: "Create" button in the properties + Then Verify that the compute profile is displaying an error message: "errorInvalidProfileName" on the footer + + Scenario:To verify the validation error message with invalid namespace name + Then Click on Create New Namespace button + Then Enter the New Namespace Name with value: "invalidNamespaceName" + Then Enter the Namespace Description with value: "validNamespaceDescription" + Then Click on: "Finish" button in the properties + Then Verify the failed error message: "errorInvalidNamespace" displayed on dialog box diff --git a/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminRunTime.feature b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminRunTime.feature new file mode 100644 index 000000000000..4562eb9dec25 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/features/systemadmin/SysAdminRunTime.feature @@ -0,0 +1,149 @@ +# +# 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. +# + +@Sysadmin +Feature: Sysadmin - Validate system admin page Run time scenarios + + Background: + Given Open Datafusion Project to configure pipeline + When Open "System Admin" menu + Then Click on the Configuration link on the System admin page + + @Sysadmin + Scenario:To verify user should be able to create Namespace successfully in System Admin + Then Click on Create New Namespace button + Then Enter the New Namespace Name with value: "namespaceName" + Then Enter the Namespace Description with value: "validNamespaceDescription" + Then Click on: "Finish" button in the properties + Then Verify the namespace created success message displayed on confirmation window + Then Verify the created namespace: "namespaceName" is displayed in Namespace tab + + @SysAdminRequired + Scenario:To verify User should be able to add a secure key from Make HTTP calls successfully with PUT calls + Then Click on Make HTTP calls from the System admin configuration page + Then Select request dropdown property with option value: "httpPutMethod" + Then Enter input plugin property: "requestPath" with value: "secureKey" + Then Enter textarea plugin property: "requestBody" with value: "bodyValue" + Then Click on send button + Then Verify the status code for success response + + @SysAdminRequired + Scenario:To verify User should be able to fetch secure key from Make HTTP calls successfully with GET calls + Then Click on Make HTTP calls from the System admin configuration page + Then Select request dropdown property with option value: "httpGetMethod" + Then Enter input plugin property: "requestPath" with value: "secureKey" + Then Click on send button + Then Verify the status code for success response + + @SysAdminRequired + Scenario:To verify User should be able to delete secure key from Make HTTP calls successfully with DELETE calls + Then Click on Make HTTP calls from the System admin configuration page + Then Select request dropdown property with option value: "httpDeleteMethod" + Then Enter input plugin property: "requestPath" with value: "secureKey" + Then Click on send button + Then Verify the status code for success response + + @BQ_SOURCE_TEST @BQ_SINK_TEST @SysAdminRequired + Scenario:To verify user should be able to run a pipeline successfully using the System preferences created + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Set system preferences with key: "keyValue" and value: "systemPreferences2" + Then Click on the Save & Close preferences button + Then Click on the Hamburger menu on the left panel + Then Select navigation item: "studio" from the Hamburger menu list + 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" + Then Enter input plugin property: "referenceName" with value: "BQReferenceName" + Then Click on the Macro button of Property: "projectId" and set the value to: "projectId" + Then Click on the Macro button of Property: "datasetProjectId" and set the value to: "datasetProjectId" + Then Enter input plugin property: "dataset" with value: "dataset" + Then Enter input plugin property: "table" with value: "bqSourceTable" + Then Validate "BigQuery" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "BigQuery2" + Then Click on the Macro button of Property: "projectId" and set the value to: "projectId" + Then Click on the Macro button of Property: "datasetProjectId" and set the value to: "datasetProjectId" + 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: "bqSourceTable" + Then Validate "BigQuery" plugin properties + Then 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 Open and capture logs + Then Verify the pipeline status is "Succeeded" + + @BQ_SOURCE_TEST @BQ_SINK_TEST @SysAdminRequired + Scenario:To verify user should be able to run a pipeline successfully using existing System preferences and the Namespace preferences created + Then Click on Create New Namespace button + Then Enter the New Namespace Name with value: "sampleNamespaceName" + Then Enter the Namespace Description with value: "validNamespaceDescription" + Then Click on: "Finish" button in the properties + Then Verify the namespace created success message displayed on confirmation window + Then Click on the switch to namespace button + Then Click on the Hamburger menu on the left panel + Then Select navigation item: "namespaceAdmin" from the Hamburger menu list + Then Click "preferences" tab from Configuration page for "sampleNamespaceName" Namespace + Then Click on edit namespace preferences to set namespace preferences + Then Set system preferences with key: "keyValue" and value: "systemPreferences1" + Then Click on the Save & Close preferences button + Then Click on the Hamburger menu on the left panel + Then Select navigation item: "studio" from the Hamburger menu list + 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" + Then Enter input plugin property: "referenceName" with value: "BQReferenceName" + Then Click on the Macro button of Property: "projectId" and set the value to: "projectId" + Then Click on the Macro button of Property: "datasetProjectId" and set the value to: "datasetProjectId" + Then Click on the Macro button of Property: "dataset" and set the value to: "dataset" + Then Enter input plugin property: "table" with value: "bqSourceTable" + Then Validate "BigQuery" plugin properties + Then Close the Plugin Properties page + Then Navigate to the properties page of plugin: "BigQuery2" + Then Enter input plugin property: "referenceName" with value: "BQReferenceName" + Then Click on the Macro button of Property: "projectId" and set the value to: "projectId" + Then Click on the Macro button of Property: "datasetProjectId" and set the value to: "datasetProjectId" + Then Click on the Macro button of Property: "dataset" and set the value to: "dataset" + Then Enter input plugin property: "table" with value: "bqSourceTable" + Then Validate "BigQuery" plugin properties + Then 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 Open and capture logs + Then Verify the pipeline status is "Succeeded" + Then Close the pipeline logs + When Open "System Admin" menu + Then Click on the Configuration link on the System admin page + Then Select "systemPreferences" option from Configuration page + Then Click on edit system preferences + Then Delete the preferences + Then Delete the preferences + Then Click on the Save & Close preferences button + Then Click on the Hamburger menu on the left panel + Then Select navigation item: "namespaceAdmin" from the Hamburger menu list + Then Click "preferences" tab from Configuration page for "sampleNamespaceName" Namespace + Then Click on edit namespace preferences to set namespace preferences + Then Delete the preferences + Then Click on the Save & Close preferences button diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/TestRunnerRequired.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/TestRunnerRequired.java new file mode 100644 index 000000000000..3ed7a83aaed9 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/TestRunnerRequired.java @@ -0,0 +1,36 @@ +/* + * 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.systemadmin.common.common; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +/** + * Test Runner to execute required test cases. Add @SysAdminRequired tag on the scenario. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = {"src/e2e-test/features"}, + glue = {"stepsdesign", "io.cdap.cdap.systemadmin.common.stepsdesign"}, + tags = {"@SysAdminRequired"}, + plugin = {"pretty", "html:target/cucumber-html-report/required", + "json:target/cucumber-reports/cucumber-required.json", + "junit:target/cucumber-reports/cucumber-required.xml"}, + monochrome = true +) +public class TestRunnerRequired { +} diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/package-info.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/package-info.java new file mode 100644 index 000000000000..cb29e9b51c46 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/common/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 common runners. + */ +package io.cdap.cdap.systemadmin.common.common; diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/TestSetupHooks.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/TestSetupHooks.java new file mode 100644 index 000000000000..e83fea75e7e2 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/TestSetupHooks.java @@ -0,0 +1,94 @@ +/* + * 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.systemadmin.common.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 java.io.IOException; +import java.util.UUID; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import stepsdesign.BeforeActions; + +/** + * GCP test hooks. + */ +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_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()); + } + } + } + + /** + * Create BigQuery table with 3 columns (Id - Int, Value - Int, UID - string) containing random testdata. + * Sample row: + * Id | Value | UID + * 22 | 968 | 245308db-6088-4db2-a933-f0eea650846a + */ + @Before(order = 1, value = "@BQ_SOURCE_TEST") + public static void createTempSourceBQTable() throws IOException, InterruptedException { + bqSourceTable = "E2E_SOURCE_" + UUID.randomUUID().toString().replaceAll("-", "_"); + StringBuilder records = new StringBuilder(StringUtils.EMPTY); + for (int index = 2; index <= 25; index++) { + records.append(" (").append(index).append(", ").append((int) (Math.random() * 1000 + 1)).append(", '") + .append(UUID.randomUUID()).append("'), "); + } + BigQueryClient.getSoleQueryResult("create table `" + datasetName + "." + bqSourceTable + "` as " + + "SELECT * FROM UNNEST([ " + + " STRUCT(1 AS Id, " + ((int) (Math.random() * 1000 + 1)) + " as Value, " + + "'" + UUID.randomUUID() + "' as UID), " + + records + + " (26, " + ((int) (Math.random() * 1000 + 1)) + ", " + + "'" + UUID.randomUUID() + "') " + + "])"); + PluginPropertyUtils.addPluginProp("bqSourceTable", bqSourceTable); + BeforeActions.scenario.write("BQ source Table " + bqSourceTable + " created successfully"); + } + + @After(order = 1, value = "@BQ_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; + } +} diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/package-info.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/package-info.java new file mode 100644 index 000000000000..31b84d5840bc --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/common/stepsdesign/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 stepDesign for the common features. + */ +package io.cdap.cdap.systemadmin.common.stepsdesign; diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/TestRunner.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/TestRunner.java new file mode 100644 index 000000000000..450b8706c9e3 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/TestRunner.java @@ -0,0 +1,36 @@ +/* + * 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.systemadmin.runners; + +import io.cucumber.junit.Cucumber; +import io.cucumber.junit.CucumberOptions; +import org.junit.runner.RunWith; + +/** + * Test Runner to execute system admin related test cases. + */ +@RunWith(Cucumber.class) +@CucumberOptions( + features = {"src/e2e-test/features"}, + glue = {"io.cdap.cdap.systemadmin.common.stepsdesign", "stepsdesign"}, + tags = {"@Sysadmin"}, + plugin = {"pretty", "html:target/cucumber-html-report/systemadmin", + "json:target/cucumber-reports/cucumber-systemadmin.json", + "junit:target/cucumber-reports/cucumber-systemadmin.xml"} +) +public class TestRunner { +} diff --git a/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/package-info.java b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/runners/package-info.java new file mode 100644 index 000000000000..084b2e6019c7 --- /dev/null +++ b/cdap-e2e-tests/src/e2e-test/java/io/cdap/cdap/systemadmin/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 system admin features. + */ +package io.cdap.cdap.systemadmin.runners; diff --git a/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties b/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties index b8da87be1bbb..d26ec820ba44 100644 --- a/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties +++ b/cdap-e2e-tests/src/e2e-test/resources/errorMessage.properties @@ -1,2 +1,7 @@ invalid.message_hub=No entities found -fail.message_hub=Failed to Deploy \ No newline at end of file +fail.message_hub=Failed to Deploy +validationResetSuccessMessage=Reset Successful +errorInvalidClusterName=Unable to get credentials from the environment. Please explicitly set the account key. +errorInvalidProfileName=Invalid profile ID: 6*&gjh879. Should only contain alphanumeric characters and _ or -. +errorInvalidNamespace=Failed to Add namespace +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 index efd810591265..cf1c8e728e82 100644 --- a/cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties +++ b/cdap-e2e-tests/src/e2e-test/resources/pluginDataCyAttributes.properties @@ -2,4 +2,22 @@ Filter=filter-dropdown Artifcats=Artifacts-input Anaplan=anaplan-plugins List=navbar-pipelines-link -Actions=select-schema-actions-dropdown \ No newline at end of file +Actions=select-schema-actions-dropdown +systemPreferences=system-prefs-accordion +keyValue=key-value-pair- +existingDataProc=provisioner-gcp-existing-dataproc +gcpDataProc=provisioner-gcp-dataproc +remoteHadoopProvisioner=provisioner-remote-hadoop +Create=profile-create-btn +Finish=wizard-finish-btn +Next=wizard-next-btn +Previous=wizard-previous-btn +profileName=profile-list- +amazonEMRProvisioner=provisioner-aws-emr +requestMethod=request-method-selector +requestPath=request-path-input +requestBody=request-body +studio=pipeline-studio +namespaceAdmin=project-admin +projectId=project +datasetProjectId=datasetProject diff --git a/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties b/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties index 1c047a300396..80d35ed2d702 100644 --- a/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties +++ b/cdap-e2e-tests/src/e2e-test/resources/pluginParameters.properties @@ -15,3 +15,22 @@ gcsTargetBucketName=dummy gcsTargetPath=dummy ## HUB-PROPERTIES-END +## SYSTEMADMIN-PROPERTIES-START +systemPreferences1=[{"key":"dataset","value":"test_automation"}] +systemPreferences2=[{"key":"projectId","value":"cdf-athena"},{"key":"datasetProjectId","value":"cdf-athena"}] +validProfile=TestProfile +validDescription=TestDescription +validClusterName=TestClusterName +invalidNamespaceName=^%&&3%% +validNamespaceDescription=Test Description +invalidProfile=6*&gjh879 +invalidClusterName=$^%%&^GHJJH89 +namespaceName=TestNamespace +sampleNamespaceName=sampleNamespace +secureKey=namespaces/default/securekeys/mytestkey +bodyValue={ "description": "Example Secure Key","data": "test123","properties": { "": "" } } +httpPutMethod=PUT +httpGetMethod=GET +httpDeleteMethod=DELETE +dataset=test_automation +## SYSTEMADMIN-PROPERTIES-END