diff --git a/qa/Dockerfile b/qa/Dockerfile index b83677f7de72994b49e6d03f91a78ab1c04868ab..08134c667865e88368dac0dd3a7547d3fb18ed2c 100644 --- a/qa/Dockerfile +++ b/qa/Dockerfile @@ -21,7 +21,7 @@ ENV BUNDLE_APP_CONFIG=/home/gitlab/.bundle # Install system libs # RUN apt-get update \ - && apt-get install -y xvfb unzip \ + && apt-get install -y xvfb unzip google-cloud-sdk-gke-gcloud-auth-plugin \ && apt-get -yq autoremove \ && apt-get clean -yqq \ && rm -rf /var/lib/apt/lists/* diff --git a/qa/qa/ee/page/group/settings/workspaces.rb b/qa/qa/ee/page/group/settings/workspaces.rb new file mode 100644 index 0000000000000000000000000000000000000000..2d30babf4c32fcd7f247dc8085136971451df693 --- /dev/null +++ b/qa/qa/ee/page/group/settings/workspaces.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module QA + module EE + module Page + module Group + module Settings + class Workspaces < QA::Page::Base + view 'ee/app/assets/javascripts/workspaces/agent_mapping/components/agent_mapping_status_toggle.vue' do + element 'agent-mapping-status-toggle' + end + + def allow_agent + click_link 'All agents' + + return unless has_element?('agent-mapping-status-toggle', text: 'Allow', wait: 3) + + click_element('agent-mapping-status-toggle') + click_button 'Allow agent' + end + end + end + end + end + end +end diff --git a/qa/qa/ee/page/workspace/action.rb b/qa/qa/ee/page/workspace/action.rb index c11516dd3faadd858a92f7c5afe925f9e8ddc7fd..42452fa32fcda162cc1552fe7941b5d92a1762b9 100644 --- a/qa/qa/ee/page/workspace/action.rb +++ b/qa/qa/ee/page/workspace/action.rb @@ -16,7 +16,6 @@ class Action < QA::Page::Base def click_workspace_action(workspace, action) within_element("#{workspace}-action".to_sym, skip_finished_loading_check: true) do click_element("workspace-#{action}-button", skip_finished_loading_check: true) - Support::WaitForRequests.wait_for_requests(skip_finished_loading_check: false, finish_loading_wait: 180) end end end diff --git a/qa/qa/ee/page/workspace/list.rb b/qa/qa/ee/page/workspace/list.rb index a3fb895e0283b3326cb951f72ef6c706f272e151..aeea73087d753bb039f7c465f8226d64d98b0a2d 100644 --- a/qa/qa/ee/page/workspace/list.rb +++ b/qa/qa/ee/page/workspace/list.rb @@ -22,7 +22,7 @@ class List < QA::Page::Base end def has_empty_workspace? - has_element?('new-workspace-button') + has_element?('new-workspace-button', skip_finished_loading_check: true) end def create_workspace(agent, project) @@ -71,9 +71,7 @@ def wait_for_workspaces_creation(workspace) def has_workspace_state?(workspace, state) within_element(workspace.to_s.to_sym, skip_finished_loading_check: true) do - Support::Retrier.retry_until(sleep_interval: 5, max_attempts: 10) do - has_element?('workspace-state-indicator', title: state) - end + has_element?('workspace-state-indicator', title: state, skip_finished_loading_check: true, wait: 360) end end end diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb index 106e09915747999d1cb409f96750bdcec78fa7cf..f1e5fb8778242357862efd20a997232dae426e3d 100644 --- a/qa/qa/page/main/menu.rb +++ b/qa/qa/page/main/menu.rb @@ -18,6 +18,10 @@ class Menu < Page::Base element 'canary-badge-link' end + view 'app/assets/javascripts/super_sidebar/components/brand_logo.vue' do + element 'brand-header-default-logo' + end + view 'app/assets/javascripts/super_sidebar/components/user_menu.vue' do element 'user-dropdown', required: !Runtime::Env.phone_layout? element 'user-avatar-content', required: !Runtime::Env.phone_layout? @@ -63,7 +67,8 @@ def go_to_snippets end def go_to_workspaces - click_element('nav-item-link', submenu_item: 'Workspaces') + # skip_finished_loading_check in case there are workspaces currently being terminated + click_element('nav-item-link', submenu_item: 'Workspaces', skip_finished_loading_check: true) end def go_to_menu_dropdown_option(option_name) @@ -74,6 +79,10 @@ def go_to_todos click_element('todos-shortcut-button') end + def go_to_homepage + click_element('brand-header-default-logo') + end + def signed_in? return false if Page::Main::Login.perform(&:on_login_page?) diff --git a/qa/qa/page/sub_menus/settings.rb b/qa/qa/page/sub_menus/settings.rb index ff5d27a9ec0afe0235efb1d889eb06b8571bf43e..aa45e4e1b091e027685ddf1dc7446a74e895aff5 100644 --- a/qa/qa/page/sub_menus/settings.rb +++ b/qa/qa/page/sub_menus/settings.rb @@ -34,6 +34,10 @@ def go_to_package_settings open_settings_submenu('Packages and registries') end + def go_to_workspaces_settings + open_settings_submenu('Workspaces') + end + private def open_settings_submenu(sub_menu) diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb index 876aab9c54b2646a37025012933a8c1a509581c5..ae9c000643bdffb1aab2ef2c57d12b2b78b5d0a2 100644 --- a/qa/qa/runtime/env.rb +++ b/qa/qa/runtime/env.rb @@ -485,6 +485,10 @@ def workspaces_oauth_signing_key ENV.fetch("WORKSPACES_OAUTH_SIGNING_KEY") end + def workspaces_proxy_version + ENV.fetch("WORKSPACES_PROXY_VERSION", '0.1.12') + end + def workspaces_proxy_domain ENV.fetch("WORKSPACES_PROXY_DOMAIN") end @@ -571,7 +575,7 @@ def geo_environment? end def gitlab_agentk_version - ENV.fetch('GITLAB_AGENTK_VERSION', 'v16.10.0') + ENV.fetch('GITLAB_AGENTK_VERSION', 'latest') end def transient_trials diff --git a/qa/qa/service/cluster_provider/gcloud.rb b/qa/qa/service/cluster_provider/gcloud.rb index bf13ab68eb7402f9c47c9153391dd3adbb61c155..8b2258d705ddb388bd820b5101650020969a6599 100644 --- a/qa/qa/service/cluster_provider/gcloud.rb +++ b/qa/qa/service/cluster_provider/gcloud.rb @@ -27,7 +27,6 @@ def initialize(rbac:) def setup login_if_not_already_logged_in create_cluster - install_helm end def teardown @@ -79,6 +78,16 @@ def install_ngnix_ingress CMD end + def wait_for_pod(namespace) + shell <<~CMD.tr("\n", ' ') + kubectl wait pod \ + --all \ + --for=condition=Ready \ + --namespace=#{namespace} \ + --timeout=300s + CMD + end + def install_gitlab_workspaces_proxy cmd_str = <<~CMD.tr("\n", ' ') helm repo add gitlab-workspaces-proxy \ @@ -86,7 +95,7 @@ def install_gitlab_workspaces_proxy helm repo update && helm upgrade --install gitlab-workspaces-proxy \ gitlab-workspaces-proxy/gitlab-workspaces-proxy \ - --version 0.1.12 \ + --version #{Runtime::Env.workspaces_proxy_version} \ --namespace=gitlab-workspaces \ --create-namespace \ --set="auth.client_id=#{Runtime::Env.workspaces_oauth_app_id}" \ @@ -126,14 +135,6 @@ def update_dns(load_balancer_ip) private - def install_helm - shell <<~CMD.tr("\n", ' ') - curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && - chmod 700 get_helm.sh && - DESIRED_VERSION=v3.14.0 ./get_helm.sh - CMD - end - def target_canary? Runtime::Env.qa_cookies.to_s.include?("gitlab_canary=true") end diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb index d1cabc58f76651fc09f3a2c06e45720ac93dd0cf..4a82ad7c45b6f9abe375023c0a62e175e22d4d4b 100644 --- a/qa/qa/service/kubernetes_cluster.rb +++ b/qa/qa/service/kubernetes_cluster.rb @@ -56,6 +56,7 @@ def uninstall_kubernetes_agent(agent_name) def setup_workspaces_in_cluster @provider.install_ngnix_ingress + @provider.wait_for_pod('ingress-nginx') @provider.install_gitlab_workspaces_proxy end diff --git a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/with_prerequisite_done/workspace_actions_with_prerequisite_done_spec.rb b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/with_prerequisite_done/workspace_actions_with_prerequisite_done_spec.rb index 929303920547beac2c556c397a471ecb64b129b1..2bc0f35176f7bb99e5d686ae8644cc3d98973a02 100644 --- a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/with_prerequisite_done/workspace_actions_with_prerequisite_done_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/with_prerequisite_done/workspace_actions_with_prerequisite_done_spec.rb @@ -2,21 +2,27 @@ # What does this test do # -# This is an e2e test that doesnt manage / orchestrate KAS / agentk / gitlab but expects them to be up and running. -# This test is currently quarantined and its used for local testing by the engineers -# This can be removed in the future when we have a better approach for local testing +# This is an e2e test that does not manage / orchestrate KAS / agentk / gitlab but expects them to be up and running. +# This test is currently quarantined and is used for local testing only. This can be removed in the future when we +# have a better approach for local testing. It can also be executed against an arbitrary environment with the +# necessary pre-requisites completed. # -# How to setup the test +# How to setup the test: # # 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. (It can also be -# run against other environments if the setup for remote dev agent and devfile project has been setup already) -# 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: +# 2. Ensure that a group exists with a project (default name: `devfile-project` or use DEVFILE_PROJECT to overwrite) +# 3. Ensure that an agent exists for the project (default name: `remotedev` or use AGENT_NAME to overwrite) +# 4. Ensure that the agent is enabled by clicking `Allow` from the Workspaces group settings +# 6. Ensure that you can successfully create and terminate workspaces +# 7. Run the script `scripts/remote_development/run-e2e-tests.sh` # -# DEVFILE_PROJECT="devfile-test-project" AGENT_NAME="test-agent" scripts/remote_development/run-e2e-tests.sh +# Note 1: Default values can be overridden from the command line, for example: +# DEVFILE_PROJECT="devfile-test-project" AGENT_NAME="test-agent" scripts/remote_development/run-e2e-tests.sh +# +# Note 2: You can significantly speed up the test by providing a token with admin API access, which allows the test to +# use the API to create a token, rather than the browser: +# GITLAB_QA_ADMIN_ACCESS_TOKEN=abcde12345 scripts/remote_development/run-e2e-tests.sh module QA RSpec.describe 'Create', diff --git a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/workspace_actions_spec.rb b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/workspace_actions_spec.rb index 9999a6ddcbccc569c3086adb2a27854ed65ae081..2e8777337636b84adebc5979a88ca27b6e530960 100644 --- a/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/workspace_actions_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/3_create/remote_development/workspace_actions_spec.rb @@ -1,32 +1,24 @@ # frozen_string_literal: true -# What does this test do -# # This is an e2e test that sets up the entire workspaces environment from scratch as mentioned in this documentation # https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/-/blob/main/doc/local-development-environment-setup.md -# This test creates project, devfile, agents and workspaces on the fly -# The other test ee/browser_ui/3_create/remote_development/with_prerequisite_done/ -# workspace_actions_with_prerequisite_done_spec.rb is used for local testing and requires an existing agent and -# devfile project +# This test creates a project, devfile, agent and workspace. It enables the agent via the Workspaces settings. +# For local testing where the pre-requisites have already been met please use the following test: +# `ee/browser_ui/3_create/remote_development/with_prerequisite_done/workspace_actions_with_prerequisite_done_spec.rb` # -# How to run the test +# How to run the test locally against staging: +# 1. The following pre-requisites are required to be installed: +# - gcloud CLI https://cloud.google.com/sdk/docs/install +# - google-cloud-sdk-gke-gcloud-auth-plugin `gcloud components install gke-gcloud-auth-plugin` +# - Helm https://helm.sh/docs/intro/install/ # -# 1. Run the test against staging environment -# The full list of env variable and their values to run this test can be found in 1password "Run workspaces tests -# against staging" +# 2. To run the test against staging environment, use the full list of environment variables which can be found in +# 1password under "Run workspaces tests against staging" and run: # bundle exec bin/qa Test::Instance::All https://staging.gitlab.com -- -- qa/specs/features/ee/browser_ui/3_create # /remote_development/workspace_actions_spec.rb -# 2. When the test is run locally, it will try to install helm (requires local password) and if unnoticed the script -# would fail eventually. To overcome this, install helm manually using the installation steps in -# https://gitlab.com/gitlab-org/gitlab/-/blob/6bb010046a9f8922f827eb035d05e28954352311/qa/qa/service/cluster_provider/gcloud.rb#L129-135 -# then run the test using step 1 module QA - RSpec.describe 'Create', only: { pipeline: %i[staging staging-canary] }, product_group: :remote_development, - quarantine: { - type: :broken, - issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/463416' - } do + RSpec.describe 'Create', only: { pipeline: %i[staging staging-canary] }, product_group: :remote_development do describe 'Remote Development' do include Runtime::Fixtures @@ -76,6 +68,10 @@ module QA cluster.install_kubernetes_agent(agent_token.token, kubernetes_agent.name) cluster.update_dns_with_load_balancer_ip Flow::Login.sign_in + + parent_group.visit! + Page::Group::Menu.perform(&:go_to_workspaces_settings) + EE::Page::Group::Settings::Workspaces.perform(&:allow_agent) end after do diff --git a/qa/qa/specs/features/shared_examples/create_and_terminate_workspace_shared_examples.rb b/qa/qa/specs/features/shared_examples/create_and_terminate_workspace_shared_examples.rb index b4313e3873f25fa7ea2e8841436a431573bd5311..33505bf10b2d8f640916b46f55f6974728d967a5 100644 --- a/qa/qa/specs/features/shared_examples/create_and_terminate_workspace_shared_examples.rb +++ b/qa/qa/specs/features/shared_examples/create_and_terminate_workspace_shared_examples.rb @@ -3,6 +3,7 @@ module QA RSpec.shared_examples 'workspaces actions' do it 'creates a new workspace and then stops and terminates it' do + QA::Page::Main::Menu.perform(&:go_to_homepage) QA::Page::Main::Menu.perform(&:go_to_workspaces) workspace_name = "" @@ -10,7 +11,6 @@ module QA workspace_name = list.create_workspace(kubernetes_agent.name, devfile_project.name) expect(list).to have_workspace_state(workspace_name, "Creating") - list.wait_for_workspaces_creation(workspace_name) expect(list).to have_workspace_state(workspace_name, "Running") end @@ -18,17 +18,21 @@ module QA workspace.click_workspace_action(workspace_name, "stop") end - QA::EE::Page::Workspace::List.perform do |list_item| - expect(list_item).to have_workspace_state(workspace_name, "Stopped") + QA::EE::Page::Workspace::List.perform do |list| + expect(list).to have_workspace_state(workspace_name, "Stopped") end QA::EE::Page::Workspace::Action.perform do |workspace| workspace.click_workspace_action(workspace_name, "terminate") end - QA::EE::Page::Workspace::List.perform do |list_item| - list_item.click_terminated_tab - expect(list_item).to have_workspace_state(workspace_name, "Terminated") + QA::EE::Page::Workspace::List.perform do |list| + # Check workspace not present on Active tab + expect { list.get_workspaces_list }.not_to eventually_include(workspace_name).within(max_duration: 60) + + # Check workspace is present on Terminated tab + list.click_terminated_tab + expect(list).to have_workspace_state(workspace_name, "Terminated") end end end