From ab4dc9c07eeab175540d18cbd0e41ca011521706 Mon Sep 17 00:00:00 2001 From: Chad Woolley <cwoolley@gitlab.com> Date: Sun, 28 May 2023 09:00:10 +0000 Subject: [PATCH] Add remote dev scripts dir, tweak e2e spec - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/120964 --- danger/roulette/Dangerfile | 3 +- qa/qa/ee/page/workspace/new.rb | 1 - ...create_new_workspace_and_terminate_spec.rb | 30 +++----- scripts/remote_development/run-e2e-tests.sh | 36 ++++++++++ .../run-smoke-test-suite.sh | 71 +++++++++++++++++++ spec/tooling/danger/project_helper_spec.rb | 1 + tooling/danger/project_helper.rb | 1 + 7 files changed, 121 insertions(+), 22 deletions(-) create mode 100755 scripts/remote_development/run-e2e-tests.sh create mode 100755 scripts/remote_development/run-smoke-test-suite.sh diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile index 5b865498651c9..fd93d566db5c7 100644 --- a/danger/roulette/Dangerfile +++ b/danger/roulette/Dangerfile @@ -57,7 +57,8 @@ NOT_AVAILABLE_TEMPLATES = { default: 'No %{role} available', product_intelligence: group_not_available_template('#g_analyze_analytics_instrumentation', '@gitlab-org/analytics-section/product-intelligence/engineers'), import_integrate_be: group_not_available_template('#g_manage_import_and_integrate', '@gitlab-org/manage/import-and-integrate'), - import_integrate_fe: group_not_available_template('#g_manage_import_and_integrate', '@gitlab-org/manage/import-and-integrate') + import_integrate_fe: group_not_available_template('#g_manage_import_and_integrate', '@gitlab-org/manage/import-and-integrate'), + remote_development: group_not_available_template('#f_remote_development', '@gitlab-org/remote-development') }.freeze def note_for_spin_role(spin, role, category) diff --git a/qa/qa/ee/page/workspace/new.rb b/qa/qa/ee/page/workspace/new.rb index b92265299c104..eaa6c7d212034 100644 --- a/qa/qa/ee/page/workspace/new.rb +++ b/qa/qa/ee/page/workspace/new.rb @@ -22,7 +22,6 @@ def select_cluster_agent(agent) options = agent_selector.all('option') raise "No agent available" if options.empty? - raise "No matching agent found" if options.none? { |option| option.text == agent } agent_selector.select agent end diff --git a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/create_new_workspace_and_terminate_spec.rb b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/create_new_workspace_and_terminate_spec.rb index 0843ec902deed..f92e1ce11bf1a 100644 --- a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/create_new_workspace_and_terminate_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/create_new_workspace_and_terminate_spec.rb @@ -8,24 +8,14 @@ # # How to setup the test # -# 1. Ensure gitlab is up and running with default KAS / agentk stopped -# 2. Setup agentk for a group and start agentk with the token received. -# (This agent name is passed in variable AGENTK_NAME) -# 3. Add a project under the same group and add a file named .devfile.yaml with below content. -# (This project name is passed in variable DEVFILE_PROJECT) -# devfile_content = <<~YAML -# schemaVersion: 2.2.0 -# components: -# - name: tooling-container -# attributes: -# gl/inject-editor: true -# container: -# image: quay.io/mloriedo/universal-developer-image:ubi8-dw-demo -# YAML -# 4. Call the helper scripts at `scripts/remote_development/run_e2e_spec.sh` with DEVFILE_PROJECT and AGENTK_NAME -# For example, to override any variable, the script can be run in the following manner -# DEVFILE_PROJECT="devfile-test-project" AGENTK_NAME="test-agent" GITLAB_PASSWORD=example -# TEST_INSTANCE_URL=https://gdk.test:3000 scripts/remote_development/run-e2e-spec.sh +# 1. Follow this documentation to set up your local GDK environment for creating remote development workspaces: +# https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/-/blob/main/doc/local-development-environment-setup.md +# 2. Ensure that you can successfully create and terminate workspaces in your local GDK environment. +# 3. Call the helper script at `scripts/remote_development/run-e2e-tests.sh`. +# If you used all the default suggested group/project/agent values in the documentation above, the default values +# should work for you. Otherwise, any variable can be overridden on the command line, for example: +# +# DEVFILE_PROJECT="devfile-test-project" AGENT_NAME="test-agent" scripts/remote_development/run-e2e-tests.sh module QA RSpec.describe 'Create', @@ -35,10 +25,10 @@ module QA }, product_group: :ide do describe 'Remote Development' do let(:devfile_project_name) { ENV.fetch("DEVFILE_PROJECT", "devfile-project-example") } - let(:agent) { ENV.fetch("AGENTK_NAME", "test-agentk") } + let(:agent) { ENV.fetch("AGENT_NAME", "test-agent") } before do - Flow::Login.sign_in + Flow::Login.sign_in(skip_page_validation: true) end it 'creates a new workspace and then stops and terminates it', diff --git a/scripts/remote_development/run-e2e-tests.sh b/scripts/remote_development/run-e2e-tests.sh new file mode 100755 index 0000000000000..905bef4754dd0 --- /dev/null +++ b/scripts/remote_development/run-e2e-tests.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh + +# frozen_string_literal: true + +# This is a convenience script to run the Remote Development category E2E spec(s) against a local +# GDK environment. It sets default values for the necessary environment variables, but allows +# them to be overridden. +# +# For details on how to run this, see the documentation comments at the top of +# qa/qa/specs/features/ee/browser_ui/3_create/remote_development/create_new_workspace_and_terminate_spec.rb + +DEFAULT_PASSWORD='5iveL!fe' + +export WEBDRIVER_HEADLESS="${WEBDRIVER_HEADLESS:-0}" +export QA_SUPER_SIDEBAR_ENABLED="${QA_SUPER_SIDEBAR_ENABLED:-1}" # This is currently necessary for the test to pass +export GITLAB_USERNAME="${GITLAB_USERNAME:-root}" +export GITLAB_PASSWORD="${GITLAB_PASSWORD:-${DEFAULT_PASSWORD}}" +export DEVFILE_PROJECT="${DEVFILE_PROJECT:-Gitlab Org / Gitlab Shell}" +export AGENT_NAME="${AGENT_NAME:-remotedev}" +export TEST_INSTANCE_URL="${TEST_INSTANCE_URL:-http://gdk.test:3000}" + +echo "WEBDRIVER_HEADLESS: ${WEBDRIVER_HEADLESS}" +echo "QA_SUPER_SIDEBAR_ENABLED: ${QA_SUPER_SIDEBAR_ENABLED}" +echo "GITLAB_USERNAME: ${GITLAB_USERNAME}" +echo "DEVFILE_PROJECT: ${AGENT_NAME}" +echo "AGENT_NAME: ${AGENT_NAME}" +echo "TEST_INSTANCE_URL: ${TEST_INSTANCE_URL}" + +working_directory="$(git rev-parse --show-toplevel)/qa" + +# TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/397005 +# Remove the '--tag quarantine' from below once this test is removed from quarantine +(cd "$working_directory" && \ + bundle && \ + bundle exec bin/qa Test::Instance::All "$TEST_INSTANCE_URL" -- \ + --tag quarantine qa/specs/features/ee/browser_ui/3_create/remote_development) diff --git a/scripts/remote_development/run-smoke-test-suite.sh b/scripts/remote_development/run-smoke-test-suite.sh new file mode 100755 index 0000000000000..5c1c5532a0588 --- /dev/null +++ b/scripts/remote_development/run-smoke-test-suite.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# This script runs a suite of non-E2E specs related to the Remote Development category, as +# a pre-commit/pre-push "Smoke Test" to catch any broken tests without having to wait +# on CI to catch them. Note that there are some shared/common specs related to +# Remote Development which are not included in this suite. +# https://en.wikipedia.org/wiki/Smoke_testing_(software) + +# shellcheck disable=SC2059 + +set -o errexit # AKA -e - exit immediately on errors (http://mywiki.wooledge.org/BashFAQ/105) + +# https://stackoverflow.com/a/28938235 +BCyan='\033[1;36m' # Bold Cyan +BRed='\033[1;31m' # Bold Red +BGreen='\033[1;32m' # Bold Green +BBlue='\033[1;34m' # Bold Blue +Color_Off='\033[0m' # Text Reset + +function onexit_err() { + local exit_status=${1:-$?} + printf "\nâŒâŒâŒ ${BRed}Remote Development specs failed!${Color_Off} âŒâŒâŒ\n" + exit "${exit_status}" +} +trap onexit_err ERR +set -o errexit + +printf "${BCyan}" +printf "\nStarting Remote Development specs.\n\n" +printf "${Color_Off}" + +printf "${BBlue}Running Remote Development backend specs${Color_Off}\n\n" + +# NOTE: For some reason this test started causing the following spec file in the list to blow up with +# "Failed to write to log, write log/workhorse-test.log: file already closed". Just removing +# it for now. +# ee/spec/graphql/api/workspace_spec.rb + +bin/spring rspec -r spec_helper \ +ee/spec/features/remote_development/workspaces_spec.rb \ +ee/spec/finders/remote_development/workspaces_finder_spec.rb \ +ee/spec/graphql/types/query_type_spec.rb \ +ee/spec/graphql/types/remote_development/workspace_type_spec.rb \ +ee/spec/graphql/types/subscription_type_spec.rb \ +ee/spec/lib/remote_development/workspaces/create/create_processor_spec.rb \ +ee/spec/lib/remote_development/workspaces/create/devfile_processor_spec.rb \ +ee/spec/lib/remote_development/workspaces/create/devfile_validator_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/actual_state_calculator_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/agent_info_parser_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/agent_info_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/desired_config_generator_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/params_parser_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/reconcile_processor_scenarios_spec.rb \ +ee/spec/lib/remote_development/workspaces/reconcile/reconcile_processor_spec.rb \ +ee/spec/lib/remote_development/workspaces/states_spec.rb \ +ee/spec/lib/remote_development/workspaces/update/update_processor_spec.rb \ +ee/spec/models/remote_development/remote_development_agent_config_spec.rb \ +ee/spec/models/remote_development/workspace_spec.rb \ +ee/spec/requests/api/graphql/mutations/remote_development/workspaces/create_spec.rb \ +ee/spec/requests/api/graphql/mutations/remote_development/workspaces/update_spec.rb \ +ee/spec/requests/api/graphql/remote_development/current_user_workspaces_spec.rb \ +ee/spec/requests/api/graphql/remote_development/workspaces_by_ids_spec.rb \ +ee/spec/requests/api/graphql/remote_development/workspace_by_id_spec.rb \ +ee/spec/requests/api/internal/kubernetes_spec.rb \ +ee/spec/services/remote_development/agent_config/update_service_spec.rb \ +ee/spec/services/remote_development/workspaces/create_service_spec.rb \ +ee/spec/services/remote_development/workspaces/reconcile_service_spec.rb \ +ee/spec/services/remote_development/workspaces/update_service_spec.rb \ +spec/graphql/types/subscription_type_spec.rb \ + +printf "\n✅✅✅ ${BGreen}All Remote Development specs passed successfully!${Color_Off} ✅✅✅\n" diff --git a/spec/tooling/danger/project_helper_spec.rb b/spec/tooling/danger/project_helper_spec.rb index 898c0ffa10c5d..3910f56940053 100644 --- a/spec/tooling/danger/project_helper_spec.rb +++ b/spec/tooling/danger/project_helper_spec.rb @@ -112,6 +112,7 @@ 'scripts/glfm/bar.rb' | [:backend] 'scripts/glfm/bar.js' | [:frontend] + 'scripts/remote_development/run-smoke-test-suite.sh' | [:remote_development] 'scripts/lib/glfm/bar.rb' | [:backend] 'scripts/lib/glfm/bar.js' | [:frontend] 'scripts/bar.rb' | [:backend, :tooling] diff --git a/tooling/danger/project_helper.rb b/tooling/danger/project_helper.rb index 5b5b998e3eaaf..9ab6c5fa32ebd 100644 --- a/tooling/danger/project_helper.rb +++ b/tooling/danger/project_helper.rb @@ -115,6 +115,7 @@ module ProjectHelper %r{\A((ee|jh)/)?scripts/(lib/)?glfm/.*\.rb} => [:backend], %r{\A((ee|jh)/)?scripts/(lib/)?glfm/.*\.js} => [:frontend], + %r{\A((ee|jh)/)?scripts/remote_development/.*} => [:remote_development], %r{\A((ee|jh)/)?scripts/.*\.rb} => [:backend, :tooling], %r{\A((ee|jh)/)?scripts/.*\.js} => [:frontend, :tooling], %r{\A((ee|jh)/)?scripts/} => :tooling, -- GitLab