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

Rakefile « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d8b5d6d08d6eedabb96814f9df95bd5b7b2b6b17 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# frozen_string_literal: true

require_relative "qa"

Dir['tasks/*.rake'].each { |file| load file }

desc "Deletes subgroups within a provided group"
task :delete_subgroups, [:delete_before] do |_, args|
  args.with_defaults(delete_before: (Date.today - 3).to_s)
  QA::Tools::DeleteSubgroups.new(delete_before: args[:delete_before]).run
end

desc "Initialize GitLab with an access token"
task :initialize_gitlab_auth, [:address] do |_, args|
  QA::Tools::InitializeGitlabAuth.new(args).run
end

desc "Generate Performance Testdata"
task :generate_perf_testdata, :type do |_, args|
  args.with_defaults(type: :all)
  QA::Tools::GeneratePerfTestdata.new.method(args[:type]).call
end

desc "Run artillery load tests"
task :run_artillery_load_tests do
  unless ENV['HOST_URL'] && ENV['LARGE_ISSUE_URL'] && ENV['LARGE_MR_URL']
    urls_file = ENV['URLS_FILE_PATH'] || 'urls.yml'

    unless File.exist?(urls_file)
      raise(<<~ERR)
        #{urls_file} file is missing. Please provide correct URLS_FILE_PATH or all of HOST_URL, LARGE_ISSUE_URL and LARGE_MR_URL\n
      ERR
    end

    urls = YAML.safe_load(File.read(urls_file))
    ENV['HOST_URL'] = urls["host"]
    ENV['LARGE_ISSUE_URL'] = urls["large_issue"]
    ENV['LARGE_MR_URL'] = urls["large_mr"]
  end

  sh('artillery run load/artillery.yml -o report.json')
  sh('artillery report report.json -o report.html && rm report.json')
end

desc "Generate data and run load tests"
task generate_data_and_run_load_test: [:generate_perf_testdata, :run_artillery_load_tests]

desc "Deletes test ssh keys a user"
task :delete_test_ssh_keys, [:title_portion, :delete_before, :dry_run] do |_, args|
  QA::Tools::DeleteTestSshKeys.new(args).run
end

desc "Deletes projects directly under the provided group"
task :delete_projects, [:delete_before] do |_, args|
  args.with_defaults(delete_before: (Date.today - 3).to_s)
  QA::Tools::DeleteProjects.new(delete_before: args[:delete_before]).run
end

desc "Deletes test users"
task :delete_test_users, [:delete_before, :dry_run, :exclude_users] do |_, args|
  QA::Tools::DeleteTestUsers.new(args).run
end

desc "Deletes snippets"
task :delete_test_snippets, [:delete_before, :dry_run] do |_, args|
  QA::Tools::DeleteTestSnippets.new(args).run
end

namespace :test_resources do
  desc "Deletes resources created during E2E test runs"
  task :delete, [:file_pattern] do |_, args|
    QA::Tools::TestResourcesHandler.new(args[:file_pattern]).run_delete
  end

  desc "Upload test resources JSON files to GCS"
  task :upload, [:file_pattern, :ci_project_name] do |_, args|
    QA::Tools::TestResourcesHandler.new(args[:file_pattern]).upload(args[:ci_project_name])
  end

  desc "Download test resources JSON files from GCS"
  task :download, [:ci_project_name] do |_, args|
    QA::Tools::TestResourcesHandler.new.download(args[:ci_project_name])
  end
end

desc "Deletes user's projects"
task :delete_user_projects, [:delete_before, :dry_run] do |_, args|
  args.with_defaults(delete_before: (Date.today - 3).to_s, dry_run: false)
  QA::Tools::DeleteUserProjects.new(
    delete_before: args[:delete_before],
    dry_run: !!(args[:dry_run] =~ /true|1|y/i)).run
end

desc "Revokes user's personal access tokens"
task :revoke_user_pats, [:revoke_before, :dry_run] do |_, args|
  QA::Tools::RevokeUserPersonalAccessTokens.new(args).run
end

desc "Generate group with multiple projects for direct transfer test"
task :generate_direct_transfer_test_group, [:project_tar_paths, :group_path, :project_copies] do |_, args|
  QA::Support::GitlabAddress.define_gitlab_address_attribute!
  QA::Runtime::Browser.configure!
  QA::Runtime::Scenario.from_env(QA::Runtime::Env.runtime_scenario_attributes)

  numeric_args = { project_copies: Integer(args[:project_copies], exception: false) }.compact
  string_args = args.to_h
    .slice(:project_tar_paths, :group_path)
    .compact_blank

  QA::Tools::GenerateImportTestGroup.new(**string_args, **numeric_args).generate
end