mcollective-client 1.3.3 → 2.0.0

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

Potentially problematic release.


This version of mcollective-client might be problematic. Click here for more details.

@@ -0,0 +1,183 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+ require File.dirname(__FILE__) + '/../../../../../plugins/mcollective/pluginpackager/rpmpackage_packager.rb'
4
+
5
+ module MCollective
6
+ module PluginPackager
7
+ describe RpmpackagePackager do
8
+ let(:maketmpdir) do
9
+ tmpdir = Dir.mktmpdir("mc-test")
10
+ @tmpdirs << tmpdir
11
+ tmpdir
12
+ end
13
+
14
+ before :all do
15
+ @tmpdirs = []
16
+ end
17
+
18
+ before :each do
19
+ PluginPackager.stubs(:build_tool?).with("rpmbuild").returns(true)
20
+ @plugin = mock()
21
+ @plugin.stubs(:iteration).returns("1")
22
+ @plugin.stubs(:metadata).returns({:name => "test", :version => "1"})
23
+ end
24
+
25
+ after :all do
26
+ @tmpdirs.each{|tmpdir| FileUtils.rm_rf tmpdir if File.directory? tmpdir}
27
+ end
28
+
29
+ describe "#initialize" do
30
+
31
+ it "should raise and exception if rpm-build is not present" do
32
+ PluginPackager.expects(:build_tool?).with("rpmbuild").returns(false)
33
+ expect{
34
+ RpmpackagePackager.new("plugin")
35
+ }.to raise_exception RuntimeError, "package 'rpm-build' is not installed"
36
+ end
37
+
38
+ it "should set the correct libdir" do
39
+ packager = RpmpackagePackager.new("plugin")
40
+ packager.libdir.should == "/usr/libexec/mcollective/mcollective/"
41
+
42
+ packager = RpmpackagePackager.new("plugin", "/tmp/")
43
+ packager.libdir.should == "/tmp/"
44
+ end
45
+
46
+ end
47
+
48
+ describe "#create_packages" do
49
+ before :each do
50
+ @packager = RpmpackagePackager.new(@plugin)
51
+ @packager.tmpdir = maketmpdir
52
+ @packager.stubs(:create_package)
53
+ @packager.stubs(:cleanup_tmpdirs)
54
+ @plugin.stubs(:packagedata).returns(:test => {:files => ["test.rb"]})
55
+ @packager.stubs(:prepare_tmpdirs)
56
+ Dir.stubs(:mktmpdir)
57
+ end
58
+
59
+ it "should set the package instance variables" do
60
+ @packager.create_packages
61
+ @packager.current_package_type.should == :test
62
+ @packager.current_package_data.should == {:files => ["test.rb"]}
63
+ @packager.current_package_name.should == "mcollective-test-test"
64
+ end
65
+
66
+ it "should create the build dir" do
67
+ @packager.expects(:prepare_tmpdirs)
68
+ @packager.create_packages
69
+ end
70
+
71
+ it "should create packages" do
72
+ @packager.expects(:create_package)
73
+ @packager.create_packages
74
+ end
75
+
76
+ end
77
+
78
+ describe "#create_package" do
79
+ before :each do
80
+ @packager = RpmpackagePackager.new(@plugin)
81
+ end
82
+
83
+ it "should create the package" do
84
+ PluginPackager.expects(:safe_system).with("rpmbuild -bb /tmp/SPECS/test.spec --buildroot /tmp/BUILD")
85
+ FileUtils.expects(:cp)
86
+ @packager.tmpdir = "/tmp"
87
+ @packager.verbose = "true"
88
+ @packager.expects(:make_spec_file)
89
+ @packager.current_package_name = "mcollective-testplugin-test"
90
+ @packager.expects(:puts).with("Created package mcollective-testplugin-test")
91
+ @packager.create_package(:test, {:files => ["foo.rb"]})
92
+ end
93
+
94
+ it "should sign the package if a signature is given" do
95
+ PluginPackager.expects(:safe_system).with("rpmbuild -bb --sign /tmp/SPECS/test.spec --buildroot /tmp/BUILD")
96
+ FileUtils.expects(:cp)
97
+ @packager.signature = true
98
+ @packager.tmpdir = "/tmp"
99
+ @packager.verbose = "true"
100
+ @packager.expects(:make_spec_file)
101
+ @packager.current_package_name = "mcollective-testplugin-test"
102
+ @packager.expects(:puts).with("Created package mcollective-testplugin-test")
103
+ @packager.create_package(:test, {:files => ["foo.rb"]})
104
+ end
105
+
106
+ it "should raise an error if the package can't be built" do
107
+ @packager = RpmpackagePackager.new(@plugin)
108
+ @packager.expects(:make_spec_file)
109
+ PluginPackager.stubs(:do_quietly?).raises("foo")
110
+ expect{
111
+ @packager.create_package("", "")
112
+ }.to raise_error RuntimeError, "Could not build package. Reason - foo"
113
+ end
114
+ end
115
+
116
+ describe "#make_spec_file" do
117
+ before :each do
118
+ @packager = RpmpackagePackager.new("package")
119
+ end
120
+
121
+ it "should raise an exception if specfile cannot be built" do
122
+ File.expects(:dirname).raises("test error")
123
+ expect{
124
+ @packager.make_spec_file
125
+ }.to raise_error RuntimeError, "Could not create specfile - test error"
126
+ end
127
+
128
+ it "should create the specfile from the erb" do
129
+ File.stubs(:read).returns("specfile")
130
+ @packager.current_package_type = "test"
131
+ @packager.tmpdir = maketmpdir
132
+ Dir.mkdir(File.join(@packager.tmpdir, "SPECS"))
133
+ @packager.make_spec_file
134
+ File.read(File.join(@packager.tmpdir, "SPECS", "test.spec")).should == "specfile"
135
+ end
136
+ end
137
+
138
+ describe "#prepare_tmpdirs" do
139
+ it "should create the tmp dirs and cp the package files" do
140
+ @plugin.stubs(:target_path).returns("")
141
+ packager = RpmpackagePackager.new(@plugin)
142
+ packager.expects(:make_rpm_dirs)
143
+ FileUtils.expects(:mkdir_p)
144
+ File.stubs(:join).returns("/target")
145
+ FileUtils.expects(:cp_r).with("test.rb", "/target")
146
+ packager.prepare_tmpdirs({:files => ["test.rb"]})
147
+ end
148
+ end
149
+
150
+ describe "#make_rpm_dirs" do
151
+ before :each do
152
+ @packager = RpmpackagePackager.new("package")
153
+ end
154
+
155
+ it "should raise an exception if a directory can't be created" do
156
+ File.expects(:join).raises("test error")
157
+ expect{
158
+ @packager.make_rpm_dirs
159
+ }.to raise_error RuntimeError, "Could not create BUILD directory - test error"
160
+ end
161
+
162
+ it "should create the correct RPM build directories" do
163
+ @packager.tmpdir = maketmpdir
164
+ @packager.make_rpm_dirs
165
+ File.directory?(File.join(@packager.tmpdir, "SPECS")).should == true
166
+ File.directory?(File.join(@packager.tmpdir, "SOURCES")).should == true
167
+ File.directory?(File.join(@packager.tmpdir, "SRPMS")).should == true
168
+ File.directory?(File.join(@packager.tmpdir, "BUILD")).should == true
169
+ File.directory?(File.join(@packager.tmpdir, "RPMS")).should == true
170
+ end
171
+ end
172
+
173
+ describe "#cleanup_tmpdirs" do
174
+ it "should remove the temp directories" do
175
+ packager = RpmpackagePackager.new("package")
176
+ packager.tmpdir = maketmpdir
177
+ packager.cleanup_tmpdirs
178
+ File.directory?(packager.tmpdir).should == false
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
@@ -159,9 +159,9 @@ module MCollective
159
159
  end
160
160
 
161
161
  it "should not invalid limits to be set" do
162
- expect { @client.limit_targets = "a" }.to raise_error /Invalid/
163
- expect { @client.limit_targets = "%1" }.to raise_error /Invalid/
164
- expect { @client.limit_targets = "1.1" }.to raise_error /Invalid/
162
+ expect { @client.limit_targets = "a" }.to raise_error(/Invalid/)
163
+ expect { @client.limit_targets = "%1" }.to raise_error(/Invalid/)
164
+ expect { @client.limit_targets = "1.1" }.to raise_error(/Invalid/)
165
165
  end
166
166
  end
167
167
 
@@ -9,7 +9,7 @@ module MCollective
9
9
  it "should fail for non array data" do
10
10
  expect {
11
11
  Helpers.extract_hosts_from_json("{}")
12
- }.to raise_error "JSON hosts list is not an array"
12
+ }.to raise_error("JSON hosts list is not an array")
13
13
  end
14
14
 
15
15
  it "should fail for non hash array members" do
@@ -17,7 +17,7 @@ module MCollective
17
17
 
18
18
  expect {
19
19
  Helpers.extract_hosts_from_json(senders)
20
- }.to raise_error "JSON host list is not an array of Hashes"
20
+ }.to raise_error("JSON host list is not an array of Hashes")
21
21
  end
22
22
 
23
23
  it "should fail for hashes without senders" do
@@ -25,7 +25,7 @@ module MCollective
25
25
 
26
26
  expect {
27
27
  Helpers.extract_hosts_from_json(senders)
28
- }.to raise_error "JSON host list does not have senders in it"
28
+ }.to raise_error("JSON host list does not have senders in it")
29
29
  end
30
30
 
31
31
  it "should return all found unique senders" do
@@ -35,7 +35,7 @@ module MCollective
35
35
 
36
36
  expect {
37
37
  @plugin.should_process_msg?(m, "fail").should == true
38
- }.to raise_error MsgDoesNotMatchRequestID
38
+ }.to raise_error(MsgDoesNotMatchRequestID)
39
39
  end
40
40
 
41
41
  it "should not test messages without expected_msgid" do
@@ -93,7 +93,7 @@ module MCollective
93
93
  end
94
94
 
95
95
  it "should read the public key from a certificate" do
96
- @ssl.read_key(:public, "#{@rootdir}/../fixtures/test-cert.pem").to_s.should match /.+BEGIN.+PUBLIC KEY.+END.+PUBLIC KEY.+/m
96
+ @ssl.read_key(:public, "#{@rootdir}/../fixtures/test-cert.pem").to_s.should match(/.+BEGIN.+PUBLIC KEY.+END.+PUBLIC KEY.+/m)
97
97
  end
98
98
 
99
99
  it "should return nil if no key was given" do
File without changes
File without changes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcollective-client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
- - 1
8
- - 3
9
- - 3
10
- version: 1.3.3
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - R.I.Pienaar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-05 00:00:00 Z
18
+ date: 2012-04-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: systemu
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: "0"
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
- description: Client tools for the mcollective Application Server
48
+ description: Client libraries for the mcollective Application Server
49
49
  email: rip@puppetlabs.com
50
50
  executables:
51
51
  - mco
@@ -111,9 +111,10 @@ files:
111
111
  - spec/fixtures/application/test.rb
112
112
  - spec/fixtures/test-private.pem
113
113
  - spec/fixtures/test-cert.pem
114
- - spec/unit/windows_daemon.rb
115
114
  - spec/unit/application_spec.rb
115
+ - spec/unit/unix_daemon_spec.rb
116
116
  - spec/unit/facts/base_spec.rb
117
+ - spec/unit/array_spec.rb
117
118
  - spec/unit/rpc/reply_spec.rb
118
119
  - spec/unit/rpc/ddl_spec.rb
119
120
  - spec/unit/rpc/client_spec.rb
@@ -123,6 +124,7 @@ files:
123
124
  - spec/unit/rpc/result_spec.rb
124
125
  - spec/unit/rpc/actionrunner_spec.rb
125
126
  - spec/unit/rpc/stats_spec.rb
127
+ - spec/unit/windows_daemon_spec.rb
126
128
  - spec/unit/optionparser_spec.rb
127
129
  - spec/unit/pluginpackager/agent_definition_spec.rb
128
130
  - spec/unit/pluginpackager/standard_definition_spec.rb
@@ -135,15 +137,14 @@ files:
135
137
  - spec/unit/plugins/mcollective/connector/activemq_spec.rb
136
138
  - spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
137
139
  - spec/unit/plugins/mcollective/connector/stomp_spec.rb
140
+ - spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
138
141
  - spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
142
+ - spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
139
143
  - spec/unit/plugins/mcollective/security/psk_spec.rb
140
144
  - spec/unit/registration/base_spec.rb
141
- - spec/unit/symbol.rb
142
145
  - spec/unit/agents_spec.rb
143
146
  - spec/unit/security/base_spec.rb
144
- - spec/unit/array.rb
145
147
  - spec/unit/vendor_spec.rb
146
- - spec/unit/unix_daemon.rb
147
148
  - spec/unit/message_spec.rb
148
149
  - spec/unit/log_spec.rb
149
150
  - spec/unit/facts_spec.rb
@@ -151,6 +152,7 @@ files:
151
152
  - spec/unit/pluginmanager_spec.rb
152
153
  - spec/unit/matcher/parser_spec.rb
153
154
  - spec/unit/matcher/scanner_spec.rb
155
+ - spec/unit/symbol_spec.rb
154
156
  - spec/unit/util_spec.rb
155
157
  - spec/windows_spec.opts
156
158
  - spec/spec_helper.rb
@@ -188,16 +190,17 @@ rubyforge_project:
188
190
  rubygems_version: 1.8.11
189
191
  signing_key:
190
192
  specification_version: 3
191
- summary: Client for The Marionette Collective
193
+ summary: Client libraries for The Marionette Collective
192
194
  test_files:
193
195
  - spec/spec.opts
194
196
  - spec/fixtures/test-public.pem
195
197
  - spec/fixtures/application/test.rb
196
198
  - spec/fixtures/test-private.pem
197
199
  - spec/fixtures/test-cert.pem
198
- - spec/unit/windows_daemon.rb
199
200
  - spec/unit/application_spec.rb
201
+ - spec/unit/unix_daemon_spec.rb
200
202
  - spec/unit/facts/base_spec.rb
203
+ - spec/unit/array_spec.rb
201
204
  - spec/unit/rpc/reply_spec.rb
202
205
  - spec/unit/rpc/ddl_spec.rb
203
206
  - spec/unit/rpc/client_spec.rb
@@ -207,6 +210,7 @@ test_files:
207
210
  - spec/unit/rpc/result_spec.rb
208
211
  - spec/unit/rpc/actionrunner_spec.rb
209
212
  - spec/unit/rpc/stats_spec.rb
213
+ - spec/unit/windows_daemon_spec.rb
210
214
  - spec/unit/optionparser_spec.rb
211
215
  - spec/unit/pluginpackager/agent_definition_spec.rb
212
216
  - spec/unit/pluginpackager/standard_definition_spec.rb
@@ -219,15 +223,14 @@ test_files:
219
223
  - spec/unit/plugins/mcollective/connector/activemq_spec.rb
220
224
  - spec/unit/plugins/mcollective/connector/stomp/eventlogger_spec.rb
221
225
  - spec/unit/plugins/mcollective/connector/stomp_spec.rb
226
+ - spec/unit/plugins/mcollective/packagers/debpackage_packager_spec.rb
222
227
  - spec/unit/plugins/mcollective/packagers/ospackage_spec.rb
228
+ - spec/unit/plugins/mcollective/packagers/rpmpackage_packager_spec.rb
223
229
  - spec/unit/plugins/mcollective/security/psk_spec.rb
224
230
  - spec/unit/registration/base_spec.rb
225
- - spec/unit/symbol.rb
226
231
  - spec/unit/agents_spec.rb
227
232
  - spec/unit/security/base_spec.rb
228
- - spec/unit/array.rb
229
233
  - spec/unit/vendor_spec.rb
230
- - spec/unit/unix_daemon.rb
231
234
  - spec/unit/message_spec.rb
232
235
  - spec/unit/log_spec.rb
233
236
  - spec/unit/facts_spec.rb
@@ -235,6 +238,7 @@ test_files:
235
238
  - spec/unit/pluginmanager_spec.rb
236
239
  - spec/unit/matcher/parser_spec.rb
237
240
  - spec/unit/matcher/scanner_spec.rb
241
+ - spec/unit/symbol_spec.rb
238
242
  - spec/unit/util_spec.rb
239
243
  - spec/windows_spec.opts
240
244
  - spec/spec_helper.rb