chef 17.8.25 → 17.9.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -81,36 +81,40 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
81
81
  context "vanilla use case" do
82
82
  it "installs if the package is not installed" do
83
83
  flush_cache
84
- yum_package("chef_rpm") do
84
+ yum_package "chef_rpm" do
85
85
  options default_options
86
+ action :install
86
87
  end.should_be_updated
87
88
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
88
89
  end
89
90
 
90
91
  it "does not install if the package is installed" do
91
92
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
92
- yum_package("chef_rpm") do
93
+ yum_package "chef_rpm" do
93
94
  options default_options
95
+ action :install
94
96
  end.should_not_be_updated
95
- expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
96
97
  end
97
98
 
98
99
  it "does not install twice" do
99
100
  flush_cache
100
- yum_package("chef_rpm") do
101
+ yum_package "chef_rpm" do
101
102
  options default_options
103
+ action :install
102
104
  end.should_be_updated
103
105
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
104
- yum_package("chef_rpm") do
106
+ yum_package "chef_rpm" do
105
107
  options default_options
108
+ action :install
106
109
  end.should_not_be_updated
107
110
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
108
111
  end
109
112
 
110
113
  it "does not install if the prior version package is installed" do
111
114
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
112
- yum_package("chef_rpm") do
115
+ yum_package "chef_rpm" do
113
116
  options default_options
117
+ action :install
114
118
  end.should_not_be_updated
115
119
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
116
120
  end
@@ -118,8 +122,9 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
118
122
  it "does not install if the i686 package is installed", :intel_64bit do
119
123
  skip "FIXME: do nothing, or install the #{pkg_arch} version?"
120
124
  preinstall("chef_rpm-1.10-1.i686.rpm")
121
- yum_package("chef_rpm") do
125
+ yum_package "chef_rpm" do
122
126
  options default_options
127
+ action :install
123
128
  end.should_not_be_updated
124
129
  expect_matching_installed_version("^chef_rpm-1.10-1.i686$")
125
130
  end
@@ -127,252 +132,575 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
127
132
  it "does not install if the prior version i686 package is installed", :intel_64bit do
128
133
  skip "FIXME: do nothing, or install the #{pkg_arch} version?"
129
134
  preinstall("chef_rpm-1.2-1.i686.rpm")
130
- yum_package("chef_rpm") do
135
+ yum_package "chef_rpm" do
131
136
  options default_options
137
+ action :install
132
138
  end.should_not_be_updated
133
139
  expect_matching_installed_version("^chef_rpm-1.2-1.i686$")
134
140
  end
135
141
  end
136
142
 
143
+ context "expanded idempotency checks with version variants" do
144
+
145
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
146
+ # python helper periodically before every top level context to get more FDs.
147
+ before(:all) do
148
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
149
+ end
150
+
151
+ # 0:1*-1 doesn't work on yum/el6
152
+ %w{1.10 1* 1.10-1 1*-1 1.10-* 1*-* 0:1* *:1.10-* *:1*-* 0:1.10 0:1.10-1}.each do |vstring|
153
+ it "installs the rpm when #{vstring} is in the package_name" do
154
+ flush_cache
155
+ yum_package "chef_rpm-#{vstring}" do
156
+ options default_options
157
+ action :install
158
+ end.should_be_updated
159
+ end
160
+
161
+ it "is idempotent when #{vstring} is in the package_name" do
162
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
163
+ yum_package "chef_rpm-#{vstring}" do
164
+ options default_options
165
+ action :install
166
+ end.should_not_be_updated
167
+ end
168
+
169
+ it "installs the rpm when #{vstring} is in the version property" do
170
+ flush_cache
171
+ yum_package "chef_rpm" do
172
+ options default_options
173
+ version vstring
174
+ action :install
175
+ end.should_be_updated
176
+ end
177
+
178
+ it "is idempotent when #{vstring} is in the version property" do
179
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
180
+ yum_package "chef_rpm" do
181
+ options default_options
182
+ version vstring
183
+ action :install
184
+ end.should_not_be_updated
185
+ end
186
+
187
+ it "upgrades the rpm when #{vstring} is in the package_name" do
188
+ flush_cache
189
+ yum_package "chef_rpm-#{vstring}" do
190
+ options default_options
191
+ action :upgrade
192
+ end.should_be_updated
193
+ end
194
+
195
+ it "is idempotent when #{vstring} is in the package_name" do
196
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
197
+ yum_package "chef_rpm-#{vstring}" do
198
+ options default_options
199
+ action :upgrade
200
+ end.should_not_be_updated
201
+ end
202
+
203
+ it "upgrades the rpm when #{vstring} is in the version property" do
204
+ flush_cache
205
+ yum_package "chef_rpm" do
206
+ options default_options
207
+ version vstring
208
+ action :upgrade
209
+ end.should_be_updated
210
+ end
211
+
212
+ it "is idempotent when #{vstring} is in the version property" do
213
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
214
+ yum_package "chef_rpm" do
215
+ options default_options
216
+ version vstring
217
+ action :upgrade
218
+ end.should_not_be_updated
219
+ end
220
+ end
221
+
222
+ # 0:1*-1 doesn't work on yum/el6
223
+ %w{1.2 1* 1.2-1 1*-1 1.2-* 1*-* 0:1* *:1.2-* *:1*-* 0:1.2 0:1.2-1}.each do |vstring|
224
+ it "is idempotent when #{vstring} is in the version property and there is a candidate version" do
225
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
226
+ yum_package "chef_rpm" do
227
+ options default_options
228
+ version vstring
229
+ action :install
230
+ end.should_not_be_updated
231
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
232
+ end
233
+ end
234
+
235
+ # 0:1.2 0:1*-1 doesn't work on yum/el6
236
+ %w{1.2 1.2-1 1.2-* *:1.2-* 0:1.2-1}.each do |vstring|
237
+ it "is idempotent when #{vstring} is in the version property on upgrade and it doesn't match the candidate version" do
238
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
239
+ yum_package "chef_rpm" do
240
+ options default_options
241
+ version vstring
242
+ action :upgrade
243
+ end.should_not_be_updated
244
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
245
+ end
246
+ end
247
+
248
+ # 0:1.2-1 0:1.2 0:1*-1 doesn't work on yum/el6
249
+ %w{1* 1*-1 1*-* 0:1* *:1*-*}.each do |vstring|
250
+ it "upgrades when #{vstring} is in the version property on upgrade and it matches the candidate version" do
251
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
252
+ yum_package "chef_rpm" do
253
+ options default_options
254
+ version vstring
255
+ action :upgrade
256
+ end.should_be_updated
257
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
258
+ yum_package "chef_rpm" do
259
+ options default_options
260
+ version vstring
261
+ action :upgrade
262
+ end.should_not_be_updated
263
+ end
264
+ end
265
+ end
266
+
137
267
  context "with versions or globs in the name" do
268
+
269
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
270
+ # python helper periodically before every top level context to get more FDs.
271
+ before(:all) do
272
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
273
+ end
274
+
138
275
  it "works with a version" do
139
276
  flush_cache
140
- yum_package("chef_rpm-1.10") do
277
+ yum_package "chef_rpm-1.10" do
141
278
  options default_options
279
+ action :install
142
280
  end.should_be_updated
143
281
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
282
+ yum_package "chef_rpm-1.10" do
283
+ options default_options
284
+ action :install
285
+ end.should_not_be_updated
144
286
  end
145
287
 
146
288
  it "works with an older version" do
147
289
  flush_cache
148
- yum_package("chef_rpm-1.2") do
290
+ yum_package "chef_rpm-1.2" do
149
291
  options default_options
292
+ action :install
150
293
  end.should_be_updated
151
294
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
295
+ yum_package "chef_rpm-1.2" do
296
+ options default_options
297
+ action :install
298
+ end.should_not_be_updated
152
299
  end
153
300
 
154
301
  it "works with an evra" do
155
302
  flush_cache
156
- yum_package("chef_rpm-0:1.2-1.#{pkg_arch}") do
303
+ yum_package "chef_rpm-0:1.2-1.#{pkg_arch}" do
157
304
  options default_options
305
+ action :install
158
306
  end.should_be_updated
159
307
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
308
+ yum_package "chef_rpm-0:1.2-1.#{pkg_arch}" do
309
+ options default_options
310
+ action :install
311
+ end.should_not_be_updated
160
312
  end
161
313
 
162
314
  it "works with version and release" do
163
315
  flush_cache
164
- yum_package("chef_rpm-1.2-1") do
316
+ yum_package "chef_rpm-1.2-1" do
165
317
  options default_options
318
+ action :install
166
319
  end.should_be_updated
167
320
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
321
+ yum_package "chef_rpm-1.2-1" do
322
+ options default_options
323
+ action :install
324
+ end.should_not_be_updated
168
325
  end
169
326
 
170
327
  it "works with a version glob" do
171
328
  flush_cache
172
- yum_package("chef_rpm-1*") do
329
+ yum_package "chef_rpm-1*" do
173
330
  options default_options
331
+ action :install
174
332
  end.should_be_updated
175
333
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
334
+ yum_package "chef_rpm-1*" do
335
+ options default_options
336
+ action :install
337
+ end.should_not_be_updated
176
338
  end
177
339
 
178
340
  it "works with a name glob + version glob" do
179
341
  flush_cache
180
- yum_package("chef_rp*-1*") do
342
+ yum_package "chef_rp*-1*" do
181
343
  options default_options
344
+ action :install
182
345
  end.should_be_updated
183
346
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
347
+ yum_package "chef_rp*-1*" do
348
+ options default_options
349
+ action :install
350
+ end.should_not_be_updated
184
351
  end
185
352
 
186
353
  it "upgrades when the installed version does not match the version string" do
187
354
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
188
- yum_package("chef_rpm-1.10") do
355
+ yum_package "chef_rpm-1.10" do
189
356
  options default_options
357
+ action :install
190
358
  end.should_be_updated
191
359
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}")
360
+ yum_package "chef_rpm-1.10" do
361
+ options default_options
362
+ action :install
363
+ end.should_not_be_updated
192
364
  end
193
365
 
194
366
  it "downgrades when the installed version is higher than the package_name version" do
195
367
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
196
- yum_package("chef_rpm-1.2") do
197
- allow_downgrade true
368
+ yum_package "chef_rpm-1.2" do
198
369
  options default_options
370
+ action :install
199
371
  end.should_be_updated
200
372
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
373
+ yum_package "chef_rpm-1.2" do
374
+ options default_options
375
+ action :install
376
+ end.should_not_be_updated
201
377
  end
202
378
  end
203
379
 
204
380
  # version only matches the actual yum version, does not work with epoch or release or combined evr
205
381
  context "with version property" do
382
+
383
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
384
+ # python helper periodically before every top level context to get more FDs.
385
+ before(:all) do
386
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
387
+ end
388
+
206
389
  it "matches the full version" do
207
390
  flush_cache
208
- yum_package("chef_rpm") do
391
+ yum_package "chef_rpm" do
209
392
  options default_options
210
- version("1.10")
393
+ version "1.10"
394
+ action :install
211
395
  end.should_be_updated
212
396
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
397
+ yum_package "chef_rpm" do
398
+ options default_options
399
+ version "1.10"
400
+ action :install
401
+ end.should_not_be_updated
213
402
  end
214
403
 
215
404
  it "matches with a glob" do
216
- # we are unlikely to ever fix this. if you've found this comment you should use e.g. "tcpdump-4*" in
217
- # the name field rather than trying to use a name of "tcpdump" and a version of "4*".
218
- pending "this does not work, is not easily supported by the underlying yum libraries, but does work in the new dnf_package provider"
219
405
  flush_cache
220
- yum_package("chef_rpm") do
406
+ yum_package "chef_rpm" do
221
407
  options default_options
222
- version("1*")
408
+ version "1*"
409
+ action :install
223
410
  end.should_be_updated
224
411
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
412
+ yum_package "chef_rpm" do
413
+ options default_options
414
+ version "1*"
415
+ action :install
416
+ end.should_not_be_updated
225
417
  end
226
418
 
227
419
  it "matches the vr" do
228
420
  flush_cache
229
- yum_package("chef_rpm") do
421
+ yum_package "chef_rpm" do
230
422
  options default_options
231
- version("1.10-1")
423
+ version "1.10-1"
424
+ action :install
232
425
  end.should_be_updated
233
426
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
427
+ yum_package "chef_rpm" do
428
+ options default_options
429
+ version "1.10-1"
430
+ action :install
431
+ end.should_not_be_updated
234
432
  end
235
433
 
236
434
  it "matches the evr" do
237
435
  flush_cache
238
- yum_package("chef_rpm") do
436
+ yum_package "chef_rpm" do
239
437
  options default_options
240
- version("0:1.10-1")
438
+ version "0:1.10-1"
439
+ action :install
241
440
  end.should_be_updated
242
441
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
442
+ yum_package "chef_rpm" do
443
+ options default_options
444
+ version "0:1.10-1"
445
+ action :install
446
+ end.should_not_be_updated
243
447
  end
244
448
 
245
449
  it "matches with a vr glob" do
246
- pending "doesn't work on command line either"
247
450
  flush_cache
248
- yum_package("chef_rpm") do
451
+ yum_package "chef_rpm" do
249
452
  options default_options
250
- version("1.10-1*")
453
+ version "1.10-1*"
454
+ action :install
251
455
  end.should_be_updated
252
456
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
457
+ yum_package "chef_rpm" do
458
+ options default_options
459
+ version "1.10-1*"
460
+ action :install
461
+ end.should_not_be_updated
253
462
  end
254
463
 
255
464
  it "matches with an evr glob" do
256
- pending "doesn't work on command line either"
257
465
  flush_cache
258
- yum_package("chef_rpm") do
466
+ yum_package "chef_rpm" do
259
467
  options default_options
260
- version("0:1.10-1*")
468
+ version "0:1.10-1*"
469
+ action :install
261
470
  end.should_be_updated
262
471
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
472
+ yum_package "chef_rpm" do
473
+ options default_options
474
+ version "0:1.10-1*"
475
+ action :install
476
+ end.should_not_be_updated
263
477
  end
264
478
  end
265
479
 
266
480
  context "downgrades" do
267
- it "downgrades the package when allow_downgrade" do
481
+
482
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
483
+ # python helper periodically before every top level context to get more FDs.
484
+ before(:all) do
485
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
486
+ end
487
+
488
+ it "downgrades the package when allow_downgrade is true" do
268
489
  flush_cache
269
490
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
270
- yum_package("chef_rpm") do
491
+ yum_package "chef_rpm" do
271
492
  options default_options
272
- allow_downgrade true
273
- version("1.2-1")
493
+ version "1.2-1"
494
+ action :install
274
495
  end.should_be_updated
275
496
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
497
+ yum_package "chef_rpm" do
498
+ options default_options
499
+ version "1.2-1"
500
+ action :install
501
+ end.should_not_be_updated
502
+ end
503
+
504
+ it "does not downgrade the package when allow_downgrade is false" do
505
+ flush_cache
506
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
507
+ yum_package "chef_rpm" do
508
+ options default_options
509
+ allow_downgrade false
510
+ version "1.2-1"
511
+ action :install
512
+ end.should_not_be_updated
513
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
276
514
  end
277
515
  end
278
516
 
279
517
  context "with arches", :intel_64bit do
518
+
519
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
520
+ # python helper periodically before every top level context to get more FDs.
521
+ before(:all) do
522
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
523
+ end
524
+
280
525
  it "installs with 64-bit arch in the name" do
281
526
  flush_cache
282
- yum_package("chef_rpm.#{pkg_arch}") do
527
+ yum_package "chef_rpm.#{pkg_arch}" do
283
528
  options default_options
529
+ action :install
284
530
  end.should_be_updated
285
531
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
532
+ yum_package "chef_rpm.#{pkg_arch}" do
533
+ options default_options
534
+ action :install
535
+ end.should_not_be_updated
286
536
  end
287
537
 
288
538
  it "installs with 32-bit arch in the name" do
289
539
  flush_cache
290
- yum_package("chef_rpm.i686") do
540
+ yum_package "chef_rpm.i686" do
291
541
  options default_options
542
+ action :install
292
543
  end.should_be_updated
293
544
  expect_matching_installed_version("^chef_rpm-1.10-1.i686$")
545
+ yum_package "chef_rpm.i686" do
546
+ options default_options
547
+ action :install
548
+ end.should_not_be_updated
294
549
  end
295
550
 
296
551
  it "installs with 64-bit arch in the property" do
297
552
  flush_cache
298
- yum_package("chef_rpm") do
553
+ yum_package "chef_rpm" do
299
554
  options default_options
300
- arch((pkg_arch).to_s)
555
+ arch pkg_arch
556
+ action :install
301
557
  end.should_be_updated
302
558
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
559
+ yum_package "chef_rpm" do
560
+ options default_options
561
+ arch pkg_arch
562
+ action :install
563
+ end.should_not_be_updated
303
564
  end
304
565
 
305
566
  it "installs with 32-bit arch in the property" do
306
567
  flush_cache
307
- yum_package("chef_rpm") do
568
+ yum_package "chef_rpm" do
569
+ options default_options
570
+ arch "i686"
571
+ action :install
572
+ end.should_be_updated
573
+ expect_matching_installed_version("^chef_rpm-1.10-1.i686$")
574
+ yum_package "chef_rpm" do
575
+ options default_options
576
+ arch "i686"
577
+ action :install
578
+ end.should_not_be_updated
579
+ end
580
+
581
+ it "installs when the 32-bit arch is in the name and the version is in the property" do
582
+ flush_cache
583
+ yum_package "chef_rpm.i686" do
308
584
  options default_options
309
- arch("i686")
585
+ version "1.10-1"
586
+ action :install
310
587
  end.should_be_updated
311
588
  expect_matching_installed_version("^chef_rpm-1.10-1.i686$")
589
+ yum_package "chef_rpm.i686" do
590
+ options default_options
591
+ version "1.10-1"
592
+ action :install
593
+ end.should_not_be_updated
594
+ end
595
+
596
+ it "installs when the 64-bit arch is in the name and the version is in the property" do
597
+ flush_cache
598
+ yum_package "chef_rpm.#{pkg_arch}" do
599
+ options default_options
600
+ version "1.10-1"
601
+ action :install
602
+ end.should_be_updated
603
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
604
+ yum_package "chef_rpm.#{pkg_arch}" do
605
+ options default_options
606
+ version "1.10-1"
607
+ action :install
608
+ end.should_not_be_updated
312
609
  end
313
610
  end
314
611
 
315
612
  context "with constraints" do
613
+
614
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
615
+ # python helper periodically before every top level context to get more FDs.
616
+ before(:all) do
617
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
618
+ end
619
+
316
620
  it "with nothing installed, it installs the latest version" do
317
621
  flush_cache
318
- yum_package("chef_rpm >= 1.2") do
622
+ yum_package "chef_rpm >= 1.2" do
319
623
  options default_options
624
+ action :install
320
625
  end.should_be_updated
321
626
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
627
+ yum_package "chef_rpm >= 1.2" do
628
+ options default_options
629
+ action :install
630
+ end.should_not_be_updated
322
631
  end
323
632
 
324
633
  it "when it is met, it does nothing" do
325
634
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
326
- yum_package("chef_rpm >= 1.2") do
635
+ yum_package "chef_rpm >= 1.2" do
327
636
  options default_options
637
+ action :install
328
638
  end.should_not_be_updated
329
639
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
330
640
  end
331
641
 
332
642
  it "when it is met, it does nothing" do
333
643
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
334
- yum_package("chef_rpm >= 1.2") do
644
+ yum_package "chef_rpm >= 1.2" do
335
645
  options default_options
646
+ action :install
336
647
  end.should_not_be_updated
337
648
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
338
649
  end
339
650
 
340
- it "with nothing intalled, it installs the latest version" do
651
+ it "with nothing installed, it installs the latest version" do
341
652
  flush_cache
342
- yum_package("chef_rpm > 1.2") do
653
+ yum_package "chef_rpm > 1.2" do
343
654
  options default_options
655
+ action :install
344
656
  end.should_be_updated
345
657
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
658
+ yum_package "chef_rpm > 1.2" do
659
+ options default_options
660
+ action :install
661
+ end.should_not_be_updated
346
662
  end
347
663
 
348
664
  it "when it is not met by an installed rpm, it upgrades" do
349
665
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
350
- yum_package("chef_rpm > 1.2") do
666
+ yum_package "chef_rpm > 1.2" do
351
667
  options default_options
668
+ action :install
352
669
  end.should_be_updated
353
670
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
671
+ yum_package "chef_rpm > 1.2" do
672
+ options default_options
673
+ action :install
674
+ end.should_not_be_updated
354
675
  end
355
676
 
356
677
  it "with an equality constraint, when it is not met by an installed rpm, it upgrades" do
357
678
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
358
- yum_package("chef_rpm = 1.10") do
679
+ yum_package "chef_rpm = 1.10" do
359
680
  options default_options
681
+ action :install
360
682
  end.should_be_updated
361
683
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
684
+ yum_package "chef_rpm = 1.10" do
685
+ options default_options
686
+ action :install
687
+ end.should_not_be_updated
362
688
  end
363
689
 
364
690
  it "with an equality constraint, when it is met by an installed rpm, it does nothing" do
365
691
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
366
- yum_package("chef_rpm = 1.2") do
692
+ yum_package "chef_rpm = 1.2" do
367
693
  options default_options
694
+ action :install
368
695
  end.should_not_be_updated
369
696
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
370
697
  end
371
698
 
372
699
  it "when it is met by an installed rpm, it does nothing" do
373
700
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
374
- yum_package("chef_rpm > 1.2") do
701
+ yum_package "chef_rpm > 1.2" do
375
702
  options default_options
703
+ action :install
376
704
  end.should_not_be_updated
377
705
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
378
706
  end
@@ -380,153 +708,188 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
380
708
  it "when there is no solution to the constraint" do
381
709
  flush_cache
382
710
  expect {
383
- yum_package("chef_rpm > 2.0") do
384
- options default_options
385
- end
711
+ yum_package "chef_rpm > 2.0"
386
712
  }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
387
713
  end
388
714
 
389
715
  it "when there is no solution to the constraint but an rpm is preinstalled" do
390
716
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
391
717
  expect {
392
- yum_package("chef_rpm > 2.0") do
393
- options default_options
394
- end
718
+ yum_package "chef_rpm > 2.0"
395
719
  }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
396
720
  end
397
721
 
398
722
  it "with a less than constraint, when nothing is installed, it installs" do
399
723
  flush_cache
400
- yum_package("chef_rpm < 1.10") do
401
- allow_downgrade true
724
+ yum_package "chef_rpm < 1.10" do
402
725
  options default_options
726
+ action :install
403
727
  end.should_be_updated
404
728
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
729
+ yum_package "chef_rpm < 1.10" do
730
+ options default_options
731
+ action :install
732
+ end.should_not_be_updated
405
733
  end
406
734
 
407
735
  it "with a less than constraint, when the install version matches, it does nothing" do
408
736
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
409
- yum_package("chef_rpm < 1.10") do
410
- allow_downgrade true
737
+ yum_package "chef_rpm < 1.10" do
411
738
  options default_options
739
+ action :install
412
740
  end.should_not_be_updated
413
741
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
414
742
  end
415
743
 
744
+ # literally no idea why this fails on our rhel6 tester and only that one box and only this one test
416
745
  it "with a less than constraint, when the install version fails, it should downgrade" do
417
746
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
418
- yum_package("chef_rpm < 1.10") do
419
- allow_downgrade true
747
+ yum_package "chef_rpm < 1.10" do
420
748
  options default_options
749
+ action :install
421
750
  end.should_be_updated
422
751
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
752
+ yum_package "chef_rpm < 1.10" do
753
+ options default_options
754
+ action :install
755
+ end.should_not_be_updated
423
756
  end
424
757
  end
425
758
 
426
759
  context "with source arguments" do
760
+
761
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
762
+ # python helper periodically before every top level context to get more FDs.
763
+ before(:all) do
764
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
765
+ end
766
+
427
767
  it "raises an exception when the package does not exist" do
428
768
  flush_cache
429
769
  expect {
430
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/this-file-better-not-exist.rpm") do
431
- options default_options
432
- end
770
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/this-file-better-not-exist.rpm"
433
771
  }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
434
772
  end
435
773
 
436
774
  it "does not raise a hard exception in why-run mode when the package does not exist" do
437
775
  Chef::Config[:why_run] = true
438
776
  flush_cache
439
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/this-file-better-not-exist.rpm") do
777
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/this-file-better-not-exist.rpm" do
440
778
  options default_options
779
+ action :install
441
780
  end
442
781
  end
443
782
 
444
783
  it "installs the package when using the source argument" do
445
784
  flush_cache
446
785
  yum_package "something" do
447
- package_name "somethingelse"
448
786
  source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
787
+ options default_options
788
+ package_name "somethingelse"
789
+ name "something"
790
+ action :install
449
791
  end.should_be_updated
450
792
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
793
+ yum_package "something" do
794
+ source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
795
+ options default_options
796
+ package_name "somethingelse"
797
+ name "something"
798
+ action :install
799
+ end.should_not_be_updated
451
800
  end
452
801
 
453
802
  it "installs the package when the name is a path to a file" do
454
803
  flush_cache
455
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
804
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
456
805
  options default_options
806
+ action :install
457
807
  end.should_be_updated
458
808
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
809
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
810
+ options default_options
811
+ action :install
812
+ end.should_not_be_updated
459
813
  end
460
814
 
461
- it "downgrade on a local file is ignored when allow_downgrade is false" do
815
+ it "downgrade on a local file with allow_downgrade true works" do
462
816
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
463
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
464
- allow_downgrade false
817
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
818
+ options default_options
465
819
  version "1.2-1"
820
+ action :install
821
+ end.should_be_updated
822
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
823
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
466
824
  options default_options
825
+ version "1.2-1"
826
+ action :install
467
827
  end.should_not_be_updated
468
- expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
469
828
  end
470
829
 
471
- it "downgrade on a local file with allow_downgrade true works" do
830
+ it "downgrade on a local file with allow_downgrade false does not downgrade" do
472
831
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
473
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
474
- version "1.2-1"
475
- allow_downgrade true
832
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
476
833
  options default_options
477
- end.should_be_updated
478
- expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
834
+ allow_downgrade false
835
+ version "1.2-1"
836
+ action :install
837
+ end.should_not_be_updated
838
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
479
839
  end
480
840
 
481
841
  it "does not downgrade the package with :install" do
482
842
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
483
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
843
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
484
844
  options default_options
845
+ action :install
485
846
  end.should_not_be_updated
486
847
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
487
848
  end
488
849
 
489
850
  it "does not upgrade the package with :install" do
490
851
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
491
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm") do
852
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm" do
492
853
  options default_options
854
+ action :install
493
855
  end.should_not_be_updated
494
856
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
495
857
  end
496
858
 
497
859
  it "is idempotent when the package is already installed" do
498
860
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
499
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
861
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
500
862
  options default_options
863
+ action :install
501
864
  end.should_not_be_updated
502
865
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
503
866
  end
504
867
 
505
868
  it "is idempotent when the package is already installed and there is a version string" do
506
869
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
507
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
508
- version "1.2-1"
509
- options default_options
510
- end.should_not_be_updated
511
- expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
512
- end
513
-
514
- it "is idempotent when the package is already installed and there is a version string with arch" do
515
- preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
516
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
517
- version "1.2-1.#{pkg_arch}"
870
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
518
871
  options default_options
872
+ version "1.2-1"
873
+ action :install
519
874
  end.should_not_be_updated
520
875
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
521
876
  end
522
877
  end
523
878
 
524
879
  context "with no available version" do
880
+
881
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
882
+ # python helper periodically before every top level context to get more FDs.
883
+ before(:all) do
884
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
885
+ end
886
+
525
887
  it "works when a package is installed" do
526
888
  FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
527
889
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
528
890
  yum_package "chef_rpm" do
529
891
  options "--nogpgcheck"
892
+ action :install
530
893
  end.should_not_be_updated
531
894
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
532
895
  end
@@ -534,28 +897,46 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
534
897
  it "works with a local source" do
535
898
  FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
536
899
  flush_cache
537
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
900
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
538
901
  options "--nogpgcheck"
902
+ action :install
539
903
  end.should_be_updated
540
904
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
905
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
906
+ options "--nogpgcheck"
907
+ action :install
908
+ end.should_not_be_updated
541
909
  end
542
910
  end
543
911
 
544
912
  context "multipackage with arches", :intel_64bit do
913
+
914
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
915
+ # python helper periodically before every top level context to get more FDs.
916
+ before(:all) do
917
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
918
+ end
919
+
545
920
  it "installs two rpms" do
546
921
  flush_cache
547
- yum_package([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] ) do
922
+ yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
548
923
  options default_options
924
+ action :install
549
925
  end.should_be_updated
550
926
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
551
927
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
928
+ yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
929
+ options default_options
930
+ action :install
931
+ end.should_not_be_updated
552
932
  end
553
933
 
554
934
  it "does nothing if both are installed" do
555
935
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm", "chef_rpm-1.10-1.i686.rpm")
556
936
  flush_cache
557
- yum_package([ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] ) do
937
+ yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
558
938
  options default_options
939
+ action :install
559
940
  end.should_not_be_updated
560
941
  end
561
942
 
@@ -563,18 +944,28 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
563
944
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
564
945
  yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
565
946
  options default_options
947
+ action :install
566
948
  end.should_be_updated
567
949
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
568
950
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
951
+ yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
952
+ options default_options
953
+ action :install
954
+ end.should_not_be_updated
569
955
  end
570
956
 
571
957
  it "installs the first rpm if the second is installed" do
572
958
  preinstall("chef_rpm-1.10-1.i686.rpm")
573
959
  yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
574
960
  options default_options
961
+ action :install
575
962
  end.should_be_updated
576
963
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
577
964
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
965
+ yum_package [ "chef_rpm.#{pkg_arch}", "chef_rpm.i686" ] do
966
+ options default_options
967
+ action :install
968
+ end.should_not_be_updated
578
969
  end
579
970
 
580
971
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -583,9 +974,15 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
583
974
  yum_package %w{chef_rpm chef_rpm} do
584
975
  options default_options
585
976
  arch [pkg_arch, "i686"]
977
+ action :install
586
978
  end.should_be_updated
587
979
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
588
980
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
981
+ yum_package %w{chef_rpm chef_rpm} do
982
+ options default_options
983
+ arch [pkg_arch, "i686"]
984
+ action :install
985
+ end.should_not_be_updated
589
986
  end
590
987
 
591
988
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -594,9 +991,14 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
594
991
  yum_package %w{chef_rpm chef_rpm} do
595
992
  options default_options
596
993
  arch [pkg_arch, "i686"]
994
+ action :install
597
995
  end.should_be_updated
598
996
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
599
997
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
998
+ yum_package %w{chef_rpm chef_rpm} do
999
+ options default_options
1000
+ action :install
1001
+ end.should_not_be_updated
600
1002
  end
601
1003
 
602
1004
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -605,9 +1007,14 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
605
1007
  yum_package %w{chef_rpm chef_rpm} do
606
1008
  options default_options
607
1009
  arch [pkg_arch, "i686"]
1010
+ action :install
608
1011
  end.should_be_updated
609
1012
  expect_matching_installed_version(/^chef_rpm-1.10-1.#{pkg_arch}$/)
610
1013
  expect_matching_installed_version(/^chef_rpm-1.10-1.i686$/)
1014
+ yum_package %w{chef_rpm chef_rpm} do
1015
+ options default_options
1016
+ action :install
1017
+ end.should_not_be_updated
611
1018
  end
612
1019
 
613
1020
  # unlikely to work consistently correct, okay to deprecate the arch-array in favor of the arch in the name
@@ -616,16 +1023,25 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
616
1023
  yum_package %w{chef_rpm chef_rpm} do
617
1024
  options default_options
618
1025
  arch [pkg_arch, "i686"]
1026
+ action :install
619
1027
  end.should_not_be_updated
620
1028
  end
621
1029
  end
622
1030
 
623
1031
  context "repo controls" do
1032
+
1033
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
1034
+ # python helper periodically before every top level context to get more FDs.
1035
+ before(:all) do
1036
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
1037
+ end
1038
+
624
1039
  it "should fail with the repo disabled" do
625
1040
  flush_cache
626
1041
  expect {
627
1042
  yum_package "chef_rpm" do
628
1043
  options "--nogpgcheck --disablerepo=chef-yum-localtesting"
1044
+ action :install
629
1045
  end
630
1046
  }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
631
1047
  end
@@ -633,9 +1049,14 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
633
1049
  it "should work with disablerepo first" do
634
1050
  flush_cache
635
1051
  yum_package "chef_rpm" do
636
- options "--nogpgcheck --disablerepo=* --enablerepo=chef-yum-localtesting"
1052
+ options ["--nogpgcheck", "--disablerepo=*", "--enablerepo=chef-yum-localtesting"]
1053
+ action :install
637
1054
  end.should_be_updated
638
1055
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1056
+ yum_package "chef_rpm" do
1057
+ options ["--nogpgcheck", "--disablerepo=*", "--enablerepo=chef-yum-localtesting"]
1058
+ action :install
1059
+ end.should_not_be_updated
639
1060
  end
640
1061
 
641
1062
  it "should work to enable a disabled repo" do
@@ -644,13 +1065,19 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
644
1065
  expect {
645
1066
  yum_package "chef_rpm" do
646
1067
  options "--nogpgcheck"
1068
+ action :install
647
1069
  end
648
1070
  }.to raise_error(Chef::Exceptions::Package, /No candidate version available/)
649
1071
  flush_cache
650
1072
  yum_package "chef_rpm" do
651
1073
  options "--nogpgcheck --enablerepo=chef-yum-localtesting"
1074
+ action :install
652
1075
  end.should_be_updated
653
1076
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1077
+ yum_package "chef_rpm" do
1078
+ options "--nogpgcheck --enablerepo=chef-yum-localtesting"
1079
+ action :install
1080
+ end.should_not_be_updated
654
1081
  end
655
1082
 
656
1083
  it "when an idempotent install action is run, does not leave repos disabled" do
@@ -667,58 +1094,114 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
667
1094
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
668
1095
  # now we're still using the same cache in the yum_helper.py cache and we test to see if the
669
1096
  # repo that we temporarily disabled is enabled on this pass.
670
- yum_package("chef_rpm-1.10-1.#{pkg_arch}") do
1097
+ yum_package "chef_rpm-1.10-1.#{pkg_arch}" do
671
1098
  options "--nogpgcheck"
1099
+ action :install
672
1100
  end.should_be_updated
673
1101
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1102
+ yum_package "chef_rpm-1.10-1.#{pkg_arch}" do
1103
+ options "--nogpgcheck"
1104
+ action :install
1105
+ end.should_not_be_updated
674
1106
  end
675
1107
  end
676
1108
  end
677
1109
 
678
1110
  describe ":upgrade" do
679
1111
 
1112
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
1113
+ # python helper periodically before every top level context to get more FDs.
1114
+ before(:all) do
1115
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
1116
+ end
1117
+
1118
+ context "downgrades" do
1119
+ it "just works by default" do
1120
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
1121
+ yum_package "chef_rpm" do
1122
+ options default_options
1123
+ version "1.2"
1124
+ action :install
1125
+ end.should_be_updated
1126
+ expect(shell_out("rpm -q chef_rpm").stdout.chomp).to match("^chef_rpm-1.2-1.#{pkg_arch}")
1127
+ yum_package "chef_rpm" do
1128
+ options default_options
1129
+ version "1.2"
1130
+ action :install
1131
+ end.should_not_be_updated
1132
+ end
1133
+ end
1134
+
680
1135
  context "with source arguments" do
681
1136
  it "installs the package when using the source argument" do
682
1137
  flush_cache
683
1138
  yum_package "something" do
1139
+ options default_options
684
1140
  package_name "somethingelse"
685
1141
  source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
686
1142
  action :upgrade
687
1143
  end.should_be_updated
688
1144
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1145
+ yum_package "something" do
1146
+ options default_options
1147
+ package_name "somethingelse"
1148
+ source("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm")
1149
+ action :upgrade
1150
+ end.should_not_be_updated
689
1151
  end
690
1152
 
691
1153
  it "installs the package when the name is a path to a file" do
692
1154
  flush_cache
693
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
1155
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
694
1156
  options default_options
695
1157
  action :upgrade
696
1158
  end.should_be_updated
697
1159
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1160
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
1161
+ options default_options
1162
+ action :upgrade
1163
+ end.should_not_be_updated
698
1164
  end
699
1165
 
700
1166
  it "downgrades the package when allow_downgrade is true" do
701
1167
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
702
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
703
- allow_downgrade true
1168
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
704
1169
  options default_options
705
1170
  action :upgrade
706
1171
  end.should_be_updated
707
1172
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1173
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
1174
+ options default_options
1175
+ action :upgrade
1176
+ end.should_not_be_updated
1177
+ end
1178
+
1179
+ it "does not downgrade the package when allow_downgrade is false" do
1180
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
1181
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
1182
+ options default_options
1183
+ allow_downgrade false
1184
+ action :upgrade
1185
+ end.should_not_be_updated
1186
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
708
1187
  end
709
1188
 
710
1189
  it "upgrades the package" do
711
1190
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
712
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm") do
1191
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm" do
713
1192
  options default_options
714
1193
  action :upgrade
715
1194
  end.should_be_updated
716
1195
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1196
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.10-1.#{pkg_arch}.rpm" do
1197
+ options default_options
1198
+ action :upgrade
1199
+ end.should_not_be_updated
717
1200
  end
718
1201
 
719
1202
  it "is idempotent when the package is already installed" do
720
1203
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
721
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
1204
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
722
1205
  options default_options
723
1206
  action :upgrade
724
1207
  end.should_not_be_updated
@@ -730,7 +1213,7 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
730
1213
  it "works when a package is installed" do
731
1214
  FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
732
1215
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
733
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
1216
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
734
1217
  options "--nogpgcheck"
735
1218
  action :upgrade
736
1219
  end.should_not_be_updated
@@ -740,74 +1223,186 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
740
1223
  it "works with a local source" do
741
1224
  FileUtils.rm_f "/etc/yum.repos.d/chef-yum-localtesting.repo"
742
1225
  flush_cache
743
- yum_package("#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm") do
1226
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
744
1227
  options "--nogpgcheck"
745
1228
  action :upgrade
746
1229
  end.should_be_updated
747
1230
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1231
+ yum_package "#{CHEF_SPEC_ASSETS}/yumrepo/chef_rpm-1.2-1.#{pkg_arch}.rpm" do
1232
+ options "--nogpgcheck"
1233
+ action :upgrade
1234
+ end.should_not_be_updated
748
1235
  end
749
1236
  end
750
1237
 
751
1238
  context "version pinning" do
752
- it "with an equality pin in the name it upgrades a prior package" do
1239
+ it "with a full version pin it installs a later package" do
753
1240
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
754
- yum_package("chef_rpm-1.10") do
1241
+ yum_package "chef_rpm" do
755
1242
  options default_options
1243
+ version "1.10-1"
756
1244
  action :upgrade
757
1245
  end.should_be_updated
758
1246
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1247
+ yum_package "chef_rpm" do
1248
+ options default_options
1249
+ version "1.10-1"
1250
+ action :upgrade
1251
+ end.should_not_be_updated
759
1252
  end
760
1253
 
761
- it "with a prco equality pin in the name it upgrades a prior package" do
1254
+ it "with a full version pin in the name it downgrades the package" do
1255
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
1256
+ yum_package "chef_rpm" do
1257
+ options default_options
1258
+ version "1.2-1"
1259
+ action :upgrade
1260
+ end.should_be_updated
1261
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1262
+ yum_package "chef_rpm" do
1263
+ options default_options
1264
+ version "1.2-1"
1265
+ action :upgrade
1266
+ end.should_not_be_updated
1267
+ end
1268
+
1269
+ it "with a partial (no release) version pin it installs a later package" do
1270
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
1271
+ yum_package "chef_rpm" do
1272
+ options default_options
1273
+ version "1.10"
1274
+ action :upgrade
1275
+ end.should_be_updated
1276
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1277
+ yum_package "chef_rpm" do
1278
+ options default_options
1279
+ version "1.10"
1280
+ action :upgrade
1281
+ end.should_not_be_updated
1282
+ end
1283
+
1284
+ it "with a partial (no release) version pin in the name it downgrades the package" do
1285
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
1286
+ yum_package "chef_rpm" do
1287
+ options default_options
1288
+ version("1.2")
1289
+ action :upgrade
1290
+ end.should_be_updated
1291
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1292
+ yum_package "chef_rpm" do
1293
+ options default_options
1294
+ version("1.2")
1295
+ action :upgrade
1296
+ end.should_not_be_updated
1297
+ end
1298
+
1299
+ it "with a full version pin it installs a later package" do
1300
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
1301
+ yum_package "chef_rpm-1.10-1" do
1302
+ options default_options
1303
+ action :upgrade
1304
+ end.should_be_updated
1305
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1306
+ yum_package "chef_rpm-1.10-1" do
1307
+ options default_options
1308
+ action :upgrade
1309
+ end.should_not_be_updated
1310
+ end
1311
+
1312
+ it "with a full version pin in the name it downgrades the package" do
1313
+ preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
1314
+ yum_package "chef_rpm-1.2-1" do
1315
+ options default_options
1316
+ action :upgrade
1317
+ end.should_be_updated
1318
+ expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1319
+ yum_package "chef_rpm-1.2-1" do
1320
+ options default_options
1321
+ action :upgrade
1322
+ end.should_not_be_updated
1323
+ end
1324
+
1325
+ it "with a partial (no release) version pin it installs a later package" do
762
1326
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
763
- yum_package("chef_rpm == 1.10") do
1327
+ yum_package "chef_rpm-1.10" do
764
1328
  options default_options
765
1329
  action :upgrade
766
1330
  end.should_be_updated
767
1331
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1332
+ yum_package "chef_rpm-1.10" do
1333
+ options default_options
1334
+ action :upgrade
1335
+ end.should_not_be_updated
768
1336
  end
769
1337
 
770
- it "with an equality pin in the name it downgrades a later package" do
1338
+ it "with a partial (no release) version pin in the name it downgrades the package" do
771
1339
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
772
- yum_package("chef_rpm-1.2") do
773
- allow_downgrade true
1340
+ yum_package "chef_rpm-1.2" do
774
1341
  options default_options
775
1342
  action :upgrade
776
1343
  end.should_be_updated
777
1344
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1345
+ yum_package "chef_rpm-1.2" do
1346
+ options default_options
1347
+ action :upgrade
1348
+ end.should_not_be_updated
1349
+ end
1350
+
1351
+ it "with a prco equality pin in the name it upgrades a prior package" do
1352
+ preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
1353
+ yum_package "chef_rpm = 1.10" do
1354
+ options default_options
1355
+ action :upgrade
1356
+ end.should_be_updated
1357
+ expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1358
+ yum_package "chef_rpm = 1.10" do
1359
+ options default_options
1360
+ action :upgrade
1361
+ end.should_not_be_updated
778
1362
  end
779
1363
 
780
1364
  it "with a prco equality pin in the name it downgrades a later package" do
781
1365
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
782
- yum_package("chef_rpm == 1.2") do
783
- allow_downgrade true
1366
+ yum_package "chef_rpm = 1.2" do
784
1367
  options default_options
785
1368
  action :upgrade
786
1369
  end.should_be_updated
787
1370
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1371
+ yum_package "chef_rpm = 1.2" do
1372
+ options default_options
1373
+ action :upgrade
1374
+ end.should_not_be_updated
788
1375
  end
789
1376
 
790
1377
  it "with a > pin in the name and no rpm installed it installs" do
791
1378
  flush_cache
792
- yum_package("chef_rpm > 1.2") do
1379
+ yum_package "chef_rpm > 1.2" do
793
1380
  options default_options
794
1381
  action :upgrade
795
1382
  end.should_be_updated
796
1383
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1384
+ yum_package "chef_rpm > 1.2" do
1385
+ options default_options
1386
+ action :upgrade
1387
+ end.should_not_be_updated
797
1388
  end
798
1389
 
799
1390
  it "with a < pin in the name and no rpm installed it installs" do
800
1391
  flush_cache
801
- yum_package("chef_rpm < 1.10") do
1392
+ yum_package "chef_rpm < 1.10" do
802
1393
  options default_options
803
1394
  action :upgrade
804
1395
  end.should_be_updated
805
1396
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1397
+ yum_package "chef_rpm < 1.10" do
1398
+ options default_options
1399
+ action :upgrade
1400
+ end.should_not_be_updated
806
1401
  end
807
1402
 
808
1403
  it "with a > pin in the name and matching rpm installed it does nothing" do
809
1404
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
810
- yum_package("chef_rpm > 1.2") do
1405
+ yum_package "chef_rpm > 1.2" do
811
1406
  options default_options
812
1407
  action :upgrade
813
1408
  end.should_not_be_updated
@@ -816,7 +1411,7 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
816
1411
 
817
1412
  it "with a < pin in the name and no rpm installed it installs" do
818
1413
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
819
- yum_package("chef_rpm < 1.10") do
1414
+ yum_package "chef_rpm < 1.10" do
820
1415
  options default_options
821
1416
  action :upgrade
822
1417
  end.should_not_be_updated
@@ -825,26 +1420,40 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
825
1420
 
826
1421
  it "with a > pin in the name and non-matching rpm installed it upgrades" do
827
1422
  preinstall("chef_rpm-1.2-1.#{pkg_arch}.rpm")
828
- yum_package("chef_rpm > 1.2") do
1423
+ yum_package "chef_rpm > 1.2" do
829
1424
  options default_options
830
1425
  action :upgrade
831
1426
  end.should_be_updated
832
1427
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1428
+ yum_package "chef_rpm > 1.2" do
1429
+ options default_options
1430
+ action :upgrade
1431
+ end.should_not_be_updated
833
1432
  end
834
1433
 
835
1434
  it "with a < pin in the name and non-matching rpm installed it downgrades" do
836
1435
  preinstall("chef_rpm-1.10-1.#{pkg_arch}.rpm")
837
- yum_package("chef_rpm < 1.10") do
838
- allow_downgrade true
1436
+ yum_package "chef_rpm < 1.10" do
839
1437
  options default_options
840
1438
  action :upgrade
841
1439
  end.should_be_updated
842
1440
  expect_matching_installed_version("^chef_rpm-1.2-1.#{pkg_arch}$")
1441
+ yum_package "chef_rpm < 1.10" do
1442
+ options default_options
1443
+ action :upgrade
1444
+ end.should_not_be_updated
843
1445
  end
844
1446
  end
845
1447
  end
846
1448
 
847
1449
  describe ":remove" do
1450
+
1451
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
1452
+ # python helper periodically before every top level context to get more FDs.
1453
+ before(:all) do
1454
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
1455
+ end
1456
+
848
1457
  context "vanilla use case" do
849
1458
  it "does nothing if the package is not installed" do
850
1459
  flush_cache
@@ -885,6 +1494,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
885
1494
  action :remove
886
1495
  end.should_be_updated
887
1496
  expect_matching_installed_version("^package chef_rpm is not installed$")
1497
+ yum_package "chef_rpm" do
1498
+ options default_options
1499
+ action :remove
1500
+ end.should_not_be_updated
888
1501
  end
889
1502
 
890
1503
  it "removes the package if the i686 package is installed", :intel_64bit do
@@ -895,6 +1508,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
895
1508
  action :remove
896
1509
  end.should_be_updated
897
1510
  expect_matching_installed_version("^package chef_rpm is not installed$")
1511
+ yum_package "chef_rpm" do
1512
+ options default_options
1513
+ action :remove
1514
+ end.should_not_be_updated
898
1515
  end
899
1516
 
900
1517
  it "removes the package if the prior version i686 package is installed", :intel_64bit do
@@ -905,6 +1522,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
905
1522
  action :remove
906
1523
  end.should_be_updated
907
1524
  expect_matching_installed_version("^package chef_rpm is not installed$")
1525
+ yum_package "chef_rpm" do
1526
+ options default_options
1527
+ action :remove
1528
+ end.should_not_be_updated
908
1529
  end
909
1530
  end
910
1531
 
@@ -925,6 +1546,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
925
1546
  action :remove
926
1547
  end.should_be_updated
927
1548
  expect_matching_installed_version("^package chef_rpm is not installed$")
1549
+ yum_package "chef_rpm.#{pkg_arch}" do
1550
+ options default_options
1551
+ action :remove
1552
+ end.should_not_be_updated
928
1553
  end
929
1554
 
930
1555
  it "removes the package if the prior version package is installed" do
@@ -934,6 +1559,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
934
1559
  action :remove
935
1560
  end.should_be_updated
936
1561
  expect_matching_installed_version("^package chef_rpm is not installed$")
1562
+ yum_package "chef_rpm.#{pkg_arch}" do
1563
+ options default_options
1564
+ action :remove
1565
+ end.should_not_be_updated
937
1566
  end
938
1567
 
939
1568
  it "does nothing if the i686 package is installed" do
@@ -963,6 +1592,10 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
963
1592
  action :remove
964
1593
  end.should_be_updated
965
1594
  expect_matching_installed_version("^chef_rpm-1.10-1.#{pkg_arch}$")
1595
+ yum_package "chef_rpm.i686" do
1596
+ options default_options
1597
+ action :remove
1598
+ end.should_not_be_updated
966
1599
  end
967
1600
  end
968
1601
 
@@ -975,11 +1608,22 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
975
1608
  action :remove
976
1609
  end.should_be_updated
977
1610
  expect_matching_installed_version("^package chef_rpm is not installed$")
1611
+ yum_package "chef_rpm" do
1612
+ options "--nogpgcheck"
1613
+ action :remove
1614
+ end.should_not_be_updated
978
1615
  end
979
1616
  end
980
1617
  end
981
1618
 
982
1619
  describe ":lock and :unlock" do
1620
+
1621
+ # XXX: this is necessary for RHEL6 due to a file descriptor leak so we need to bounce the
1622
+ # python helper periodically before every top level context to get more FDs.
1623
+ before(:all) do
1624
+ Chef::Provider::Package::Yum::PythonHelper.instance.restart
1625
+ end
1626
+
983
1627
  before(:all) do
984
1628
  shell_out!("yum -y install yum-versionlock")
985
1629
  end
@@ -990,17 +1634,21 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
990
1634
 
991
1635
  it "locks an rpm" do
992
1636
  flush_cache
993
- yum_package("chef_rpm") do
1637
+ yum_package "chef_rpm" do
994
1638
  options default_options
995
1639
  action :lock
996
1640
  end.should_be_updated
997
1641
  expect(shell_out("yum versionlock list").stdout.chomp).to match("^0:chef_rpm-")
1642
+ yum_package "chef_rpm" do
1643
+ options default_options
1644
+ action :lock
1645
+ end.should_not_be_updated
998
1646
  end
999
1647
 
1000
1648
  it "does not lock if its already locked" do
1001
1649
  flush_cache
1002
1650
  shell_out!("yum versionlock add chef_rpm")
1003
- yum_package("chef_rpm") do
1651
+ yum_package "chef_rpm" do
1004
1652
  options default_options
1005
1653
  action :lock
1006
1654
  end.should_not_be_updated
@@ -1010,16 +1658,20 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
1010
1658
  it "unlocks an rpm" do
1011
1659
  flush_cache
1012
1660
  shell_out!("yum versionlock add chef_rpm")
1013
- yum_package("chef_rpm") do
1661
+ yum_package "chef_rpm" do
1014
1662
  options default_options
1015
1663
  action :unlock
1016
1664
  end.should_be_updated
1017
1665
  expect(shell_out("yum versionlock list").stdout.chomp).not_to match("^0:chef_rpm-")
1666
+ yum_package "chef_rpm" do
1667
+ options default_options
1668
+ action :unlock
1669
+ end.should_not_be_updated
1018
1670
  end
1019
1671
 
1020
1672
  it "does not unlock an already locked rpm" do
1021
1673
  flush_cache
1022
- yum_package("chef_rpm") do
1674
+ yum_package "chef_rpm" do
1023
1675
  options default_options
1024
1676
  action :unlock
1025
1677
  end.should_not_be_updated
@@ -1028,21 +1680,29 @@ describe Chef::Resource::YumPackage, :requires_root, external: exclude_test do
1028
1680
 
1029
1681
  it "check that we can lock based on provides" do
1030
1682
  flush_cache
1031
- yum_package("chef_rpm_provides") do
1683
+ yum_package "chef_rpm_provides" do
1032
1684
  options default_options
1033
1685
  action :lock
1034
1686
  end.should_be_updated
1035
1687
  expect(shell_out("yum versionlock list").stdout.chomp).to match("^0:chef_rpm-")
1688
+ yum_package "chef_rpm_provides" do
1689
+ options default_options
1690
+ action :lock
1691
+ end.should_not_be_updated
1036
1692
  end
1037
1693
 
1038
1694
  it "check that we can unlock based on provides" do
1039
1695
  flush_cache
1040
1696
  shell_out!("yum versionlock add chef_rpm")
1041
- yum_package("chef_rpm_provides") do
1697
+ yum_package "chef_rpm_provides" do
1042
1698
  options default_options
1043
1699
  action :unlock
1044
1700
  end.should_be_updated
1045
1701
  expect(shell_out("yum versionlock list").stdout.chomp).not_to match("^0:chef_rpm-")
1702
+ yum_package "chef_rpm_provides" do
1703
+ options default_options
1704
+ action :unlock
1705
+ end.should_not_be_updated
1046
1706
  end
1047
1707
  end
1048
1708
  end