diff --git a/.openshift-ci/dispatch.sh b/.openshift-ci/dispatch.sh index 39ee8bf999325..968ff14e0c72d 100755 --- a/.openshift-ci/dispatch.sh +++ b/.openshift-ci/dispatch.sh @@ -40,7 +40,7 @@ case "$ci_job" in esac case "$ci_job" in - eks-qa-e2e-tests|osd*qa-e2e-tests|ocp*e2e-tests) + eks-qa-e2e-tests|osd*qa-e2e-tests) setup_automation_flavor_e2e_cluster "$ci_job" ;; esac diff --git a/tests/e2e/lib.sh b/tests/e2e/lib.sh index 92c426f121a30..e87bbe4eb6c3c 100755 --- a/tests/e2e/lib.sh +++ b/tests/e2e/lib.sh @@ -1480,20 +1480,12 @@ setup_automation_flavor_e2e_cluster() { ls -l "${SHARED_DIR}" export KUBECONFIG="${SHARED_DIR}/kubeconfig" - if [[ "$ci_job" =~ ^(osd|ocp) ]]; then - info "Logging in to an ${ci_job:0:3} cluster" + if [[ "$ci_job" =~ ^osd ]]; then + info "Logging in to an OSD cluster" source "${SHARED_DIR}/dotenv" - - # OCP and OSD require one of (OPENSHIFT_CONSOLE_|CLUSTER_) var groups. - # Fail if neither are found from the dotenv. - export OPENSHIFT_CONSOLE_URL="${OPENSHIFT_CONSOLE_URL:-${CLUSTER_CONSOLE_ENDPOINT:-$(oc whoami --show-console)}}" - export OPENSHIFT_API_ENDPOINT="${OPENSHIFT_API_ENDPOINT:-${CLUSTER_API_ENDPOINT:-$(oc whoami --show-server)}}" - export OPENSHIFT_CONSOLE_USERNAME="${OPENSHIFT_CONSOLE_USERNAME:-${CLUSTER_USERNAME:-kubeadmin}}" - export OPENSHIFT_CONSOLE_PASSWORD="${OPENSHIFT_CONSOLE_PASSWORD:-${CLUSTER_PASSWORD}}" - - oc login "$OPENSHIFT_API_ENDPOINT" \ - --username "$OPENSHIFT_CONSOLE_USERNAME" \ - --password "$OPENSHIFT_CONSOLE_PASSWORD" \ + oc login "$CLUSTER_API_ENDPOINT" \ + --username "$CLUSTER_USERNAME" \ + --password "$CLUSTER_PASSWORD" \ --insecure-skip-tls-verify=true fi } diff --git a/ui/Makefile b/ui/Makefile index 688b75e9f9b0d..b33f583f66dfe 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -47,8 +47,6 @@ test-component: deps $(SOURCES) test-e2e: deps $(SOURCES) @echo "+ $@" npm run test-e2e -# Uncomment this once the plugin is installed via the operator in CI -# npm run test-e2e:ocp .PHONY: clean clean: diff --git a/ui/apps/platform/README.md b/ui/apps/platform/README.md index b738498a3ffd7..aeed41eeaca47 100644 --- a/ui/apps/platform/README.md +++ b/ui/apps/platform/README.md @@ -142,36 +142,6 @@ run all end-to-end tests in a headless mode use `npm run test-e2e-local`. To run one test suite specifically in headless mode, use `npm run cypress-spec `. -#### End-to-end Tests (Cypress targeting console plugin) - -To run Cypress against the OCP console for dynamic plugin tests, there are two scenarios that are supported. - -1. Running against a locally deployed version of the development console with bridge authentication off - -```sh -# If necessary, export the target URL -export OPENSHIFT_CONSOLE_URL= -# Set ORCHESTRATOR_FLAVOR, which is typically only available in CI -export ORCHESTRATOR_FLAVOR='openshift' -# Runs Cypress OCP tests ignoring authentication -OCP_BRIDGE_AUTH_DISABLED=true npm run cypress-open:ocp -``` - -2. Running against a deployed version of the console with username/password credentials - -```sh -# If necessary, export the target URL -export OPENSHIFT_CONSOLE_URL= -# Set ORCHESTRATOR_FLAVOR, which is typically only available in CI -export ORCHESTRATOR_FLAVOR='openshift' -# export credentials -export OPENSHIFT_CONSOLE_USERNAME='kubeadmin' -export OPENSHIFT_CONSOLE_PASSWORD= - -# Runs Cypress OCP tests with a session initialization step -npm run cypress-open:ocp -``` - ### Feature flags #### Add a feature flag to frontend code diff --git a/ui/apps/platform/cypress.config.js b/ui/apps/platform/cypress.config.js index 4a0cf2cdd2747..f077d7cd91bfc 100644 --- a/ui/apps/platform/cypress.config.js +++ b/ui/apps/platform/cypress.config.js @@ -7,6 +7,7 @@ */ module.exports = { + blockHosts: ['*.*'], // Browser options chromeWebSecurity: false, // Browser options defaultCommandTimeout: 8000, // Timeouts options numTestsKeptInMemory: 0, // Global options @@ -24,6 +25,7 @@ module.exports = { e2e: { baseUrl: 'https://localhost:3000', + specPattern: 'cypress/integration/**/*.test.{js,ts}', viewportHeight: 850, // Viewport options viewportWidth: 1440, // Viewport options setupNodeEvents: (on) => { diff --git a/ui/apps/platform/cypress/helpers/ocpAuth.ts b/ui/apps/platform/cypress/helpers/ocpAuth.ts deleted file mode 100644 index 18f38fc6654b2..0000000000000 --- a/ui/apps/platform/cypress/helpers/ocpAuth.ts +++ /dev/null @@ -1,21 +0,0 @@ -export function withOcpAuth() { - if (Cypress.env('OCP_BRIDGE_AUTH_DISABLED')) { - return; - } - - // Establish a cookie based session for the OCP web console - cy.session('ocp-session-auth', () => { - cy.visit('/'); - cy.url().should('contain', '/login?'); - cy.get('input[name="username"]').type(Cypress.env('OPENSHIFT_CONSOLE_USERNAME')); - cy.get('input[name="password"]').type(Cypress.env('OPENSHIFT_CONSOLE_PASSWORD')); - cy.get('button[type="submit"]').click(); - - // Wait for the page to load - cy.url().should('contain', '/dashboards'); - cy.get('h1:contains("Overview")'); - - // Pressing Escape closes the welcome modal if it exists, and silently does nothing if it doesn't - cy.get('body').type('{esc}'); - }); -} diff --git a/ui/apps/platform/cypress/integration-ocp/smoke.test.ts b/ui/apps/platform/cypress/integration-ocp/smoke.test.ts deleted file mode 100644 index 8254bd5138876..0000000000000 --- a/ui/apps/platform/cypress/integration-ocp/smoke.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { withOcpAuth } from '../helpers/ocpAuth'; - -describe('Basic connectivity to the OCP plugin', () => { - it('should open the OCP web console', () => { - withOcpAuth(); - - cy.visit('/'); - - cy.get('h1:contains("Overview")'); - }); -}); diff --git a/ui/apps/platform/package.json b/ui/apps/platform/package.json index d42c29a13c184..d890fe3b31cce 100644 --- a/ui/apps/platform/package.json +++ b/ui/apps/platform/package.json @@ -107,13 +107,10 @@ "lint:fix": "eslint --fix --quiet", "tsc": "tsc", "cypress-open": "./scripts/cypress.sh open --e2e --config defaultBrowser=chrome", - "cypress-open:ocp": "./scripts/cypress-ocp.sh open --e2e --config defaultBrowser=chrome", "cypress-spec": "./scripts/cypress.sh run --spec", "cypress-component": "CYPRESS_COMPONENT_TEST=true ./scripts/cypress-component.sh open --component", "test-e2e": "TZ=UTC ./scripts/cypress.sh run --reporter mocha-multi-reporters --reporter-options configFile=cypress/mocha.config.js", "test-e2e-local": "TZ=UTC ./scripts/cypress.sh run", - "test-e2e:ocp": "TZ=UTC ./scripts/cypress-ocp.sh run --reporter mocha-multi-reporters --reporter-options configFile=cypress/mocha.config.js", - "test-e2e-local:ocp": "TZ=UTC ./scripts/cypress-ocp.sh run", "test-component": "TZ=UTC CYPRESS_COMPONENT_TEST=true ./scripts/cypress-component.sh run --reporter mocha-multi-reporters --reporter-options configFile=cypress/mocha.config.js --component", "generate-graphql-possible-types": "ROX_AUTH_TOKEN=$(./scripts/get-auth-token.sh) node scripts/generate-graphql-possible-types.js", "postinstall": "node scripts/check-optional-dependency-versions.js" diff --git a/ui/apps/platform/scripts/cypress-ocp.sh b/ui/apps/platform/scripts/cypress-ocp.sh deleted file mode 100755 index 14498670274ee..0000000000000 --- a/ui/apps/platform/scripts/cypress-ocp.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -export CYPRESS_ORCHESTRATOR_FLAVOR="${ORCHESTRATOR_FLAVOR}" -# exit if ORCHESTRATOR_FLAVOR is not 'openshift' - these tests are only relevant for openshift -if [ "${ORCHESTRATOR_FLAVOR}" != "openshift" ]; then - echo "ORCHESTRATOR_FLAVOR is not 'openshift', skipping cypress-ocp" - exit 0 -fi - - -# Opens cypress with environment variables for feature flags and auth -OPENSHIFT_CONSOLE_URL="${OPENSHIFT_CONSOLE_URL:-http://localhost:9000}" -API_PROXY_BASE_URL="${OPENSHIFT_API_ENDPOINT}/api/proxy/plugin/advanced-cluster-security/api-service" - -if [[ -z "$OPENSHIFT_CONSOLE_USERNAME" || -z "$OPENSHIFT_CONSOLE_PASSWORD" ]]; then - echo "OPENSHIFT_CONSOLE_USERNAME and OPENSHIFT_CONSOLE_PASSWORD must be set" - exit 1 -fi - -curl_cfg() { # Use built-in echo to not expose $2 in the process list. - echo -n "$1 = \"${2//[\"\\]/\\&}\"" -} - -if [[ -n "$OPENSHIFT_CONSOLE_PASSWORD" ]]; then - readarray -t arr < <(curl -sk --config <(curl_cfg user "$OPENSHIFT_CONSOLE_USERNAME:$OPENSHIFT_CONSOLE_PASSWORD") "${API_PROXY_BASE_URL}"/v1/featureflags | jq -cr '.featureFlags[] | {name: .envVar, enabled: .enabled}') - for i in "${arr[@]}"; do - name=$(echo "$i" | jq -rc .name) - val=$(echo "$i" | jq -rc .enabled) - export CYPRESS_"${name}"="${val}" - done -fi - -# eventually it should be in cypress.config.js: https://github.com/cypress-io/cypress/issues/5218 -artifacts_dir="${TEST_RESULTS_OUTPUT_DIR:-cypress/test-results}/artifacts/ocp-console-plugin" -export CYPRESS_VIDEOS_FOLDER="${artifacts_dir}/videos" -export CYPRESS_SCREENSHOTS_FOLDER="${artifacts_dir}/screenshots" -if [[ -n "${OPENSHIFT_CONSOLE_URL}" ]]; then - export CYPRESS_BASE_URL="${OPENSHIFT_CONSOLE_URL}" -fi - -export CYPRESS_SPEC_PATTERN='cypress/integration-ocp/**/*.test.{js,ts}' - - -export CYPRESS_OCP_BRIDGE_AUTH_DISABLED="${OCP_BRIDGE_AUTH_DISABLED}" -export CYPRESS_OPENSHIFT_CONSOLE_USERNAME="${OPENSHIFT_CONSOLE_USERNAME}" -export CYPRESS_OPENSHIFT_CONSOLE_PASSWORD="${OPENSHIFT_CONSOLE_PASSWORD}" - -if [ "$2" == "--spec" ]; then - if [ $# -ne 3 ]; then - echo "usage: npm run cypress-spec " - exit 1 - fi - cypress run --spec "cypress/integration-ocp/$3" -else - DEBUG="cypress*" NO_COLOR=1 cypress "$@" 2> /dev/null -fi diff --git a/ui/apps/platform/scripts/cypress.sh b/ui/apps/platform/scripts/cypress.sh index b4a0a4b41a659..e138f16fed8ee 100755 --- a/ui/apps/platform/scripts/cypress.sh +++ b/ui/apps/platform/scripts/cypress.sh @@ -14,11 +14,11 @@ curl_cfg() { # Use built-in echo to not expose $2 in the process list. } if [[ -n "$ROX_ADMIN_PASSWORD" ]]; then - readarray -t arr < <(curl -sk --config <(curl_cfg user "admin:$ROX_ADMIN_PASSWORD") "${api_endpoint}"/v1/featureflags | jq -cr '.featureFlags[] | {name: .envVar, enabled: .enabled}') + readarray -t arr < <(curl -sk --config <(curl_cfg user "admin:$ROX_ADMIN_PASSWORD") ${api_endpoint}/v1/featureflags | jq -cr '.featureFlags[] | {name: .envVar, enabled: .enabled}') for i in "${arr[@]}"; do - name=$(echo "$i" | jq -rc .name) - val=$(echo "$i" | jq -rc .enabled) - export CYPRESS_"${name}"="${val}" + name=$(echo $i | jq -rc .name) + val=$(echo $i | jq -rc .enabled) + export CYPRESS_${name}=${val} done fi export CYPRESS_ROX_AUTH_TOKEN=$(./scripts/get-auth-token.sh) @@ -31,12 +31,10 @@ if [[ -n "${UI_BASE_URL}" ]]; then export CYPRESS_BASE_URL="${UI_BASE_URL}" fi -export CYPRESS_SPEC_PATTERN='cypress/integration/**/*.test.{js,ts}' - # be able to skip tests that are not relevant, for example: openshift export CYPRESS_ORCHESTRATOR_FLAVOR="${ORCHESTRATOR_FLAVOR}" -if [ "$2" == "--spec" ]; then +if [ $2 == "--spec" ]; then if [ $# -ne 3 ]; then echo "usage: npm run cypress-spec " exit 1 diff --git a/ui/package.json b/ui/package.json index ed4fed65cbaba..139ee9d431b4d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -13,7 +13,6 @@ "lint": "npm --prefix apps/platform run lint", "test": "CI=true npm --prefix apps/platform run test", "test-e2e": "TEST_RESULTS_OUTPUT_DIR=../../test-results npm --prefix apps/platform run test-e2e", - "test-e2e:ocp": "TEST_RESULTS_OUTPUT_DIR=../../test-results npm --prefix apps/platform run test-e2e:ocp", "test-component": "npm --prefix apps/platform run test-component", "posttest-e2e:coverage": "mv apps/platform/coverage/ ./test-results/artifacts/", "prebuild": "npm run clean",