Skip to content
代码片段 群组 项目
未验证 提交 aaf864ab 编辑于 作者: Jay McCure's avatar Jay McCure 提交者: GitLab
浏览文件

E2E test: Fix and enable workspaces e2e test

上级 17539e61
No related branches found
No related tags found
无相关合并请求
显示 101 个添加53 个删除
......@@ -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/*
......
# 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
......@@ -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
......
......@@ -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
......
......@@ -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?)
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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',
......
# 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
......
......@@ -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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册