simp-rake-helpers 5.9.1 → 5.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/lib/simp/ci/gitlab.rb +226 -0
  4. data/lib/simp/rake/ci.rb +31 -0
  5. data/lib/simp/rake/helpers/version.rb +1 -1
  6. data/lib/simp/rake/pupmod/helpers.rb +3 -0
  7. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/default.yml +41 -0
  8. data/spec/lib/simp/ci/files/global_nodesets_only/spec/acceptance/nodesets/oel.yml +41 -0
  9. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/centos.yml +41 -0
  10. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/nodesets/oel.yml +41 -0
  11. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  12. data/spec/lib/simp/ci/files/job_broken_link_nodeset/spec/acceptance/suites/default/nodesets +1 -0
  13. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/default.yml +41 -0
  14. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/nodesets/oel.yml +41 -0
  15. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  16. data/spec/lib/simp/ci/files/job_invalid_nodeset/spec/acceptance/suites/default/nodesets +1 -0
  17. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/default.yml +41 -0
  18. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/nodesets/oel.yml +41 -0
  19. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/class_spec.rb +0 -0
  20. data/spec/lib/simp/ci/files/job_invalid_suite/spec/acceptance/suites/default/nodesets +1 -0
  21. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/default.yml +41 -0
  22. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/nodesets/oel.yml +41 -0
  23. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  24. data/spec/lib/simp/ci/files/job_missing_nodeset/spec/acceptance/suites/default/nodesets +1 -0
  25. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/default.yml +41 -0
  26. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/nodesets/oel.yml +41 -0
  27. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  28. data/spec/lib/simp/ci/files/job_missing_suite_and_nodeset/spec/acceptance/suites/default/nodesets +1 -0
  29. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/default.yml +41 -0
  30. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/nodesets/oel.yml +41 -0
  31. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  32. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/default/nodesets +1 -0
  33. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  34. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  35. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +35 -0
  36. data/spec/lib/simp/ci/files/multiple_invalid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +35 -0
  37. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/default.yml +41 -0
  38. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/nodesets/oel.yml +41 -0
  39. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/class_spec.rb +0 -0
  40. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/default/nodesets +1 -0
  41. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature-1/feature-1_spec.rb +0 -0
  42. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/feature_2_spec.rb +0 -0
  43. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/default.yml +35 -0
  44. data/spec/lib/simp/ci/files/multiple_valid_jobs/spec/acceptance/suites/feature_2/nodesets/oel.yml +35 -0
  45. data/spec/lib/simp/ci/files/no_acceptance_tests/spec/spec_helper.rb +0 -0
  46. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/default.yml +41 -0
  47. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/nodesets/oel.yml +41 -0
  48. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/class_spec.rb +0 -0
  49. data/spec/lib/simp/ci/files/no_gitlab_config_with_tests/spec/acceptance/suites/default/nodesets +1 -0
  50. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/default.yml +41 -0
  51. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/nodesets/oel.yml +41 -0
  52. data/spec/lib/simp/ci/files/no_gitlab_config_without_tests/spec/acceptance/suites/default/nodesets +1 -0
  53. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml +41 -0
  54. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/default.yml +1 -0
  55. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/oel.yml +41 -0
  56. data/spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/suites/default/nodesets +1 -0
  57. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/default.yml +41 -0
  58. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/nodesets/oel.yml +41 -0
  59. data/spec/lib/simp/ci/files/valid_job_global_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  60. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/default.yml +41 -0
  61. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/nodesets/oel.yml +41 -0
  62. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  63. data/spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/nodesets +1 -0
  64. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/class_spec.rb +0 -0
  65. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml +41 -0
  66. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/default.yml +1 -0
  67. data/spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/oel.yml +41 -0
  68. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/class_spec.rb +0 -0
  69. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/default.yml +41 -0
  70. data/spec/lib/simp/ci/files/valid_job_suite_nodeset/spec/acceptance/suites/default/nodesets/oel.yml +41 -0
  71. data/spec/lib/simp/ci/gitlab_spec.rb +246 -0
  72. metadata +69 -2
@@ -0,0 +1 @@
1
+ spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/nodesets/centos.yml
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: onyxpoint/oel-7-x86_64
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: onyxpoint/oel-7-x86_64
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: onyxpoint/oel-7-x86_64
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: onyxpoint/oel-7-x86_64
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1 @@
1
+ spec/lib/simp/ci/files/suite_skeleton_only/spec/acceptance/suites/default/../../nodesets
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: centos/7
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: centos/7
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: centos/6
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: centos/7
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: onyxpoint/oel-7-x86_64
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: onyxpoint/oel-7-x86_64
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: onyxpoint/oel-7-x86_64
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: onyxpoint/oel-7-x86_64
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: centos/7
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: centos/7
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: centos/6
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: centos/7
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: onyxpoint/oel-7-x86_64
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: onyxpoint/oel-7-x86_64
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: onyxpoint/oel-7-x86_64
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: onyxpoint/oel-7-x86_64
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1 @@
1
+ spec/lib/simp/ci/files/valid_job_nodeset_dir_link/spec/acceptance/suites/default/../../nodesets
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: centos/7
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: centos/7
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: centos/6
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: centos/7
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1 @@
1
+ spec/lib/simp/ci/files/valid_job_nodeset_link/spec/acceptance/suites/default/nodesets/centos.yml
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: onyxpoint/oel-7-x86_64
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: onyxpoint/oel-7-x86_64
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: onyxpoint/oel-7-x86_64
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: onyxpoint/oel-7-x86_64
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: centos/7
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: centos/7
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: centos/6
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: centos/7
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,41 @@
1
+ <%
2
+ if ENV['BEAKER_HYPERVISOR']
3
+ hypervisor = ENV['BEAKER_HYPERVISOR']
4
+ else
5
+ hypervisor = 'vagrant'
6
+ end
7
+ -%>
8
+ HOSTS:
9
+ client:
10
+ roles:
11
+ - default
12
+ - master
13
+ - client
14
+ platform: el-7-x86_64
15
+ box: onyxpoint/oel-7-x86_64
16
+ hypervisor: <%= hypervisor %>
17
+ server-1:
18
+ roles:
19
+ - server
20
+ platform: el-7-x86_64
21
+ box: onyxpoint/oel-7-x86_64
22
+ hypervisor: <%= hypervisor %>
23
+ server-2:
24
+ roles:
25
+ - server
26
+ platform: el-6-x86_64
27
+ box: onyxpoint/oel-7-x86_64
28
+ hypervisor: <%= hypervisor %>
29
+ server-3:
30
+ roles:
31
+ - failover_server
32
+ platform: el-7-x86_64
33
+ box: onyxpoint/oel-7-x86_64
34
+ hypervisor: <%= hypervisor %>
35
+ CONFIG:
36
+ log_level: verbose
37
+ type: aio
38
+ vagrant_memsize: 256
39
+ <% if ENV['BEAKER_PUPPET_COLLECTION'] -%>
40
+ puppet_collection: <%= ENV['BEAKER_PUPPET_COLLECTION'] %>
41
+ <% end -%>
@@ -0,0 +1,246 @@
1
+ require 'simp/ci/gitlab'
2
+ require 'spec_helper'
3
+
4
+ describe Simp::Ci::Gitlab do
5
+ let(:files_dir) { File.join(File.dirname(__FILE__), 'files') }
6
+
7
+ describe '#acceptance_tests?' do
8
+ it 'returns true when acceptance test with suite-specific nodesets exists' do
9
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
10
+ expect( Simp::Ci::Gitlab.new(proj_dir).acceptance_tests? ).to be true
11
+ end
12
+
13
+ it 'returns true when acceptance test with implied global nodesets exists' do
14
+ proj_dir = File.join(files_dir, 'valid_job_global_nodeset')
15
+ expect( Simp::Ci::Gitlab.new(proj_dir).acceptance_tests? ).to be true
16
+ end
17
+
18
+ it 'returns false when acceptance test dir does not exists' do
19
+ proj_dir = File.join(files_dir, 'no_acceptance_tests')
20
+ expect( Simp::Ci::Gitlab.new(proj_dir).acceptance_tests? ).to be false
21
+ end
22
+
23
+ it 'returns false when only global nodesets exists' do
24
+ proj_dir = File.join(files_dir, 'global_nodesets_only')
25
+ expect( Simp::Ci::Gitlab.new(proj_dir).acceptance_tests? ).to be false
26
+ end
27
+
28
+ it 'returns false when only acceptance test suite skeleton exists' do
29
+ proj_dir = File.join(files_dir, 'suite_skeleton_only')
30
+ expect( Simp::Ci::Gitlab.new(proj_dir).acceptance_tests? ).to be false
31
+ end
32
+
33
+ end
34
+
35
+ describe '#validate_config' do
36
+ it 'succeeds when no .gitlab-ci.yml file exists and no tests exist' do
37
+ proj_dir = File.join(files_dir, 'no_gitlab_config_without_tests')
38
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_config }.
39
+ to_not raise_error
40
+ end
41
+
42
+ it 'succeeds but warns when no .gitlab-ci.yml file exists but tests exist' do
43
+ proj_dir = File.join(files_dir, 'no_gitlab_config_with_tests')
44
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_config }.
45
+ to output(/has acceptance tests but no \.gitlab\-ci\.yml/).to_stdout
46
+ end
47
+
48
+ it 'fails when .gitlab-ci.yml is malformed' do
49
+ proj_dir = File.join(files_dir, 'malformed_gitlab_config')
50
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_config }.
51
+ to raise_error(Simp::Ci::Gitlab::LintError,
52
+ /ERROR: Malformed YAML: \(#{proj_dir}\/\.gitlab-ci\.yml\):/)
53
+ end
54
+
55
+ it 'succeeds when .gitlab-ci.yml is valid YAML and passes GitLab lint' do
56
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
57
+ validator = Simp::Ci::Gitlab.new(proj_dir)
58
+
59
+ validator.stubs(:`).with('which curl').returns('/usr/bin/curl')
60
+ gitlab_response = '{"status":"valid","errors":[]}'
61
+ validator.stubs(:`).with(Not(equals('which curl'))).returns(gitlab_response)
62
+
63
+ expect{ validator.validate_config }.
64
+ to_not raise_error
65
+ end
66
+
67
+ it 'fails when .gitlab-ci.yml is valid YAML and fails GitLab lint' do
68
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
69
+ validator = Simp::Ci::Gitlab.new(proj_dir)
70
+
71
+ validator.stubs(:`).with('which curl').returns('/usr/bin/curl')
72
+ gitlab_response = '{"status":"invalid","errors":["root config contains unknown keys: pup5.5-unit"]}'
73
+ validator.stubs(:`).with(Not(equals('which curl'))).returns(gitlab_response)
74
+
75
+ expect{ validator.validate_config }.
76
+ to raise_error(Simp::Ci::Gitlab::LintError,
77
+ /ERROR: Invalid GitLab config:.*root config contains unknown keys/m)
78
+ end
79
+
80
+ end
81
+
82
+ describe '#validate_yaml' do
83
+ it 'succeeds when no .gitlab-ci.yml file exists' do
84
+ proj_dir = File.join(files_dir, 'no_gitlab_config_without_tests')
85
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_yaml }.
86
+ to_not raise_error
87
+ end
88
+
89
+ it 'fails when .gitlab-ci.yml is malformed' do
90
+ proj_dir = File.join(files_dir, 'malformed_gitlab_config')
91
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_yaml }.
92
+ to raise_error(Simp::Ci::Gitlab::LintError,
93
+ /ERROR: Malformed YAML: \(#{proj_dir}\/\.gitlab-ci\.yml\):/)
94
+ end
95
+
96
+ it 'succeeds but warns when curl is not found' do
97
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
98
+ validator = Simp::Ci::Gitlab.new(proj_dir)
99
+
100
+ validator.stubs(:`).returns('')
101
+
102
+ expect{ validator.validate_yaml }.
103
+ to output(/Could not find 'curl'/).to_stdout
104
+ end
105
+
106
+ it 'succeeds but warns when connection to GitLab fails' do
107
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
108
+ validator = Simp::Ci::Gitlab.new(proj_dir)
109
+
110
+ validator.stubs(:`).with('which curl').returns('/usr/bin/curl')
111
+ validator.stubs(:`).with(Not(equals('which curl'))).returns('{}')
112
+
113
+ expect{ validator.validate_yaml }.
114
+ to output(/Unable to lint check/).to_stdout
115
+ end
116
+
117
+ it 'succeeds when config passes GitLab lint check' do
118
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
119
+ validator = Simp::Ci::Gitlab.new(proj_dir)
120
+
121
+ validator.stubs(:`).with('which curl').returns('/usr/bin/curl')
122
+ gitlab_response = '{"status":"valid","errors":[]}'
123
+ validator.stubs(:`).with(Not(equals('which curl'))).returns(gitlab_response)
124
+
125
+ expect{ validator.validate_yaml }.
126
+ to_not raise_error
127
+ end
128
+
129
+ it 'fails when config fails GitLab lint check' do
130
+ # mocking lint API call to GitLab, so doesn't matter if we are using
131
+ # a project dir with valid config
132
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
133
+ validator = Simp::Ci::Gitlab.new(proj_dir)
134
+
135
+ validator.stubs(:`).with('which curl').returns('/usr/bin/curl')
136
+ gitlab_response = '{"status":"invalid","errors":["root config contains unknown keys: pup5.5-unit"]}'
137
+ validator.stubs(:`).with(Not(equals('which curl'))).returns(gitlab_response)
138
+
139
+ expect{ validator.validate_yaml }.
140
+ to raise_error(Simp::Ci::Gitlab::LintError,
141
+ /ERROR: Invalid GitLab config:.*root config contains unknown keys/m)
142
+ end
143
+
144
+ end
145
+
146
+ describe '#validate_acceptance_test_jobs' do
147
+ it 'succeeds when no .gitlab-ci.yml file exists' do
148
+ proj_dir = File.join(files_dir, 'no_gitlab_config_without_tests')
149
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
150
+ to_not raise_error
151
+ end
152
+
153
+ it 'fails when .gitlab-ci.yml is malformed' do
154
+ proj_dir = File.join(files_dir, 'malformed_gitlab_config')
155
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
156
+ to raise_error(Simp::Ci::Gitlab::LintError,
157
+ /ERROR: Malformed YAML: \(#{proj_dir}\/\.gitlab-ci\.yml\):/)
158
+ end
159
+
160
+ it 'succeeds when no acceptance tests are specified in the .gitlab-ci.yml file' do
161
+ proj_dir = File.join(files_dir, 'no_acceptance_tests')
162
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
163
+ to_not raise_error
164
+ end
165
+
166
+ it 'succeeds when acceptance test with suite-specific nodeset is correctly specified' do
167
+ proj_dir = File.join(files_dir, 'valid_job_suite_nodeset')
168
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
169
+ to_not raise_error
170
+ end
171
+
172
+ it 'succeeds when acceptance test with nodeset link is correctly specified' do
173
+ proj_dir = File.join(files_dir, 'valid_job_nodeset_link')
174
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
175
+ to_not raise_error
176
+ end
177
+
178
+ it 'succeeds when acceptance test with nodeset dir link is correctly specified' do
179
+ proj_dir = File.join(files_dir, 'valid_job_nodeset_dir_link')
180
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
181
+ to_not raise_error
182
+ end
183
+
184
+ it 'succeeds when acceptance test with implied global nodeset is correctly specified' do
185
+ proj_dir = File.join(files_dir, 'valid_job_global_nodeset')
186
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
187
+ to_not raise_error
188
+ end
189
+
190
+ it 'succeeds when acceptance tests for multiple suites/nodesets are correctly specified' do
191
+ proj_dir = File.join(files_dir, 'multiple_valid_jobs')
192
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
193
+ to_not raise_error
194
+ end
195
+
196
+ it 'fails when an acceptance job is missing suite and nodeset' do
197
+ proj_dir = File.join(files_dir, 'job_missing_suite_and_nodeset')
198
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
199
+ to raise_error(Simp::Ci::Gitlab::JobError, /missing suite and nodeset/)
200
+ end
201
+
202
+ it 'fails when an acceptance job is missing nodeset' do
203
+ proj_dir = File.join(files_dir, 'job_missing_nodeset')
204
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
205
+ to raise_error(Simp::Ci::Gitlab::JobError, /missing nodeset/)
206
+ end
207
+
208
+ it 'fails when an acceptance job has invalid suite' do
209
+ proj_dir = File.join(files_dir, 'job_invalid_suite')
210
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
211
+ to raise_error(Simp::Ci::Gitlab::JobError, /uses invalid suite 'oops_suite'/)
212
+ end
213
+
214
+ it 'fails when an acceptance job has invalid nodeset' do
215
+ proj_dir = File.join(files_dir, 'job_invalid_nodeset')
216
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
217
+ to raise_error(Simp::Ci::Gitlab::JobError, /uses invalid nodeset 'oops_nodeset'/)
218
+ end
219
+
220
+ it 'fails when an acceptance job has nodeset with a broken link' do
221
+ proj_dir = File.join(files_dir, 'job_broken_link_nodeset')
222
+ # When the gem is created, the broken link nodeset YAML can't be included. So,
223
+ # in case someone is running this test on files packaged in the gem, skip it!
224
+ broken_link = File.join(proj_dir, 'spec', 'acceptance', 'nodesets', 'nodeset_broken_link.yml')
225
+ unless File.symlink?(broken_link)
226
+ skip 'test nodeset YAML with broken link is not present'
227
+ end
228
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
229
+ to raise_error(Simp::Ci::Gitlab::JobError, /uses invalid nodeset 'nodeset_broken_link'/)
230
+ end
231
+
232
+ it 'reports all job failures' do
233
+ proj_dir = File.join(files_dir, 'multiple_invalid_jobs')
234
+ expected_failures = <<-EOF
235
+ Invalid GitLab acceptance test config:
236
+ multiple_invalid_jobs job 'pup5.5.10' missing suite and nodeset: 'bundle exec rake beaker:suites'
237
+ multiple_invalid_jobs job 'pup5.5.10-fips' missing nodeset: 'BEAKER_fips=yes bundle exec rake beaker:suites[default]'
238
+ multiple_invalid_jobs job 'pup5.5.10-oel' uses invalid nodeset 'oel-x86_64': 'bundle exec rake beaker:suites[default,oel-x86_64]'
239
+ multiple_invalid_jobs job 'pup5.5.10-feature_3-oel' uses invalid suite 'feature_3': 'bundle exec rake beaker:suites[feature_3,oel]'
240
+ EOF
241
+ expect{ Simp::Ci::Gitlab.new(proj_dir).validate_acceptance_test_jobs }.
242
+ to raise_error(Simp::Ci::Gitlab::JobError, /#{Regexp.escape(expected_failures.strip)}/)
243
+ end
244
+ end
245
+
246
+ end