puppet 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/ext/build_defaults.yaml +1 -1
  3. data/ext/redhat/puppet.spec.erb +8 -8
  4. data/lib/puppet/defaults.rb +5 -1
  5. data/lib/puppet/indirector/resource_type/parser.rb +58 -38
  6. data/lib/puppet/metatype/manager.rb +0 -1
  7. data/lib/puppet/network/http/connection.rb +8 -0
  8. data/lib/puppet/network/http/webrick.rb +4 -1
  9. data/lib/puppet/node/environment.rb +13 -32
  10. data/lib/puppet/parser/compiler.rb +1 -2
  11. data/lib/puppet/parser/functions/each.rb +4 -4
  12. data/lib/puppet/parser/type_loader.rb +20 -1
  13. data/lib/puppet/provider/package/dpkg.rb +13 -54
  14. data/lib/puppet/provider/package/rpm.rb +7 -11
  15. data/lib/puppet/transaction/resource_harness.rb +17 -17
  16. data/lib/puppet/type.rb +83 -117
  17. data/lib/puppet/type/exec.rb +42 -20
  18. data/lib/puppet/type/file.rb +4 -0
  19. data/lib/puppet/type/interface.rb +4 -0
  20. data/lib/puppet/type/mount.rb +4 -2
  21. data/lib/puppet/type/package.rb +4 -0
  22. data/lib/puppet/type/schedule.rb +14 -13
  23. data/lib/puppet/type/service.rb +9 -6
  24. data/lib/puppet/type/stage.rb +17 -9
  25. data/lib/puppet/type/user.rb +1 -1
  26. data/lib/puppet/util/monkey_patches.rb +16 -11
  27. data/lib/puppet/util/rdoc/code_objects.rb +4 -0
  28. data/lib/puppet/util/windows.rb +1 -0
  29. data/lib/puppet/util/windows/file.rb +36 -13
  30. data/lib/puppet/util/windows/process.rb +7 -4
  31. data/lib/puppet/util/windows/registry.rb +35 -1
  32. data/lib/puppet/util/windows/string.rb +14 -0
  33. data/lib/puppet/version.rb +1 -1
  34. data/spec/integration/util_spec.rb +31 -0
  35. data/spec/unit/node/environment_spec.rb +5 -13
  36. data/spec/unit/provider/package/aptitude_spec.rb +13 -10
  37. data/spec/unit/provider/package/aptrpm_spec.rb +2 -2
  38. data/spec/unit/provider/package/dpkg_spec.rb +93 -234
  39. data/spec/unit/provider/package/rpm_spec.rb +50 -74
  40. data/spec/unit/provider/package/yum_spec.rb +5 -6
  41. data/spec/unit/transaction/resource_harness_spec.rb +111 -3
  42. data/spec/unit/type/user_spec.rb +7 -5
  43. data/spec/unit/util/windows/registry_spec.rb +54 -0
  44. data/spec/unit/util/windows/string_spec.rb +54 -0
  45. data/tasks/benchmark.rake +110 -0
  46. data/tasks/ci.rake +1 -1
  47. metadata +11 -15
@@ -1,4 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
+ # encoding: UTF-8
2
3
  require 'spec_helper'
3
4
 
4
5
  describe Puppet::Type.type(:user) do
@@ -339,12 +340,13 @@ describe Puppet::Type.type(:user) do
339
340
  end
340
341
  end
341
342
 
342
- describe "when managing comment on Ruby 1.9", :if => String.respond_to?(:encode) do
343
+ describe "when managing comment on Ruby 1.9", :if => String.method_defined?(:encode) do
343
344
  it "should force value encoding to ASCII-8BIT" do
344
- value = 'abcd'.encode(Encoding::UTF_8)
345
- comment = described_class.new(:name => 'foo', :comment => value)
346
- comment[:comment].should == 'abcd'
347
- comment[:comment].encoding.should == Encoding::ASCII_8BIT
345
+ value = 'abcd'
346
+ value.encoding.should == Encoding::UTF_8
347
+ user = described_class.new(:name => 'foo', :comment => value)
348
+ user[:comment].encoding.should == Encoding::ASCII_8BIT
349
+ user[:comment].should == value.force_encoding(Encoding::ASCII_8BIT)
348
350
  end
349
351
  end
350
352
 
@@ -82,5 +82,59 @@ describe Puppet::Util::Windows::Registry, :if => Puppet::Util::Platform.windows?
82
82
 
83
83
  subject.values(key).should == {}
84
84
  end
85
+
86
+ context "when reading non-ASCII values" do
87
+ # registered trademark symbol
88
+ let(:data) do
89
+ str = [0xAE].pack("C")
90
+ str.force_encoding('US-ASCII')
91
+ str
92
+ end
93
+
94
+ def expects_registry_value(array)
95
+ key.expects(:each_value).multiple_yields(array)
96
+
97
+ subject.values(key).first[1]
98
+ end
99
+
100
+ # The win32console gem applies this regex to strip out ANSI escape
101
+ # sequences. If the registered trademark had encoding US-ASCII,
102
+ # the regex would fail with 'invalid byte sequence in US-ASCII'
103
+ def strip_ansi_escapes(value)
104
+ value.sub(/([^\e]*)?\e([\[\(])([0-9\;\=]*)([a-zA-Z@])(.*)/, '\5')
105
+ end
106
+
107
+ it "encodes REG_SZ according to the current code page" do
108
+ reg_value = ['string', Win32::Registry::REG_SZ, data]
109
+
110
+ value = expects_registry_value(reg_value)
111
+
112
+ strip_ansi_escapes(value)
113
+ end
114
+
115
+ it "encodes REG_EXPAND_SZ based on the current code page" do
116
+ reg_value = ['expand', Win32::Registry::REG_EXPAND_SZ, "%SYSTEMROOT%\\#{data}"]
117
+
118
+ value = expects_registry_value(reg_value)
119
+
120
+ strip_ansi_escapes(value)
121
+ end
122
+
123
+ it "encodes REG_MULTI_SZ based on the current code page" do
124
+ reg_value = ['multi', Win32::Registry::REG_MULTI_SZ, ["one#{data}", "two#{data}"]]
125
+
126
+ value = expects_registry_value(reg_value)
127
+
128
+ value.each { |str| strip_ansi_escapes(str) }
129
+ end
130
+
131
+ it "passes REG_DWORD through" do
132
+ reg_value = ['dword', Win32::Registry::REG_DWORD, '1']
133
+
134
+ value = expects_registry_value(reg_value)
135
+
136
+ Integer(value).should == 1
137
+ end
138
+ end
85
139
  end
86
140
  end
@@ -0,0 +1,54 @@
1
+ # encoding: UTF-8
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'spec_helper'
5
+ require 'puppet/util/windows'
6
+
7
+ describe "Puppet::Util::Windows::String", :if => Puppet.features.microsoft_windows? do
8
+ UTF16_NULL = [0, 0]
9
+
10
+ def wide_string(str)
11
+ Puppet::Util::Windows::String.wide_string(str)
12
+ end
13
+
14
+ def converts_to_wide_string(string_value)
15
+ expected = string_value.encode(Encoding::UTF_16LE)
16
+ expected_bytes = expected.bytes.to_a + UTF16_NULL
17
+
18
+ wide_string(string_value).bytes.to_a.should == expected_bytes
19
+ end
20
+
21
+ context "wide_string" do
22
+ it "should return encoding of UTF-16LE" do
23
+ wide_string("bob").encoding.should == Encoding::UTF_16LE
24
+ end
25
+
26
+ it "should return valid encoding" do
27
+ wide_string("bob").valid_encoding?.should be_true
28
+ end
29
+
30
+ it "should convert an ASCII string" do
31
+ converts_to_wide_string("bob".encode(Encoding::US_ASCII))
32
+ end
33
+
34
+ it "should convert a UTF-8 string" do
35
+ converts_to_wide_string("bob".encode(Encoding::UTF_8))
36
+ end
37
+
38
+ it "should convert a UTF-16LE string" do
39
+ converts_to_wide_string("bob\u00E8".encode(Encoding::UTF_16LE))
40
+ end
41
+
42
+ it "should convert a UTF-16BE string" do
43
+ converts_to_wide_string("bob\u00E8".encode(Encoding::UTF_16BE))
44
+ end
45
+
46
+ it "should convert an UTF-32LE string" do
47
+ converts_to_wide_string("bob\u00E8".encode(Encoding::UTF_32LE))
48
+ end
49
+
50
+ it "should convert an UTF-32BE string" do
51
+ converts_to_wide_string("bob\u00E8".encode(Encoding::UTF_32BE))
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,110 @@
1
+ require 'benchmark'
2
+ require 'tmpdir'
3
+ require 'csv'
4
+
5
+ namespace :benchmark do
6
+ def generate_scenario_tasks(location, name)
7
+ desc File.read(File.join(location, 'description'))
8
+ task name => "#{name}:run"
9
+
10
+ namespace name do
11
+ task :setup do
12
+ ENV['ITERATIONS'] ||= '10'
13
+ ENV['SIZE'] ||= '100'
14
+ ENV['TARGET'] ||= Dir.mktmpdir(name)
15
+ ENV['TARGET'] = File.expand_path(ENV['TARGET'])
16
+
17
+ mkdir_p(ENV['TARGET'])
18
+
19
+ require File.expand_path(File.join(location, 'benchmarker.rb'))
20
+
21
+ @benchmark = Benchmarker.new(ENV['TARGET'], ENV['SIZE'].to_i)
22
+ end
23
+
24
+ desc "Generate the #{name} scenario."
25
+ task :generate => :setup do
26
+ @benchmark.generate
27
+ @benchmark.setup
28
+ end
29
+
30
+ desc "Run the #{name} scenario."
31
+ task :run => :generate do
32
+ format = if RUBY_VERSION =~ /^1\.8/
33
+ Benchmark::FMTSTR
34
+ else
35
+ Benchmark::FORMAT
36
+ end
37
+
38
+ report = []
39
+ Benchmark.benchmark(Benchmark::CAPTION, 10, format, "> total:", "> avg:") do |b|
40
+ times = []
41
+ ENV['ITERATIONS'].to_i.times do |i|
42
+ start_time = Time.now.to_i
43
+ times << b.report("Run #{i + 1}") do
44
+ @benchmark.run
45
+ end
46
+ report << [to_millis(start_time), to_millis(times.last.real), 200, true, name]
47
+ end
48
+
49
+ sum = times.inject(Benchmark::Tms.new, &:+)
50
+
51
+ [sum, sum / times.length]
52
+ end
53
+
54
+ write_csv("#{name}.samples",
55
+ %w{timestamp elapsed responsecode success name},
56
+ report)
57
+ end
58
+
59
+ desc "Profile a single run of the #{name} scenario."
60
+ task :profile => :generate do
61
+ require 'ruby-prof'
62
+
63
+ result = RubyProf.profile do
64
+ @benchmark.run
65
+ end
66
+
67
+ printer = RubyProf::CallTreePrinter.new(result)
68
+ File.open(File.join("callgrind.#{name}.#{Time.now.to_i}.trace"), "w") do |f|
69
+ printer.print(f)
70
+ end
71
+ end
72
+
73
+ def to_millis(seconds)
74
+ (seconds * 1000).round
75
+ end
76
+
77
+ def write_csv(file, header, data)
78
+ CSV.open(file, 'w') do |csv|
79
+ csv << header
80
+ data.each do |line|
81
+ csv << line
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ scenarios = []
89
+ Dir.glob('benchmarks/*') do |location|
90
+ name = File.basename(location)
91
+ scenarios << name
92
+ generate_scenario_tasks(location, File.basename(location))
93
+ end
94
+
95
+ namespace :all do
96
+ desc "Profile all of the scenarios. (#{scenarios.join(', ')})"
97
+ task :profile do
98
+ scenarios.each do |name|
99
+ sh "rake benchmark:#{name}:profile"
100
+ end
101
+ end
102
+
103
+ desc "Run all of the scenarios. (#{scenarios.join(', ')})"
104
+ task :run do
105
+ scenarios.each do |name|
106
+ sh "rake benchmark:#{name}:run"
107
+ end
108
+ end
109
+ end
110
+ end
@@ -4,7 +4,7 @@ require 'time'
4
4
  namespace "ci" do
5
5
  task :spec do
6
6
  ENV["LOG_SPEC_ORDER"] = "true"
7
- sh %{rspec -r yarjuf -f JUnit -o result.xml -fd spec}
7
+ sh %{rspec -r yarjuf -f JUnit -o result.xml -fp spec}
8
8
  end
9
9
 
10
10
  desc "Tar up the acceptance/ directory so that package test runs have tests to run against."
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
5
- prerelease:
4
+ version: 3.4.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Puppet Labs
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: facter
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: hiera
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rgen
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -984,6 +977,7 @@ files:
984
977
  - lib/puppet/util/windows/security.rb
985
978
  - lib/puppet/util/windows/security_descriptor.rb
986
979
  - lib/puppet/util/windows/sid.rb
980
+ - lib/puppet/util/windows/string.rb
987
981
  - lib/puppet/util/windows/user.rb
988
982
  - lib/puppet/util/yaml.rb
989
983
  - lib/puppet/util/zaml.rb
@@ -1225,6 +1219,7 @@ files:
1225
1219
  - ext/windows/service/daemon.bat
1226
1220
  - ext/windows/service/daemon.rb
1227
1221
  - ext/yaml_nodes.rb
1222
+ - tasks/benchmark.rake
1228
1223
  - tasks/ci.rake
1229
1224
  - tasks/manpages.rake
1230
1225
  - tasks/parser.rake
@@ -2195,6 +2190,7 @@ files:
2195
2190
  - spec/unit/util/windows/root_certs_spec.rb
2196
2191
  - spec/unit/util/windows/security_descriptor_spec.rb
2197
2192
  - spec/unit/util/windows/sid_spec.rb
2193
+ - spec/unit/util/windows/string_spec.rb
2198
2194
  - spec/unit/util/yaml_spec.rb
2199
2195
  - spec/unit/util/zaml_spec.rb
2200
2196
  - spec/unit/util_spec.rb
@@ -2202,6 +2198,7 @@ files:
2202
2198
  - spec/watchr.rb
2203
2199
  homepage: https://github.com/puppetlabs/puppet
2204
2200
  licenses: []
2201
+ metadata: {}
2205
2202
  post_install_message:
2206
2203
  rdoc_options:
2207
2204
  - --title
@@ -2212,22 +2209,20 @@ rdoc_options:
2212
2209
  require_paths:
2213
2210
  - lib
2214
2211
  required_ruby_version: !ruby/object:Gem::Requirement
2215
- none: false
2216
2212
  requirements:
2217
- - - ! '>='
2213
+ - - '>='
2218
2214
  - !ruby/object:Gem::Version
2219
2215
  version: '0'
2220
2216
  required_rubygems_version: !ruby/object:Gem::Requirement
2221
- none: false
2222
2217
  requirements:
2223
- - - ! '>='
2218
+ - - '>='
2224
2219
  - !ruby/object:Gem::Version
2225
2220
  version: '0'
2226
2221
  requirements: []
2227
2222
  rubyforge_project: puppet
2228
- rubygems_version: 1.8.23
2223
+ rubygems_version: 2.0.3
2229
2224
  signing_key:
2230
- specification_version: 3
2225
+ specification_version: 4
2231
2226
  summary: Puppet, an automated configuration management tool
2232
2227
  test_files:
2233
2228
  - spec/fixtures/faulty_face/puppet/face/syntax.rb
@@ -3197,6 +3192,7 @@ test_files:
3197
3192
  - spec/unit/util/windows/root_certs_spec.rb
3198
3193
  - spec/unit/util/windows/security_descriptor_spec.rb
3199
3194
  - spec/unit/util/windows/sid_spec.rb
3195
+ - spec/unit/util/windows/string_spec.rb
3200
3196
  - spec/unit/util/yaml_spec.rb
3201
3197
  - spec/unit/util/zaml_spec.rb
3202
3198
  - spec/unit/util_spec.rb