summaryrefslogtreecommitdiff
path: root/qa/Rakefile
blob: 6bafec2a67dee5432a123c9af542e0d187d31e59 (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
require_relative 'qa/tools/revoke_all_personal_access_tokens'
require_relative 'qa/tools/delete_subgroups'
require_relative 'qa/tools/generate_perf_testdata'
require_relative 'qa/tools/delete_test_ssh_keys'
require_relative 'qa/tools/initialize_gitlab_auth'
require_relative 'qa/tools/delete_projects'

desc "Revokes all personal access tokens"
task :revoke_personal_access_tokens do
  QA::Tools::RevokeAllPersonalAccessTokens.new.run
end

desc "Deletes subgroups within a provided group"
task :delete_subgroups do
  QA::Tools::DeleteSubgroups.new.run
end

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

desc "Generate Performance Testdata"
task :generate_perf_testdata, :type do |t, 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 "\n#{urls_file} file is missing. Please provide correct URLS_FILE_PATH or all of HOST_URL, LARGE_ISSUE_URL and LARGE_MR_URL\n\n"
    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 |t, args|
  QA::Tools::DeleteTestSSHKeys.new(args).run
end

desc "Deletes projects directly under the provided group"
task :delete_projects do
  QA::Tools::DeleteProjects.new.run
end