1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# frozen_string_literal: true
module QA
RSpec.describe 'Verify', :runner, product_group: :pipeline_security do
describe 'Project artifacts' do
context 'when user tries bulk deletion' do
let(:total_jobs_count) { 20 }
let(:total_runners_count) { 5 }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" }
let(:project) { create(:project, name: 'project-with-many-artifacts') }
let(:runners) { [] }
before do
launch_runners
commit_ci_file
Flow::Login.sign_in
wait_for_pipeline_to_succeed
project.visit!
Page::Project::Menu.perform(&:go_to_artifacts)
Page::Project::Artifacts::Index.perform(&:select_all)
end
after do
Parallel.each((0..(total_runners_count - 1)), in_threads: 3) do |i|
runners[i]&.remove_via_api!
end
end
it 'successfully delete them', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/425725' do
Page::Project::Artifacts::Index.perform do |index|
index.delete_selected_artifacts
position = rand(1..20)
artifacts_count = index.job_artifacts_count_by_row(row: position)
artifacts_size = index.job_artifacts_size_by_row(row: position)
aggregate_failures 'job artifacts count and size' do
expect(artifacts_count).to eq(0), 'Failed to delete artifact'
expect(artifacts_size).to eq(0), 'Failed to delete artifact'
end
end
end
end
private
def launch_runners
Parallel.each((1..total_runners_count), in_threads: 3) do |i|
runners << create(:project_runner, project: project, name: "#{executor}-#{i}", tags: [executor])
end
end
def commit_ci_file
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: content
}
]
)
end
end
def content
(1..total_jobs_count).map do |i|
<<~YAML
job_with_artifact_#{i}:
tags: ["#{executor}"]
script:
- mkdir tmp
- echo "write some random strings #{i} times" >> tmp/file_#{i}.xml
artifacts:
paths:
- tmp
YAML
end.join("\n")
end
def wait_for_pipeline_to_succeed
Support::Waiter.wait_until(message: 'Wait for pipeline to succeed', max_duration: 300) do
project.latest_pipeline.present? && project.latest_pipeline[:status] == 'success'
end
end
end
end
end
|