Commit 0abb9109 authored by Dan Davison's avatar Dan Davison Committed by Mark Lapierre

Refactor autodevops test

Favor let over instance variables
Fabricate project via api rather than browser ui
Enable autodevops from project
Remove variable shadow (whoops)

Refactor AutoDevOps QA spec

Use single let for fabrication of projects
for each example.  Disable all optional jobs for
full-run and smoke-run.  Use new quarantine
process to specify issue.
Make disable_optional_jobs private

Fix rubocop issue around before

Refactor disable_optional_jobs
parent 063ede42
...@@ -4,93 +4,49 @@ require 'pathname' ...@@ -4,93 +4,49 @@ require 'pathname'
module QA module QA
context 'Configure' do context 'Configure' do
def disable_optional_jobs(project) let(:project) do
# Disable code_quality check in Auto DevOps pipeline as it takes Resource::Project.fabricate_via_api! do |p|
# too long and times out the test p.name = Runtime::Env.auto_devops_project_name || 'autodevops-project'
Resource::CiVariable.fabricate_via_api! do |resource| p.auto_devops_enabled = true
resource.project = project
resource.key = 'CODE_QUALITY_DISABLED'
resource.value = '1'
resource.masked = false
end
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = project
resource.key = 'LICENSE_MANAGEMENT_DISABLED'
resource.value = '1'
resource.masked = false
end
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = project
resource.key = 'SAST_DISABLED'
resource.value = '1'
resource.masked = false
end
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = project
resource.key = 'DEPENDENCY_SCANNING_DISABLED'
resource.value = '1'
resource.masked = false
end
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = project
resource.key = 'CONTAINER_SCANNING_DISABLED'
resource.value = '1'
resource.masked = false
end end
end
Resource::CiVariable.fabricate_via_api! do |resource| before do
resource.project = project disable_optional_jobs(project)
resource.key = 'DAST_DISABLED'
resource.value = '1'
resource.masked = false
end
end end
describe 'Auto DevOps support', :orchestrated, :kubernetes, quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/118481' do describe 'Auto DevOps support', :orchestrated, :kubernetes, quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/118481' do
context 'when rbac is enabled' do context 'when rbac is enabled' do
before(:all) do let(:cluster) { Service::KubernetesCluster.new.create! }
@cluster = Service::KubernetesCluster.new.create!
end
after(:all) do after do
@cluster&.remove! cluster&.remove!
end end
it 'runs auto devops' do it 'runs auto devops' do
Flow::Login.sign_in Flow::Login.sign_in
@project = Resource::Project.fabricate! do |p|
p.name = Runtime::Env.auto_devops_project_name || 'project-with-autodevops'
p.description = 'Project with Auto DevOps'
end
disable_optional_jobs(@project)
# Set an application secret CI variable (prefixed with K8S_SECRET_) # Set an application secret CI variable (prefixed with K8S_SECRET_)
Resource::CiVariable.fabricate! do |resource| Resource::CiVariable.fabricate! do |resource|
resource.project = @project resource.project = project
resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE' resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE'
resource.value = 'you_can_see_this_variable' resource.value = 'you_can_see_this_variable'
resource.masked = false resource.masked = false
end end
# Connect K8s cluster # Connect K8s cluster
Resource::KubernetesCluster.fabricate! do |cluster| Resource::KubernetesCluster.fabricate! do |k8s_cluster|
cluster.project = @project k8s_cluster.project = project
cluster.cluster = @cluster k8s_cluster.cluster = cluster
cluster.install_helm_tiller = true k8s_cluster.install_helm_tiller = true
cluster.install_ingress = true k8s_cluster.install_ingress = true
cluster.install_prometheus = true k8s_cluster.install_prometheus = true
cluster.install_runner = true k8s_cluster.install_runner = true
end end
# Create Auto DevOps compatible repo # Create Auto DevOps compatible repo
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
push.project = @project push.project = project
push.directory = Pathname push.directory = Pathname
.new(__dir__) .new(__dir__)
.join('../../../../../fixtures/auto_devops_rack') .join('../../../../../fixtures/auto_devops_rack')
...@@ -145,20 +101,15 @@ module QA ...@@ -145,20 +101,15 @@ module QA
before do before do
Flow::Login.sign_in Flow::Login.sign_in
@project = Resource::Project.fabricate_via_browser_ui! do |p| project.visit!
p.name = "project-with-autodevops-#{SecureRandom.hex(8)}"
p.description = 'Project with AutoDevOps'
end
Page::Project::Menu.perform(&:go_to_ci_cd_settings) Page::Project::Menu.perform(&:go_to_ci_cd_settings)
Page::Project::Settings::CICD.perform(&:expand_auto_devops) Page::Project::Settings::CICD.perform(&:expand_auto_devops)
Page::Project::Settings::AutoDevops.perform(&:enable_autodevops) Page::Project::Settings::AutoDevops.perform(&:enable_autodevops)
@project.visit!
# Create AutoDevOps repo # Create AutoDevOps repo
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
push.project = @project push.project = project
push.directory = Pathname push.directory = Pathname
.new(__dir__) .new(__dir__)
.join('../../../../../fixtures/auto_devops_rack') .join('../../../../../fixtures/auto_devops_rack')
...@@ -175,5 +126,22 @@ module QA ...@@ -175,5 +126,22 @@ module QA
end end
end end
end end
private
def disable_optional_jobs(project)
%w[
CODE_QUALITY_DISABLED LICENSE_MANAGEMENT_DISABLED
SAST_DISABLED DAST_DISABLED DEPENDENCY_SCANNING_DISABLED
CONTAINER_SCANNING_DISABLED
].each do |key|
Resource::CiVariable.fabricate_via_api! do |resource|
resource.project = project
resource.key = key
resource.value = '1'
resource.masked = false
end
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment