simp-rake-helpers 5.1.4 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/lib/simp/componentinfo.rb +227 -0
  4. data/lib/simp/rake/helpers/version.rb +1 -1
  5. data/lib/simp/rake/pkg.rb +115 -0
  6. data/lib/simp/rake/pupmod/helpers.rb +2 -2
  7. data/lib/simp/relchecks.rb +172 -0
  8. data/lib/simp/rpm.rb +2 -0
  9. data/spec/acceptance/nodesets/default.yml +2 -0
  10. data/spec/acceptance/pkg_rpm_spec.rb +42 -133
  11. data/spec/lib/simp/componentinfo_changelog_regex_spec.rb +120 -0
  12. data/spec/lib/simp/componentinfo_spec.rb +278 -0
  13. data/spec/lib/simp/files/componentinfo_spec/asset_missing_release/build/asset_missing_release.spec +36 -0
  14. data/spec/lib/simp/files/componentinfo_spec/asset_missing_version/build/asset_missing_version.spec +36 -0
  15. data/spec/lib/simp/files/componentinfo_spec/asset_with_dist_in_release/build/asset_with_dist_in_release.spec +31 -0
  16. data/spec/lib/simp/files/componentinfo_spec/asset_with_multiple_packages/build/asset_with_multiple_packages.spec +64 -0
  17. data/spec/lib/simp/files/componentinfo_spec/asset_with_single_package/build/asset_with_single_package.spec +37 -0
  18. data/spec/lib/simp/files/componentinfo_spec/asset_with_two_spec_files/build/asseta.spec +43 -0
  19. data/spec/lib/simp/files/componentinfo_spec/asset_with_two_spec_files/build/assetb.spec +43 -0
  20. data/spec/lib/simp/files/componentinfo_spec/asset_without_spec_file/build/README +1 -0
  21. data/spec/lib/simp/files/componentinfo_spec/module/CHANGELOG +14 -0
  22. data/spec/lib/simp/files/componentinfo_spec/module/metadata.json +44 -0
  23. data/spec/lib/simp/files/componentinfo_spec/module_missing_version_metadata/CHANGELOG +14 -0
  24. data/spec/lib/simp/files/componentinfo_spec/module_missing_version_metadata/metadata.json +43 -0
  25. data/spec/lib/simp/files/componentinfo_spec/module_with_date_misordered_entries/CHANGELOG +14 -0
  26. data/spec/lib/simp/files/componentinfo_spec/module_with_date_misordered_entries/metadata.json +44 -0
  27. data/spec/lib/simp/files/componentinfo_spec/module_with_invalid_entries/CHANGELOG +8 -0
  28. data/spec/lib/simp/files/componentinfo_spec/module_with_invalid_entries/metadata.json +44 -0
  29. data/spec/lib/simp/files/componentinfo_spec/module_with_invalid_weekday_entry/CHANGELOG +14 -0
  30. data/spec/lib/simp/files/componentinfo_spec/module_with_invalid_weekday_entry/metadata.json +44 -0
  31. data/spec/lib/simp/files/componentinfo_spec/module_with_malformed_metadata/CHANGELOG +14 -0
  32. data/spec/lib/simp/files/componentinfo_spec/module_with_malformed_metadata/metadata.json +44 -0
  33. data/spec/lib/simp/files/componentinfo_spec/module_with_version_misordered_entries/CHANGELOG +14 -0
  34. data/spec/lib/simp/files/componentinfo_spec/module_with_version_misordered_entries/metadata.json +44 -0
  35. data/spec/lib/simp/files/componentinfo_spec/module_without_changelog/metadata.json +44 -0
  36. data/spec/lib/simp/files/relchecks_compare_latest_tag_spec/module/CHANGELOG +5 -0
  37. data/spec/lib/simp/files/relchecks_compare_latest_tag_spec/module/metadata.json +44 -0
  38. data/spec/lib/simp/files/relchecks_compare_latest_tag_spec/module_without_changelog/metadata.json +44 -0
  39. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_mismatched_release/build/asset_mismatched_release.spec +35 -0
  40. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_missing_changelog/build/asset_missing_changelog.spec +27 -0
  41. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_with_dist_in_release/build/asset_with_dist_in_release.spec +31 -0
  42. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_with_multiple_packages/build/asset_with_multiple_packages.spec +64 -0
  43. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_with_single_package/build/asset_with_single_package.spec +35 -0
  44. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/asset_without_spec_file/build/README +1 -0
  45. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_misordered_entries/CHANGELOG +14 -0
  46. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_misordered_entries/metadata.json +44 -0
  47. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_multiple_entries/CHANGELOG +14 -0
  48. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_multiple_entries/metadata.json +44 -0
  49. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_newer_changelog_entry/CHANGELOG +14 -0
  50. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_newer_changelog_entry/metadata.json +44 -0
  51. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_no_entry_for_version/CHANGELOG +14 -0
  52. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_no_entry_for_version/metadata.json +44 -0
  53. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_single_entry/CHANGELOG +7 -0
  54. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_with_single_entry/metadata.json +44 -0
  55. data/spec/lib/simp/files/relchecks_create_tag_changelog_spec/module_without_changelog/metadata.json +44 -0
  56. data/spec/lib/simp/relchecks_compare_latest_tag_spec.rb +89 -0
  57. data/spec/lib/simp/relchecks_create_tag_changelog_spec.rb +143 -0
  58. metadata +51 -2
@@ -387,6 +387,8 @@ EOE
387
387
  end
388
388
 
389
389
  def self.create_rpm_build_metadata(project_dir, srpms=nil, rpms=nil)
390
+ require 'yaml'
391
+
390
392
  last_build = {
391
393
  'git_hash' => %x(git rev-list --max-count=1 HEAD).chomp,
392
394
  'srpms' => {},
@@ -13,6 +13,7 @@ HOSTS:
13
13
  - "echo 'Defaults:build_user !requiretty' >> /etc/sudoers"
14
14
  - "echo 'build_user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
15
15
  - 'useradd -b /home -m -c "Build User" -s /bin/bash -U build_user'
16
+ - 'yum install -y facter'
16
17
  # simp build-deps
17
18
  - 'yum install -y rpm-build augeas-devel createrepo genisoimage git gnupg2 libicu-devel libxml2 libxml2-devel libxslt libxslt-devel mock rpmdevtools clamav which'
18
19
  - 'usermod -a -G mock build_user'
@@ -48,6 +49,7 @@ HOSTS:
48
49
  - "echo 'Defaults:build_user !requiretty' >> /etc/sudoers"
49
50
  - "echo 'build_user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
50
51
  - 'useradd -b /home -m -c "Build User" -s /bin/bash -U build_user'
52
+ - 'yum install -y facter'
51
53
  # simp build-deps
52
54
  - 'yum install -y rpm-build augeas-devel createrepo genisoimage git gnupg2 libicu-devel libxml2 libxml2-devel libxslt libxslt-devel mock rpmdevtools clamav clamav-update which'
53
55
  - 'usermod -a -G mock build_user'
@@ -1,34 +1,23 @@
1
1
  require 'spec_helper_acceptance'
2
2
 
3
- env_vars = {
4
- :default => '',
5
- :simp4 => "SIMP_BUILD_version='4.3.1'",
6
- :simp5 => "SIMP_BUILD_version='5.2.1'"
7
- }
8
3
 
9
4
  shared_examples_for "a RPM generator" do
10
- it 'should create an RPM and remove the mock directory when SIMP_RAKE_MOCK_cleanup=yes' do
11
- on test_host, %(#{run_cmd} "cd #{testpackage_dir}; #{env_vars[build_type]} SIMP_RAKE_MOCK_cleanup=yes rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
12
- on test_host, %(test -f #{testpackage_rpm})
13
- on test_host, %(test -d /var/lib/mock/epel-#{test_dist}-x86_64-pupmod-simp-testpackage__$USER), {:acceptable_exit_codes => [1]}
14
- end
15
-
16
5
  it 'should use specified release number for the RPM' do
17
- on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_release; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
6
+ on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_release; rake pkg:rpm")
18
7
  release_test_rpm = File.join(pkg_root_dir, 'testpackage_with_release',
19
8
  'dist', 'pupmod-simp-testpackage-0.0.1-42.noarch.rpm')
20
9
  on test_host, %(test -f #{release_test_rpm})
21
10
  end
22
11
 
23
12
  it 'should generate a changelog for the RPM when no CHANGELOG exists' do
24
- on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_without_changelog; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
13
+ on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_without_changelog; rake pkg:rpm")
25
14
  changelog_test_rpm = File.join(pkg_root_dir, 'testpackage_without_changelog',
26
15
  'dist', File.basename(testpackage_rpm))
27
16
  on test_host, %(rpm --changelog -qp #{changelog_test_rpm} | grep -q 'Auto Changelog')
28
17
  end
29
18
 
30
19
  it 'should not require pupmod-simp-simplib for simp-simplib RPM' do
31
- on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/simplib; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
20
+ on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/simplib; rake pkg:rpm")
32
21
  simplib_rpm = File.join(pkg_root_dir, 'simplib', 'dist',
33
22
  File.basename(testpackage_rpm).gsub(/simp-testpackage-0.0.1/,'simp-simplib-1.2.3'))
34
23
  on test_host, %(test -f #{simplib_rpm})
@@ -37,7 +26,7 @@ shared_examples_for "a RPM generator" do
37
26
 
38
27
  it 'should not fail to create an RPM when the CHANGELOG has a bad date' do
39
28
  on test_host,
40
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_bad_changelog_date; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
29
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_with_bad_changelog_date; rake pkg:rpm")
41
30
 
42
31
  bad_date_test_rpm = File.join(pkg_root_dir, 'testpackage_with_bad_changelog_date',
43
32
  'dist', File.basename(testpackage_rpm))
@@ -46,77 +35,41 @@ shared_examples_for "a RPM generator" do
46
35
 
47
36
  it 'should fail to create an RPM when metadata.json is missing' do
48
37
  on test_host,
49
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_metadata_file; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
38
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_metadata_file; rake pkg:rpm"),
50
39
  :acceptable_exit_codes => [1]
51
40
  end
52
41
 
53
42
  it 'should fail to create an RPM when license metadata is missing' do
54
43
  on test_host,
55
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_license; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
44
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_license; rake pkg:rpm"),
56
45
  :acceptable_exit_codes => [1]
57
46
  end
58
47
 
59
48
  it 'should fail to create an RPM when name metadata is missing' do
60
49
  on test_host,
61
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_name; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
62
- :acceptable_exit_codes => [1]
50
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_name; rake pkg:rpm"),
51
+ :acceptable_exit_codes => [1]
63
52
  end
64
53
 
65
54
  it 'should fail to create an RPM when source metadata is missing' do
66
55
  on test_host,
67
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_source; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
56
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_source; rake pkg:rpm"),
68
57
  :acceptable_exit_codes => [1]
69
58
  end
70
59
 
71
60
  it 'should fail to create an RPM when summary metadata is missing' do
72
61
  on test_host,
73
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_summary; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
62
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_summary; rake pkg:rpm"),
74
63
  :acceptable_exit_codes => [1]
75
64
  end
76
65
 
77
66
  it 'should fail to create an RPM when version metadata is missing' do
78
67
  on test_host,
79
- %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_version; #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]"),
68
+ %(#{run_cmd} "cd #{pkg_root_dir}/testpackage_missing_version; rake pkg:rpm"),
80
69
  :acceptable_exit_codes => [1]
81
70
  end
82
71
  end
83
72
 
84
- shared_examples_for "a pre-SIMP6 RPM generator" do
85
- it "should create an RPM and leave the mock directory when SIMP_RAKE_MOCK_cleanup=no" do
86
- comment "produces RPM"
87
- on test_host, %(#{run_cmd} "cd #{testpackage_dir}; SIMP_RAKE_MOCK_cleanup=no #{env_vars[build_type]} rake pkg:rpm[epel-#{test_dist}-x86_64,true]")
88
- on test_host, %(test -f #{testpackage_rpm})
89
-
90
- comment "produces RPM with appropriate dependencies"
91
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo)
92
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-simplib)
93
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-puppetlabs-stdlib)
94
- on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "pupmod-testpackage = 0.0.1-0")
95
- on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "simp-testpackage = 0.0.1-0")
96
- on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^pupmod-testpackage")
97
- on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^simp-testpackage")
98
-
99
- comment "RPM generated does not require simp-adapter"
100
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q simp-adapter), {:acceptable_exit_codes => [1]}
101
-
102
- comment "produces RPM with a sourced CHANGELOG"
103
- on test_host, %(rpm --changelog -qp #{testpackage_rpm} | grep -q Stallman)
104
-
105
- comment "produces RPM without SIMP6-specific appropriate pre/post/preun/postun"
106
- on test_host,
107
- %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper"),
108
- {:acceptable_exit_codes => [1]}
109
-
110
- comment "keeps mock chroot when SIMP_RAKE_MOCK_cleanup=no"
111
- on test_host, %(test -d /var/lib/mock/epel-#{test_dist}-x86_64-pupmod-simp-testpackage__build_user)
112
- end
113
-
114
- it "should handle variants" do
115
- pending "removed code to pass variant to mock needs to be reinstated for this feature to work"
116
- fail "INSERT CHECKING CODE HERE"
117
- end
118
- end
119
-
120
73
  def comment(msg, indent=10)
121
74
  logger.optionally_color(Beaker::Logger::MAGENTA, " "*indent + msg)
122
75
  end
@@ -152,14 +105,8 @@ describe 'rake pkg:rpm' do
152
105
  let(:pkg_root_dir) { '/home/build_user/host_files/spec/acceptance/files' }
153
106
  let(:testpackage_dir) { '/home/build_user/host_files/spec/acceptance/files/testpackage' }
154
107
 
155
- dists = ['6', '7']
156
-
157
108
  hosts.each do |host|
158
109
  context "rpm building on #{host}" do
159
- before :each do
160
- on host, 'mkdir -p -m 0755 /var/lib/mock'
161
- on host, 'rm -rf /var/lib/mock/*', :accept_all_exit_codes => true
162
- end
163
110
 
164
111
  context 'prep' do
165
112
  it 'should have a local copy of the test directory' do
@@ -174,81 +121,43 @@ describe 'rake pkg:rpm' do
174
121
 
175
122
  end
176
123
 
177
- dists.each do |dist|
178
- context "for #{dist} distribution using simpdefault.spec" do
179
- let(:test_host) { host }
180
- let(:test_dist) { dist }
181
- let(:build_type) {:default}
182
- let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-0.noarch.rpm') }
183
-
184
- it 'should have a clean working environment' do
185
- testpackages.each do |package|
186
- on host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; rake clean")
187
- end
188
- end
124
+ context "using simpdefault.spec" do
125
+ let(:test_host) { host }
126
+ let(:build_type) {:default}
127
+ let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-0.noarch.rpm') }
189
128
 
190
- it "should create an RPM for #{dist} and leave the mock directory" do
191
- comment "produces RPM"
192
- on test_host, %(#{run_cmd} "cd #{testpackage_dir}; SIMP_RAKE_MOCK_cleanup=no rake pkg:rpm[epel-#{dist}-x86_64,true]")
193
- on test_host, %(test -f #{testpackage_rpm})
194
-
195
- comment "produces RPM with appropriate dependencies"
196
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q simp-adapter)
197
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo)
198
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-simplib)
199
- on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-puppetlabs-stdlib)
200
- on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "pupmod-testpackage = 0.0.1-0")
201
- on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "simp-testpackage = 0.0.1-0")
202
- on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^pupmod-testpackage")
203
- on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^simp-testpackage")
204
-
205
- comment "produces RPM with a sourced CHANGELOG"
206
- on test_host, %(rpm --changelog -qp #{testpackage_rpm} | grep -q Stallman)
207
-
208
- comment "produces RPM with appropriate pre/post/preun/postun"
209
- on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='pre' --rpm_status=\\$1")
210
- on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='post' --rpm_status=\\$1")
211
- on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='preun' --rpm_status=\\$1")
212
- on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='postun' --rpm_status=\\$1")
213
-
214
- comment "keeps mock chroot when SIMP_RAKE_MOCK_cleanup=no"
215
- on test_host, %(test -d /var/lib/mock/epel-#{dist}-x86_64-pupmod-simp-testpackage__build_user)
129
+ it 'should have a clean working environment' do
130
+ testpackages.each do |package|
131
+ on host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; rake clean")
216
132
  end
217
-
218
- it_should_behave_like "a RPM generator"
219
133
  end
220
134
 
221
- context "for #{dist} distribution using simp4.spec" do
222
- let(:test_host) { host }
223
- let(:test_dist) { dist }
224
- let(:build_type) { :simp4 }
225
- let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-0.noarch.rpm') }
226
-
227
- it 'should have a clean working environment' do
228
- testpackages.each do |package|
229
- on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; rake clean")
230
- end
231
- end
232
-
233
- it_should_behave_like "a pre-SIMP6 RPM generator"
234
- it_should_behave_like "a RPM generator"
135
+ it "should create an RPM" do
136
+ comment "produces RPM"
137
+ on test_host, %(#{run_cmd} "cd #{testpackage_dir}; rake pkg:rpm")
138
+ on test_host, %(test -f #{testpackage_rpm})
139
+
140
+ comment "produces RPM with appropriate dependencies"
141
+ on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q simp-adapter)
142
+ on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-foo)
143
+ on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-simp-simplib)
144
+ on test_host, %(rpm -qpR #{testpackage_rpm} | grep -q pupmod-puppetlabs-stdlib)
145
+ on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "pupmod-testpackage = 0.0.1-0")
146
+ on test_host, %(rpm -qp --provides #{testpackage_rpm} | grep -q -x "simp-testpackage = 0.0.1-0")
147
+ on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^pupmod-testpackage")
148
+ on test_host, %(rpm -qp --queryformat "[%{obsoletes}\\n]" #{testpackage_rpm} | grep -q "^simp-testpackage")
149
+
150
+ comment "produces RPM with a sourced CHANGELOG"
151
+ on test_host, %(rpm --changelog -qp #{testpackage_rpm} | grep -q Stallman)
152
+
153
+ comment "produces RPM with appropriate pre/post/preun/postun"
154
+ on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='pre' --rpm_status=\\$1")
155
+ on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='post' --rpm_status=\\$1")
156
+ on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='preun' --rpm_status=\\$1")
157
+ on test_host, %(rpm -qp --scripts #{testpackage_rpm} | grep -q -x "/usr/local/sbin/simp_rpm_helper --rpm_dir=/usr/share/simp/modules/testpackage --rpm_section='postun' --rpm_status=\\$1")
235
158
  end
236
159
 
237
- context "for #{dist} distribution using simp5.spec" do
238
- let(:test_host) { host }
239
- let(:test_dist) { dist }
240
- let(:build_type) { :simp5 }
241
- let(:testpackage_rpm) { File.join(testpackage_dir, 'dist/pupmod-simp-testpackage-0.0.1-0.noarch.rpm') }
242
-
243
- it 'should have a clean working environment' do
244
- testpackages.each do |package|
245
- on test_host, %(#{run_cmd} "cd #{pkg_root_dir}/#{package}; rake clean")
246
- end
247
- end
248
-
249
- it_should_behave_like "a pre-SIMP6 RPM generator"
250
- it_should_behave_like "a RPM generator"
251
- end
160
+ it_should_behave_like "a RPM generator"
252
161
  end
253
162
  end
254
163
  end
@@ -0,0 +1,120 @@
1
+ require 'simp/relchecks'
2
+ require 'spec_helper'
3
+
4
+ describe 'Simp::ComponentInfo changelog regex' do
5
+
6
+ context 'valid initial changelog lines' do
7
+ it 'matches a valid line with a hyphen before version' do
8
+ line = '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
9
+ result = line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX)
10
+ expect( result ).to_not be nil
11
+ expect( result[1] ).to eq 'Mon Nov 06 2017'
12
+ expect( result[2] ).to eq 'Tom Smith <tom.smith@simp.com>'
13
+ expect( result[3] ).to eq '3.8.0'
14
+ expect( result[4] ).to eq '0'
15
+ end
16
+
17
+ it 'matches a valid line without a hyphen before version' do
18
+ line = '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> 13.28.30-RC1 '
19
+ result = line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX)
20
+ expect( result ).to_not be nil
21
+ expect( result[1] ).to eq 'Mon Nov 06 2017'
22
+ expect( result[2] ).to eq 'Tom Smith <tom.smith@simp.com>'
23
+ expect( result[3] ).to eq '13.28.30'
24
+ expect( result[4] ).to eq 'RC1'
25
+ end
26
+
27
+ it 'matches a valid line without release qualifier' do
28
+ line = '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0'
29
+ result = line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX)
30
+ expect( result ).to_not be nil
31
+ expect( result[1] ).to eq 'Mon Nov 06 2017'
32
+ expect( result[2] ).to eq 'Tom Smith <tom.smith@simp.com>'
33
+ expect( result[3] ).to eq '3.8.0'
34
+ expect( result[4] ).to be nil
35
+ end
36
+ end
37
+
38
+ context 'invalid initial changelog lines' do
39
+ it "does not match line that does not begin with '*'" do
40
+ line = '- Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
41
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
42
+ end
43
+
44
+ it 'does not match line with bad weekday' do
45
+ line = '* Tues Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
46
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
47
+ end
48
+
49
+ it 'does not match line missing weekday' do
50
+ line = '* Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
51
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
52
+ end
53
+
54
+ it 'does not match line with invalid month' do
55
+ line = '* Mon June 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
56
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
57
+ end
58
+
59
+ it 'does not match line missing month' do
60
+ line = '* Mon 06 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
61
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
62
+ end
63
+
64
+ it 'does not match line with single digit day' do
65
+ line = '* Mon Nov 6 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
66
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
67
+ end
68
+
69
+ it 'does not match line with a too-large day' do
70
+ line = '* Mon Nov 46 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
71
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
72
+ end
73
+
74
+ it 'does not match line missing day' do
75
+ line = '* Mon Nov 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
76
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
77
+ end
78
+
79
+ it 'does not match line with a two-digit year' do
80
+ line = '* Mon Nov 01 17 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
81
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
82
+ end
83
+
84
+ it 'does not match line with a too-large year' do
85
+ line = '* Mon Nov 01 20170 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
86
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
87
+ end
88
+
89
+ it 'does not match line missing year' do
90
+ line = '* Mon Nov 01 Tom Smith <tom.smith@simp.com> - 3.8.0-0'
91
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
92
+ end
93
+
94
+ it 'does not match line missing author name' do
95
+ line = '* Mon Nov 01 2017 <tom.smith@simp.com> - 3.8.0-0'
96
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
97
+ end
98
+
99
+ it 'does not match line missing author email address' do
100
+ line = '* Mon Nov 01 20170 Tom Smith - 3.8.0-0'
101
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
102
+ end
103
+
104
+ it 'does not match line missing version' do
105
+ line = '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com>'
106
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
107
+ end
108
+
109
+ it 'does not match line with a version less than 3 parts' do
110
+ line = '* Mon Nov 01 20170 Tom Smith <tom.smith@simp.com> - 3.8'
111
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
112
+ end
113
+
114
+ it 'does not match a valid line with more than 3 parts in the version' do
115
+ line = '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> 3.8.0.0'
116
+ expect( line.match(Simp::ComponentInfo::CHANGELOG_ENTRY_REGEX) ).to be nil
117
+ end
118
+
119
+ end
120
+ end
@@ -0,0 +1,278 @@
1
+ require 'simp/componentinfo'
2
+ require 'spec_helper'
3
+
4
+ describe Simp::ComponentInfo do
5
+ let(:files_dir) {
6
+ File.join( File.dirname(__FILE__), 'files', File.basename(__FILE__, '.rb'))
7
+ }
8
+
9
+ context 'with valid module input' do
10
+ it 'loads version and changelog info' do
11
+ component_dir = File.join(files_dir, 'module')
12
+ info = Simp::ComponentInfo.new(component_dir)
13
+ expect( info.component_dir ).to eq component_dir
14
+ expect( info.type ).to eq :module
15
+ expect( info.version ).to eq '3.8.0'
16
+ expect( info.release ).to be nil
17
+ expected_changelog = [
18
+ {
19
+ :date => 'Wed Nov 15 2017',
20
+ :version => '3.8.0',
21
+ :release => '0',
22
+ :content => [
23
+ '* Wed Nov 15 2017 Mary Jones <mary.jones@simp.com> - 3.8.0-0',
24
+ '- Disable deprecation warnings by default'
25
+ ]
26
+ },
27
+ {
28
+ :date => 'Mon Nov 06 2017',
29
+ :version => '3.8.0',
30
+ :release => '0',
31
+ :content => [
32
+ '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0',
33
+ '- Fixes split failure when "findmnt" does not exist on Linux'
34
+ ]
35
+ },
36
+ {
37
+ :date => 'Thu Oct 26 2017',
38
+ :version => '3.7.0',
39
+ :release => '0',
40
+ :content => [ # +changelog_date+:: Date string of the form <weekday> <month> <day> <year>
41
+
42
+ '* Thu Oct 26 2017 Mary Jones <mary.jones@simp.com> - 3.7.0-0',
43
+ '- Add Mod::Macaddress data type'
44
+ ]
45
+ },
46
+ {
47
+ :date => 'Tue Sep 26 2017',
48
+ :version => '3.6.0',
49
+ :release => '0',
50
+ :content => [
51
+ '* Tue Sep 26 2017 Joe Brown <joe.brown@simp.com> - 3.6.0-0',
52
+ "- Convert all 'sysctl' 'kernel.shm*' entries to Strings",
53
+ ' - shmall and shmmax were causing Facter and newer versions of Puppet to crash',
54
+ ' - See FACT-1732 for additional information',
55
+ '- Add Puppet function `mod::assert_metadata_os()`'
56
+ ]
57
+ }
58
+ ]
59
+ expect(info.changelog).to eq expected_changelog
60
+ end
61
+
62
+ it 'loads version and latest changelog info' do
63
+ component_dir = File.join(files_dir, 'module')
64
+ info = Simp::ComponentInfo.new(component_dir, true)
65
+ expect( info.component_dir ).to eq component_dir
66
+ expect( info.type ).to eq :module
67
+ expect( info.version ).to eq '3.8.0'
68
+ expect( info.release ).to be nil
69
+ expected_changelog = [
70
+ {
71
+ :date => 'Wed Nov 15 2017',
72
+ :version => '3.8.0',
73
+ :release => '0',
74
+ :content => [
75
+ '* Wed Nov 15 2017 Mary Jones <mary.jones@simp.com> - 3.8.0-0',
76
+ '- Disable deprecation warnings by default'
77
+ ]
78
+ },
79
+ {
80
+ :date => 'Mon Nov 06 2017',
81
+ :version => '3.8.0',
82
+ :release => '0',
83
+ :content => [
84
+ '* Mon Nov 06 2017 Tom Smith <tom.smith@simp.com> - 3.8.0-0',
85
+ '- Fixes split failure when "findmnt" does not exist on Linux'
86
+ ]
87
+ }
88
+ ]
89
+ expect(info.changelog).to eq expected_changelog
90
+ end
91
+ end
92
+
93
+ context 'with invalid module input' do
94
+ it 'fails when metadata.json is malformed' do
95
+ component_dir = File.join(files_dir, 'module_with_malformed_metadata')
96
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
97
+ JSON::ParserError)
98
+ end
99
+
100
+ it 'fails when version is missing from metadata.json' do
101
+ component_dir = File.join(files_dir, 'module_missing_version_metadata')
102
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
103
+ /Version missing from .*module_missing_version_metadata\/metadata.json/)
104
+ end
105
+
106
+ it 'fails when module CHANGELOG is missing' do
107
+ component_dir = File.join(files_dir, 'module_without_changelog')
108
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
109
+ /No CHANGELOG file found in .*module_without_changelog/)
110
+ end
111
+
112
+ it 'fails when any changelog entry version is > top-most version' do
113
+ component_dir = File.join(files_dir, 'module_with_version_misordered_entries')
114
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
115
+ /ERROR: Changelog entries are not properly version ordered/)
116
+ end
117
+
118
+ it 'fails when changelog entry dates are not ordered newest to oldest' do
119
+ component_dir = File.join(files_dir, 'module_with_date_misordered_entries')
120
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
121
+ /ERROR: Changelog entries are not properly date ordered/)
122
+ end
123
+
124
+ it 'stops processing upon first malformed changelog signature' do
125
+ component_dir = File.join(files_dir, 'module_with_invalid_entries')
126
+ info = Simp::ComponentInfo.new(component_dir)
127
+ expected_changelog = [
128
+ {
129
+ :date => 'Wed Nov 15 2017',
130
+ :version => '3.8.0',
131
+ :release => '0',
132
+ :content => [
133
+ '* Wed Nov 15 2017 Mary Jones <mary.jones@simp.com> - 3.8.0-0',
134
+ '- Disable deprecation warnings by default'
135
+ ]
136
+ }
137
+ ]
138
+ expect(info.changelog).to eq expected_changelog
139
+ end
140
+
141
+ it 'stops processing upon first invalid changelog weekday' do
142
+ component_dir = File.join(files_dir, 'module_with_invalid_weekday_entry')
143
+ info = Simp::ComponentInfo.new(component_dir)
144
+ expected_changelog = [
145
+ {
146
+ :date => 'Thu Nov 16 2017',
147
+ :version => '3.8.0',
148
+ :release => '0',
149
+ :content => [
150
+ '* Thu Nov 16 2017 Mary Jones <mary.jones@simp.com> - 3.8.0-0',
151
+ '- Disable deprecation warnings by default'
152
+ ]
153
+ }
154
+ ]
155
+ expect(info.changelog).to eq expected_changelog
156
+ end
157
+ end
158
+
159
+ context 'with valid asset input' do
160
+ it 'loads version, release and changelog info from a single-package spec file' do
161
+ component_dir = File.join(files_dir, 'asset_with_single_package')
162
+ info = Simp::ComponentInfo.new(component_dir, true)
163
+ expect( info.component_dir ).to eq component_dir
164
+ expect( info.type ).to eq :asset
165
+ expect( info.version ).to eq '1.0.0'
166
+ expect( info.release ).to eq '1'
167
+ expected_changelog = [
168
+ {
169
+ :date => 'Wed Oct 18 2017',
170
+ :version => '1.0.0',
171
+ :release => '1',
172
+ :content => [
173
+ '* Wed Oct 18 2017 Jane Doe <jane.doe@simp.com> - 1.0.0-1',
174
+ '- Fix installed file permissions'
175
+ ]
176
+ }
177
+ ]
178
+ expect(info.changelog).to eq expected_changelog
179
+ end
180
+
181
+ it 'loads version, release, and changelog info for primary package from a multi-package spec file' do
182
+ component_dir = File.join(files_dir, 'asset_with_multiple_packages')
183
+ info = Simp::ComponentInfo.new(component_dir)
184
+ expect( info.component_dir ).to eq component_dir
185
+ expect( info.type ).to eq :asset
186
+ expect( info.version ).to eq '4.0.3'
187
+ expect( info.release ).to eq '0'
188
+ expected_changelog = [
189
+ {
190
+ :date => 'Thu Aug 31 2017',
191
+ :version => '4.0.3',
192
+ :release => nil,
193
+ :content => [
194
+ '* Thu Aug 31 2017 Jane Doe <jane.doe@simp.com> - 4.0.3',
195
+ '- Fix bug Z',
196
+ ' - Thanks to Lilia Smith for the PR!'
197
+ ]
198
+ },
199
+ {
200
+ :date => 'Mon Jun 12 2017',
201
+ :version => '4.0.3',
202
+ :release => nil,
203
+ :content => [
204
+ '* Mon Jun 12 2017 Jane Doe <jane.doe@simp.com> - 4.0.3',
205
+ '- Prompt user for new input'
206
+ ]
207
+ },
208
+ {
209
+ :date => 'Fri Jun 02 2017',
210
+ :version => '4.0.2',
211
+ :release => '0',
212
+ :content => [
213
+ '* Fri Jun 02 2017 Jim Jones <jim.jones@simp.com> - 4.0.2-0',
214
+ '- Expand X',
215
+ '- Fix Y'
216
+ ]
217
+ }
218
+ ]
219
+ expect(info.changelog).to eq expected_changelog
220
+ end
221
+
222
+ it 'loads version, release, and changelog info when release includes distribution' do
223
+ component_dir = File.join(files_dir, 'asset_with_dist_in_release')
224
+ info = Simp::ComponentInfo.new(component_dir)
225
+ expect( info.component_dir ).to eq component_dir
226
+ expect( info.type ).to eq :asset
227
+ expect( info.version ).to eq '1.0.0'
228
+ expect( info.release ).to match /0/
229
+ expected_changelog = [
230
+ {
231
+ :date => 'Wed Oct 18 2017',
232
+ :version => '1.0.0',
233
+ :release => '0',
234
+ :content => [
235
+ '* Wed Oct 18 2017 Jane Doe <jane.doe@simp.com> - 1.0.0-0',
236
+ '- Package with distribution in release tag'
237
+ ]
238
+ }
239
+ ]
240
+ expect(info.changelog).to eq expected_changelog
241
+ end
242
+ end
243
+
244
+ # Since same changelog parsing code is used for module and
245
+ # RPM changelog content, only focus on the errors not already
246
+ # tested above.
247
+ context 'with invalid asset input' do
248
+ it 'fails when asset RPM spec file is missing' do
249
+ component_dir = File.join(files_dir, 'asset_without_spec_file')
250
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
251
+ /No RPM spec file found in .*asset_without_spec_file\/build/)
252
+ end
253
+
254
+ it 'fails when more than 1 asset RPM spec file is found' do
255
+ component_dir = File.join(files_dir, 'asset_with_two_spec_files')
256
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
257
+ /More than 1 RPM spec file found:/)
258
+ end
259
+
260
+ it 'fails when version is missing from asset RPM spec file' do
261
+ component_dir = File.join(files_dir, 'asset_missing_version')
262
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
263
+ /Could not extract version and release from /)
264
+ end
265
+
266
+ it 'fails when release is missing from asset RPM spec file' do
267
+ component_dir = File.join(files_dir, 'asset_missing_release')
268
+ expect{ Simp::ComponentInfo.new(component_dir) }.to raise_error(
269
+ /Could not extract version and release from /)
270
+ end
271
+
272
+ # This has to be a case in which version and release can be read
273
+ # from spec file but the changelog (which is optional) can't. Could
274
+ # be mocked, but would like a real-world test case.
275
+ xit 'fails when changelog cannot be read from asset RPM spec file'
276
+
277
+ end
278
+ end