Commit 269db476 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'test-registry-with-3-docker-clients' into 'master'

Add 3 latest docker versions on Container Registry test

See merge request gitlab-org/gitlab!75411
parents 8505e459 6a96f130
...@@ -48,84 +48,87 @@ module QA ...@@ -48,84 +48,87 @@ module QA
project.remove_via_api! project.remove_via_api!
end end
where(:authentication_token_type, :token_name) do context "when tls is disabled" do
:personal_access_token | 'Personal Access Token' where(:authentication_token_type, :token_name) do
:project_deploy_token | 'Deploy Token' :personal_access_token | 'Personal Access Token'
:ci_job_token | 'Job Token' :project_deploy_token | 'Deploy Token'
end :ci_job_token | 'Job Token'
with_them do
let(:auth_token) do
case authentication_token_type
when :personal_access_token
"\"#{personal_access_token}\""
when :project_deploy_token
"\"#{project_deploy_token.token}\""
when :ci_job_token
'$CI_JOB_TOKEN'
end
end end
let(:auth_user) do with_them do
case authentication_token_type let(:auth_token) do
when :personal_access_token case authentication_token_type
"$CI_REGISTRY_USER" when :personal_access_token
when :project_deploy_token "\"#{personal_access_token}\""
"\"#{project_deploy_token.username}\"" when :project_deploy_token
when :ci_job_token "\"#{project_deploy_token.token}\""
'gitlab-ci-token' when :ci_job_token
'$CI_JOB_TOKEN'
end
end end
end
context "when tls is disabled" do let(:auth_user) do
it "using a #{params[:token_name]}, pushes image and deletes tag", :registry do case authentication_token_type
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do when :personal_access_token
Resource::Repository::Commit.fabricate_via_api! do |commit| "$CI_REGISTRY_USER"
commit.project = project when :project_deploy_token
commit.commit_message = 'Add .gitlab-ci.yml' "\"#{project_deploy_token.username}\""
commit.add_files([{ when :ci_job_token
file_path: '.gitlab-ci.yml', 'gitlab-ci-token'
content:
<<~YAML
build:
image: docker:19.03.12
stage: build
services:
- name: docker:19.03.12-dind
command: ["--insecure-registry=gitlab.test:5050"]
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
tags:
- "runner-for-#{project.name}"
YAML
}])
end
end end
end
Flow::Pipeline.visit_latest_pipeline where(:docker_client_version) do
%w[docker:18.09.9 docker:19.03.12 docker:20.10]
end
Page::Project::Pipeline::Show.perform do |pipeline| with_them do
pipeline.click_job('build') it "pushes image and deletes tag", :registry do
end Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([{
file_path: '.gitlab-ci.yml',
content:
<<~YAML
build:
image: "#{docker_client_version}"
stage: build
services:
- name: "#{docker_client_version}-dind"
command: ["--insecure-registry=gitlab.test:5050"]
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
tags:
- "runner-for-#{project.name}"
YAML
}])
end
end
Page::Project::Job::Show.perform do |job| Flow::Pipeline.visit_latest_pipeline
expect(job).to be_successful(timeout: 800)
end
Page::Project::Menu.perform(&:go_to_container_registry) Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('build')
end
Page::Project::Registry::Show.perform do |registry| Page::Project::Job::Show.perform do |job|
expect(registry).to have_registry_repository(project.path_with_namespace) expect(job).to be_successful(timeout: 800)
end
Page::Project::Menu.perform(&:go_to_container_registry)
registry.click_on_image(project.path_with_namespace) Page::Project::Registry::Show.perform do |registry|
expect(registry).to have_tag('master') expect(registry).to have_registry_repository(project.path_with_namespace)
registry.click_delete registry.click_on_image(project.path_with_namespace)
expect(registry).not_to have_tag('master') expect(registry).to have_tag('master')
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