Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-20 12:24:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-20 12:24:38 +0300
commit898e2cc1dfa88b4ac39cb4b35011f61b37f57b51 (patch)
treec6524edb6c9a43cccf93be05c36883fde1a53ee4 /qa
parentb5571e6e22cdacc81f78eff5943d68c8ba220fbb (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/Dockerfile6
-rw-r--r--qa/qa.rb1
-rw-r--r--qa/qa/page/project/operations/kubernetes/index.rb4
-rw-r--r--qa/qa/page/project/operations/kubernetes/show.rb22
-rw-r--r--qa/qa/runtime/application_settings.rb46
-rw-r--r--qa/qa/runtime/env.rb4
-rw-r--r--qa/qa/service/cluster_provider/k3d.rb3
-rw-r--r--qa/qa/service/kubernetes_cluster.rb4
-rw-r--r--qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb53
-rw-r--r--qa/spec/runtime/application_settings_spec.rb43
-rw-r--r--qa/spec/runtime/env_spec.rb14
11 files changed, 189 insertions, 11 deletions
diff --git a/qa/Dockerfile b/qa/Dockerfile
index e4b860b08b2..126d9fbc591 100644
--- a/qa/Dockerfile
+++ b/qa/Dockerfile
@@ -39,6 +39,12 @@ RUN wget -q https://chromedriver.storage.googleapis.com/$(wget -q -O - https://c
RUN unzip chromedriver_linux64.zip -d /usr/local/bin
##
+# Install K3d local cluster support
+# https://github.com/rancher/k3d
+#
+RUN curl -s https://raw.githubusercontent.com/rancher/k3d/master/install.sh | TAG=v1.3.4 bash
+
+##
# Install gcloud and kubectl CLI used in Auto DevOps test to create K8s
# clusters
#
diff --git a/qa/qa.rb b/qa/qa.rb
index 509de4af79c..1dcaa7f568e 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -37,6 +37,7 @@ module QA
autoload :MailHog, 'qa/runtime/mail_hog'
autoload :IPAddress, 'qa/runtime/ip_address'
autoload :Search, 'qa/runtime/search'
+ autoload :ApplicationSettings, 'qa/runtime/application_settings'
module API
autoload :Client, 'qa/runtime/api/client'
diff --git a/qa/qa/page/project/operations/kubernetes/index.rb b/qa/qa/page/project/operations/kubernetes/index.rb
index de54319596d..84b58e9ea5b 100644
--- a/qa/qa/page/project/operations/kubernetes/index.rb
+++ b/qa/qa/page/project/operations/kubernetes/index.rb
@@ -13,6 +13,10 @@ module QA
def add_kubernetes_cluster
click_on 'Add Kubernetes cluster'
end
+
+ def has_cluster?(cluster)
+ has_element?(:cluster, cluster_name: cluster.to_s)
+ end
end
end
end
diff --git a/qa/qa/page/project/operations/kubernetes/show.rb b/qa/qa/page/project/operations/kubernetes/show.rb
index fa276f15b8a..3d3eebdbec9 100644
--- a/qa/qa/page/project/operations/kubernetes/show.rb
+++ b/qa/qa/page/project/operations/kubernetes/show.rb
@@ -6,12 +6,6 @@ module QA
module Operations
module Kubernetes
class Show < Page::Base
- view 'app/assets/javascripts/clusters/components/application_row.vue' do
- element :application_row, 'js-cluster-application-row-${this.id}' # rubocop:disable QA/ElementWithPattern
- element :install_button, "__('Install')" # rubocop:disable QA/ElementWithPattern
- element :installed_button, "__('Installed')" # rubocop:disable QA/ElementWithPattern
- end
-
view 'app/assets/javascripts/clusters/components/applications.vue' do
element :ingress_ip_address, 'id="ingress-endpoint"' # rubocop:disable QA/ElementWithPattern
end
@@ -22,15 +16,21 @@ module QA
end
def install!(application_name)
- within(".js-cluster-application-row-#{application_name}") do
- page.has_button?('Install', wait: 30)
- click_on 'Install'
+ within_element(application_name) do
+ has_element?(:install_button, application: application_name, wait: 30)
+ click_on 'Install' # TODO replace with click_element
end
end
def await_installed(application_name)
- within(".js-cluster-application-row-#{application_name}") do
- page.has_text?(/Installed|Uninstall/, wait: 300)
+ within_element(application_name) do
+ has_element?(:uninstall_button, application: application_name, wait: 300)
+ end
+ end
+
+ def has_application_installed?(application_name)
+ within_element(application_name) do
+ has_element?(:uninstall_button, application: application_name, wait: 300)
end
end
diff --git a/qa/qa/runtime/application_settings.rb b/qa/qa/runtime/application_settings.rb
new file mode 100644
index 00000000000..df6323f9a48
--- /dev/null
+++ b/qa/qa/runtime/application_settings.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+module QA
+ module Runtime
+ module ApplicationSettings
+ extend self
+ extend Support::Api
+
+ APPLICATION_SETTINGS_PATH = '/application/settings'
+
+ # Set a GitLab application setting
+ # Example:
+ # #set({ allow_local_requests_from_web_hooks_and_services: true })
+ # #set(allow_local_requests_from_web_hooks_and_services: true)
+ # https://docs.gitlab.com/ee/api/settings.html
+ def set_application_settings(**application_settings)
+ QA::Runtime::Logger.info("Setting application settings: #{application_settings}")
+ r = put(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url, **application_settings)
+ raise "Couldn't set application settings #{application_settings.inspect}" unless r.code == QA::Support::Api::HTTP_STATUS_OK
+ end
+
+ def get_application_settings
+ parse_body(get(Runtime::API::Request.new(api_client, APPLICATION_SETTINGS_PATH).url))
+ end
+
+ private
+
+ def api_client
+ @api_client ||= begin
+ return Runtime::API::Client.new(:gitlab, personal_access_token: Runtime::Env.admin_personal_access_token) if Runtime::Env.admin_personal_access_token
+
+ user = Resource::User.fabricate_via_api! do |user|
+ user.username = Runtime::User.admin_username
+ user.password = Runtime::User.admin_password
+ end
+
+ unless user.admin?
+ raise "Administrator access is required to set application settings. User '#{user.username}' is not an administrator."
+ end
+
+ Runtime::API::Client.new(:gitlab, user: user)
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index 184ccd3ef07..6514e41e279 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -248,6 +248,10 @@ module QA
raise ArgumentError, "Please provide GITHUB_ACCESS_TOKEN"
end
+ def require_admin_access_token!
+ admin_personal_access_token || (raise ArgumentError, "GITLAB_QA_ADMIN_ACCESS_TOKEN is required!")
+ end
+
# Returns true if there is an environment variable that indicates that
# the feature is supported in the environment under test.
# All features are supported by default.
diff --git a/qa/qa/service/cluster_provider/k3d.rb b/qa/qa/service/cluster_provider/k3d.rb
index 8e117c2dbd5..fe02dde607c 100644
--- a/qa/qa/service/cluster_provider/k3d.rb
+++ b/qa/qa/service/cluster_provider/k3d.rb
@@ -6,6 +6,8 @@ module QA
class K3d < Base
def validate_dependencies
find_executable('k3d') || raise("You must first install `k3d` executable to run these tests.")
+ Runtime::Env.require_admin_access_token!
+ Runtime::ApplicationSettings.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
end
def set_credentials(admin_user)
@@ -24,6 +26,7 @@ module QA
def teardown
ENV['KUBECONFIG'] = @old_kubeconfig
shell "k3d delete --name #{cluster_name}"
+ Runtime::ApplicationSettings.set_application_settings(allow_local_requests_from_web_hooks_and_services: false)
end
# Fetch "real" certificate
diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb
index 26b5f58d2d3..84196556547 100644
--- a/qa/qa/service/kubernetes_cluster.rb
+++ b/qa/qa/service/kubernetes_cluster.rb
@@ -39,6 +39,10 @@ module QA
@provider.cluster_name
end
+ def to_s
+ cluster_name
+ end
+
private
def fetch_api_url
diff --git a/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb
new file mode 100644
index 00000000000..73b5a579e08
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/7_configure/kubernetes/kubernetes_integration_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+module QA
+ context 'Configure' do
+ # This test requires GITLAB_QA_ADMIN_ACCESS_TOKEN to be specified
+ describe 'Kubernetes Cluster Integration', :orchestrated, :kubernetes, :requires_admin, :skip do
+ context 'Project Clusters' do
+ let(:cluster) { Service::KubernetesCluster.new(provider_class: Service::ClusterProvider::K3d).create! }
+ let(:project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.name = 'project-with-k8s'
+ project.description = 'Project with Kubernetes cluster integration'
+ end
+ end
+
+ before do
+ Flow::Login.sign_in
+ end
+
+ after do
+ cluster.remove!
+ end
+
+ it 'can create and associate a project cluster', :smoke do
+ Resource::KubernetesCluster.fabricate_via_browser_ui! do |k8s_cluster|
+ k8s_cluster.project = project
+ k8s_cluster.cluster = cluster
+ end
+
+ project.visit!
+
+ Page::Project::Menu.perform(&:go_to_operations_kubernetes)
+
+ Page::Project::Operations::Kubernetes::Index.perform do |index|
+ expect(index).to have_cluster(cluster)
+ end
+ end
+
+ it 'installs helm and tiller on a gitlab managed app' do
+ Resource::KubernetesCluster.fabricate_via_browser_ui! do |k8s_cluster|
+ k8s_cluster.project = project
+ k8s_cluster.cluster = cluster
+ k8s_cluster.install_helm_tiller = true
+ end
+
+ Page::Project::Operations::Kubernetes::Show.perform do |show|
+ expect(show).to have_application_installed(:helm)
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/spec/runtime/application_settings_spec.rb b/qa/spec/runtime/application_settings_spec.rb
new file mode 100644
index 00000000000..fce0361aee0
--- /dev/null
+++ b/qa/spec/runtime/application_settings_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+describe QA::Runtime::ApplicationSettings do
+ let(:api_client) { double('QA::Runtime::API::Client') }
+ let(:request) { Struct.new(:url).new('http://api') }
+ let(:get_response) { Struct.new(:body).new("{}") }
+
+ before do
+ allow(described_class).to receive(:api_client).and_return(api_client)
+ end
+
+ describe '.set_application_settings' do
+ it 'sets application settings' do
+ expect(QA::Runtime::API::Request)
+ .to receive(:new)
+ .with(api_client, '/application/settings')
+ .and_return(request)
+
+ expect(described_class)
+ .to receive(:put)
+ .with(request.url, { allow_local_requests_from_web_hooks_and_services: true })
+ .and_return(Struct.new(:code).new(200))
+
+ subject.set_application_settings(allow_local_requests_from_web_hooks_and_services: true)
+ end
+ end
+
+ describe '.get_application_settings' do
+ it 'gets application settings' do
+ expect(QA::Runtime::API::Request)
+ .to receive(:new)
+ .with(api_client, '/application/settings')
+ .and_return(request)
+
+ expect(described_class)
+ .to receive(:get)
+ .with(request.url)
+ .and_return(get_response)
+
+ subject.get_application_settings
+ end
+ end
+end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index 340831aa06d..0a0bf33a726 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -230,6 +230,20 @@ describe QA::Runtime::Env do
end
end
+ describe '.require_admin_access_token!' do
+ it 'raises ArgumentError if GITLAB_QA_ADMIN_ACCESS_TOKEN is not specified' do
+ stub_env('GITLAB_QA_ADMIN_ACCESS_TOKEN', nil)
+
+ expect { described_class.require_admin_access_token! }.to raise_error(ArgumentError)
+ end
+
+ it 'does not raise exception if GITLAB_QA_ADMIN_ACCESS_TOKEN is specified' do
+ stub_env('GITLAB_QA_ADMIN_ACCESS_TOKEN', 'foobar123')
+
+ expect { described_class.require_admin_access_token! }.not_to raise_error
+ end
+ end
+
describe '.log_destination' do
it 'returns $stdout if QA_LOG_PATH is not defined' do
stub_env('QA_LOG_PATH', nil)