beaker 1.14.1 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -689,10 +689,8 @@ module Beaker
689
689
 
690
690
  # @!visibility private
691
691
  def bounce_service host, service, curl_retries = 120
692
- # Any reason to not
693
- # host.exec puppet_resource( 'service', service, 'ensure=stopped' )
694
- # host.exec puppet_resource( 'service', service, 'ensure=running' )
695
- host.exec( Command.new( "#{host['service-prefix']}#{service} restart" ) )
692
+ host.exec puppet_resource( 'service', service, 'ensure=stopped' )
693
+ host.exec puppet_resource( 'service', service, 'ensure=running' )
696
694
  curl_with_retries(" #{service} ", host, "https://localhost:8140", [35, 60], curl_retries)
697
695
  end
698
696
 
@@ -603,7 +603,7 @@ module Beaker
603
603
  host.install_package('lsb-release')
604
604
  end
605
605
 
606
- if ! host.check_for_package 'curl'
606
+ if ! host.check_for_command 'curl'
607
607
  on host, 'apt-get install -y curl'
608
608
  end
609
609
 
@@ -688,7 +688,7 @@ module Beaker
688
688
  # @raise [StandardError] if gem does not exist on target host
689
689
  # @api private
690
690
  def install_puppet_from_gem( host, opts )
691
- if host.check_for_package( 'gem' )
691
+ if host.check_for_command( 'gem' )
692
692
  if opts[:facter_version]
693
693
  on host, "gem install facter -v#{opts[:facter_version]}"
694
694
  end
@@ -19,7 +19,6 @@ module Unix
19
19
  h.merge({
20
20
  'user' => 'root',
21
21
  'group' => 'pe-puppet',
22
- 'service-prefix'=> '/etc/init.d/',
23
22
  'master-start-curl-retries' => 120,
24
23
  'puppetservice' => 'pe-httpd',
25
24
  'puppetpath' => '/etc/puppetlabs/puppet',
@@ -143,8 +143,9 @@ module Beaker
143
143
  else
144
144
  if string.respond_to?( :encode )
145
145
  # We're running in >= 1.9 and we'll need to convert
146
- # Remove invalide and undefined UTF-8 character encodings
147
- string.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
146
+ # Remove invalid and undefined UTF-8 character encodings
147
+ encoding = Encoding ? Encoding.default_external : "UTF-8"
148
+ return string.encode(encoding, string.encoding, :invalid => :replace, :undef => :replace, :replace => '')
148
149
  else
149
150
  # We're running 1.8, do nothing
150
151
  string
@@ -1,10 +1,11 @@
1
1
  module Beaker
2
- #This class create a Platform object inheriting from String. It supports all String methods while adding
3
- #several platform-specific use cases.
2
+ # This class create a Platform object inheriting from String. It supports
3
+ # all String methods while adding several platform-specific use cases.
4
4
  class Platform < String
5
- #Supported platforms
5
+ # Supported platforms
6
6
  PLATFORMS = /^(osx|centos|fedora|debian|oracle|redhat|scientific|sles|ubuntu|windows|solaris|aix|el)\-.+\-.+$/
7
- #Platform version numbers vs. codenames conversion hash
7
+
8
+ # Platform version numbers vs. codenames conversion hash
8
9
  PLATFORM_VERSION_CODES =
9
10
  { :debian => { "wheezy" => "7",
10
11
  "squeeze" => "6",
@@ -14,21 +15,26 @@ module Beaker
14
15
  "raring" => "1304",
15
16
  "quantal" => "1210",
16
17
  "precise" => "1204",
18
+ "lucid" => "1004",
17
19
  },
18
20
  }
19
21
 
20
22
  # A string with the name of the platform.
21
23
  attr_reader :variant
24
+
22
25
  # A string with the version number of the platform.
23
26
  attr_reader :version
27
+
24
28
  # A string with the codename of the platform+version, nil on platforms
25
29
  # without codenames.
26
30
  attr_reader :codename
31
+
27
32
  # A string with the cpu architecture of the platform.
28
33
  attr_reader :arch
29
34
 
30
- #Creates the Platform object. Checks to ensure that the platform String provided meets the platform
31
- #formatting rules. Platforms name must be of the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of:
35
+ # Creates the Platform object. Checks to ensure that the platform String
36
+ # provided meets the platform formatting rules. Platforms name must be of
37
+ # the format /^OSFAMILY-VERSION-ARCH.*$/ where OSFAMILY is one of:
32
38
  # * osx
33
39
  # * centos
34
40
  # * fedora
@@ -33,8 +33,9 @@ module Beaker
33
33
  def convert string
34
34
  if string.respond_to?( :encode )
35
35
  # We're running in >= 1.9 and we'll need to convert
36
- # Remove invalide and undefined UTF-8 character encodings
37
- return string.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
36
+ # Remove invalid and undefined UTF-8 character encodings
37
+ encoding = Encoding ? Encoding.default_external : "UTF-8"
38
+ return string.encode(encoding, string.encoding, :invalid => :replace, :undef => :replace, :replace => '')
38
39
  else
39
40
  # We're running in < 1.9 and Ruby doesn't care
40
41
  return string
@@ -1,5 +1,5 @@
1
1
  module Beaker
2
2
  module Version
3
- STRING = '1.14.1'
3
+ STRING = '1.15.0'
4
4
  end
5
5
  end
@@ -761,7 +761,7 @@ describe ClassMixedWithDSLHelpers do
761
761
  let(:test_case_path) { 'testcase/path' }
762
762
  let(:tmpdir_path) { '/tmp/tmpdir' }
763
763
  let(:puppet_path) { '/puppet/path' }
764
- let(:puppetservice) { @ps || nil }
764
+ let(:puppetservice) { nil }
765
765
  let(:is_pe) { false }
766
766
  let(:host) do
767
767
  FakeHost.new(:pe => is_pe,
@@ -805,7 +805,8 @@ describe ClassMixedWithDSLHelpers do
805
805
  it 'bounces puppet twice' do
806
806
  subject.stub(:curl_with_retries)
807
807
  subject.with_puppet_running_on(host, {})
808
- expect(host).to execute_commands_matching(/#{@ps} restart/).exactly(2).times
808
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).exactly(2).times
809
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).exactly(2).times
809
810
  end
810
811
 
811
812
  it 'yield to a block after bouncing service' do
@@ -813,11 +814,13 @@ describe ClassMixedWithDSLHelpers do
813
814
  subject.stub(:curl_with_retries)
814
815
  expect do
815
816
  subject.with_puppet_running_on(host, {}) do
816
- expect(host).to execute_commands_matching(/#{@ps} restart/).once
817
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).once
818
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).once
817
819
  execution += 1
818
820
  end
819
821
  end.to change { execution }.by(1)
820
- expect(host).to execute_commands_matching(/#{@ps} restart/).exactly(2).times
822
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=stopped/).exactly(2).times
823
+ expect(host).to execute_commands_matching(/puppet resource service #{puppetservice} ensure=running/).exactly(2).times
821
824
  end
822
825
  end
823
826
 
@@ -74,6 +74,11 @@ module Beaker
74
74
  expect( platform.with_version_codename ).to be === 'ubuntu-quantal-xxx'
75
75
  end
76
76
 
77
+ it "can convert ubuntu-10.04-xxx to ubuntu-lucid-xxx" do
78
+ @name = 'ubuntu-10.04-xxx'
79
+ expect( platform.with_version_codename ).to be === 'ubuntu-lucid-xxx'
80
+ end
81
+
77
82
  it "leaves centos-7-xxx alone" do
78
83
  @name = 'centos-7-xxx'
79
84
  expect( platform.with_version_codename ).to be === 'centos-7-xxx'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppetlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -332,6 +332,7 @@ files:
332
332
  - .travis.yml
333
333
  - DOCUMENTING.md
334
334
  - Gemfile
335
+ - HISTORY.md
335
336
  - LICENSE
336
337
  - README.md
337
338
  - Rakefile