puppet 2.7.13 → 2.7.14
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.
- data/CHANGELOG +144 -1
- data/conf/osx/preflight +1 -1
- data/conf/redhat/puppet.spec +9 -5
- data/conf/suse/puppet.spec +4 -1
- data/conf/windows/eventlog/Rakefile +32 -0
- data/conf/windows/eventlog/puppetres.dll +0 -0
- data/conf/windows/eventlog/puppetres.mc +18 -0
- data/ext/rack/files/apache2.conf +3 -0
- data/install.rb +23 -1
- data/lib/puppet.rb +1 -1
- data/lib/puppet/agent.rb +1 -14
- data/lib/puppet/application/kick.rb +1 -1
- data/lib/puppet/application/module.rb +11 -0
- data/lib/puppet/daemon.rb +74 -3
- data/lib/puppet/defaults.rb +1 -1
- data/lib/puppet/face/certificate.rb +1 -1
- data/lib/puppet/face/help/man.erb +1 -1
- data/lib/puppet/face/module.rb +17 -0
- data/lib/puppet/face/module/build.rb +10 -4
- data/lib/puppet/face/module/changes.rb +5 -5
- data/lib/puppet/face/module/generate.rb +6 -4
- data/lib/puppet/face/module/install.rb +122 -32
- data/lib/puppet/face/module/list.rb +234 -33
- data/lib/puppet/face/module/search.rb +56 -23
- data/lib/puppet/face/module/uninstall.rb +33 -38
- data/lib/puppet/face/module/upgrade.rb +84 -0
- data/lib/puppet/feature/eventlog.rb +6 -0
- data/lib/puppet/forge.rb +67 -122
- data/lib/puppet/forge/cache.rb +1 -1
- data/lib/puppet/forge/repository.rb +6 -25
- data/lib/puppet/indirector/facts/network_device.rb +1 -1
- data/lib/puppet/interface/action.rb +1 -1
- data/lib/puppet/module.rb +79 -28
- data/lib/puppet/module_tool.rb +72 -34
- data/lib/puppet/module_tool/applications.rb +12 -14
- data/lib/puppet/module_tool/applications/application.rb +21 -19
- data/lib/puppet/module_tool/applications/builder.rb +4 -4
- data/lib/puppet/module_tool/applications/checksummer.rb +12 -3
- data/lib/puppet/module_tool/applications/generator.rb +1 -1
- data/lib/puppet/module_tool/applications/installer.rb +163 -34
- data/lib/puppet/module_tool/applications/searcher.rb +2 -3
- data/lib/puppet/module_tool/applications/uninstaller.rb +84 -36
- data/lib/puppet/module_tool/applications/unpacker.rb +4 -26
- data/lib/puppet/module_tool/applications/upgrader.rb +109 -0
- data/lib/puppet/module_tool/checksums.rb +2 -2
- data/lib/puppet/module_tool/contents_description.rb +1 -1
- data/lib/puppet/module_tool/dependency.rb +2 -2
- data/lib/puppet/module_tool/errors.rb +9 -0
- data/lib/puppet/module_tool/errors/base.rb +15 -0
- data/lib/puppet/module_tool/errors/installer.rb +90 -0
- data/lib/puppet/module_tool/errors/shared.rb +115 -0
- data/lib/puppet/module_tool/errors/uninstaller.rb +45 -0
- data/lib/puppet/module_tool/errors/upgrader.rb +72 -0
- data/lib/puppet/module_tool/metadata.rb +2 -2
- data/lib/puppet/module_tool/modulefile.rb +7 -7
- data/lib/puppet/module_tool/shared_behaviors.rb +161 -0
- data/lib/puppet/module_tool/skeleton.rb +1 -1
- data/lib/puppet/node/environment.rb +4 -2
- data/lib/puppet/parser/ast/leaf.rb +1 -1
- data/lib/puppet/parser/functions/create_resources.rb +3 -2
- data/lib/puppet/parser/scope.rb +44 -9
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/exec.rb +8 -3
- data/lib/puppet/provider/exec/shell.rb +1 -2
- data/lib/puppet/provider/nameservice/directoryservice.rb +10 -4
- data/lib/puppet/provider/package/gem.rb +1 -1
- data/lib/puppet/provider/package/pkg.rb +10 -21
- data/lib/puppet/provider/selmodule/semodule.rb +1 -2
- data/lib/puppet/provider/service/upstart.rb +33 -17
- data/lib/puppet/provider/ssh_authorized_key/parsed.rb +1 -1
- data/lib/puppet/rails/inventory_node.rb +7 -7
- data/lib/puppet/reports/http.rb +4 -1
- data/lib/puppet/reports/tagmail.rb +8 -1
- data/lib/puppet/resource/type.rb +1 -1
- data/lib/puppet/test/test_helper.rb +138 -0
- data/lib/puppet/type.rb +9 -1
- data/lib/puppet/type/file.rb +18 -10
- data/lib/puppet/type/package.rb +13 -9
- data/lib/puppet/type/resources.rb +1 -1
- data/lib/puppet/type/ssh_authorized_key.rb +3 -4
- data/lib/puppet/type/sshkey.rb +4 -4
- data/lib/puppet/type/user.rb +1 -0
- data/lib/puppet/type/vlan.rb +1 -1
- data/lib/puppet/util.rb +31 -14
- data/lib/puppet/util/autoload.rb +1 -1
- data/lib/puppet/util/command_line.rb +2 -6
- data/lib/puppet/util/instrumentation/indirection_probe.rb +1 -1
- data/lib/puppet/util/instrumentation/instrumentable.rb +1 -1
- data/lib/puppet/util/instrumentation/listeners/log.rb +1 -1
- data/lib/puppet/util/instrumentation/listeners/performance.rb +1 -1
- data/lib/puppet/util/log.rb +3 -1
- data/lib/puppet/util/log/destinations.rb +38 -0
- data/lib/puppet/util/monkey_patches.rb +45 -0
- data/lib/puppet/util/network_device/base.rb +1 -1
- data/lib/puppet/util/network_device/cisco.rb +1 -1
- data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
- data/lib/puppet/util/network_device/cisco/interface.rb +1 -1
- data/lib/puppet/util/network_device/config.rb +1 -1
- data/lib/puppet/util/network_device/ipcalc.rb +1 -1
- data/lib/puppet/util/network_device/transport.rb +1 -1
- data/lib/puppet/util/network_device/transport/base.rb +1 -1
- data/lib/puppet/util/network_device/transport/ssh.rb +1 -1
- data/lib/puppet/util/settings.rb +2 -11
- data/lib/puppet/util/settings/file_setting.rb +3 -5
- data/lib/puppet/util/terminal.rb +16 -0
- data/lib/puppet/util/zaml.rb +3 -1
- data/lib/semver.rb +15 -7
- data/spec/fixtures/releases/jamtur01-apache/metadata.json +1 -1
- data/spec/fixtures/unit/parser/lexer/arithmetic_expression.pp +1 -1
- data/spec/fixtures/unit/provider/package/pkg/dummy +1 -0
- data/spec/fixtures/unit/provider/package/pkg/incomplete +1 -0
- data/spec/fixtures/unit/provider/package/pkg/publisher +2 -0
- data/spec/fixtures/unit/provider/package/pkg/simple +4 -0
- data/spec/fixtures/unit/reports/tagmail/tagmail_email.conf +2 -0
- data/spec/fixtures/yaml/report0.25.x.yaml +1 -1
- data/spec/fixtures/yaml/report2.6.x.yaml +1 -1
- data/spec/integration/faces/documentation_spec.rb +1 -1
- data/spec/integration/network/rest_authconfig_spec.rb +1 -1
- data/spec/lib/puppet_spec/compiler.rb +6 -0
- data/spec/lib/puppet_spec/database.rb +30 -0
- data/spec/lib/puppet_spec/files.rb +4 -2
- data/spec/shared_behaviours/path_parameters.rb +2 -29
- data/spec/shared_contexts/platform.rb +43 -0
- data/spec/spec_helper.rb +36 -65
- data/spec/unit/agent_spec.rb +0 -32
- data/spec/unit/application/kick_spec.rb +2 -2
- data/spec/unit/daemon_spec.rb +1 -17
- data/spec/unit/face/module/install_spec.rb +158 -0
- data/spec/unit/face/module/list_spec.rb +182 -0
- data/spec/unit/face/module/search_spec.rb +163 -0
- data/spec/unit/face/module/uninstall_spec.rb +77 -0
- data/spec/unit/face/module/upgrade_spec.rb +26 -0
- data/spec/unit/forge/repository_spec.rb +0 -30
- data/spec/unit/forge_spec.rb +28 -86
- data/spec/unit/indirector/catalog/active_record_spec.rb +45 -65
- data/spec/unit/indirector/facts/inventory_active_record_spec.rb +5 -18
- data/spec/unit/indirector/resource/active_record_spec.rb +2 -11
- data/spec/unit/indirector/resource/ral_spec.rb +7 -2
- data/spec/unit/module_spec.rb +240 -107
- data/spec/unit/module_tool/application_spec.rb +3 -5
- data/spec/unit/module_tool/applications/application_spec.rb +19 -0
- data/spec/unit/module_tool/applications/installer_spec.rb +205 -0
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +206 -0
- data/spec/unit/module_tool/applications/upgrader_spec.rb +37 -0
- data/spec/unit/module_tool/metadata_spec.rb +2 -2
- data/spec/unit/module_tool_spec.rb +109 -1
- data/spec/unit/node/environment_spec.rb +16 -1
- data/spec/unit/parser/ast/leaf_spec.rb +16 -1
- data/spec/unit/parser/collector_spec.rb +2 -12
- data/spec/unit/parser/functions/create_resources_spec.rb +135 -86
- data/spec/unit/parser/functions/generate_spec.rb +2 -10
- data/spec/unit/parser/scope_spec.rb +345 -16
- data/spec/unit/provider/augeas/augeas_spec.rb +19 -0
- data/spec/unit/provider/exec/shell_spec.rb +17 -14
- data/spec/unit/provider/exec/windows_spec.rb +1 -7
- data/spec/unit/provider/exec_spec.rb +35 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/package/dpkg_spec.rb +2 -1
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/openbsd_spec.rb +5 -4
- data/spec/unit/provider/package/pacman_spec.rb +3 -2
- data/spec/unit/provider/package/pkg_spec.rb +56 -33
- data/spec/unit/provider/selmodule_spec.rb +11 -4
- data/spec/unit/provider/service/redhat_spec.rb +1 -3
- data/spec/unit/provider/service/smf_spec.rb +1 -3
- data/spec/unit/provider/service/upstart_spec.rb +38 -0
- data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +28 -0
- data/spec/unit/rails/host_spec.rb +6 -12
- data/spec/unit/rails/param_value_spec.rb +3 -8
- data/spec/unit/rails/resource_spec.rb +2 -8
- data/spec/unit/reports/http_spec.rb +47 -31
- data/spec/unit/reports/tagmail_spec.rb +77 -0
- data/spec/unit/resource/type_spec.rb +2 -2
- data/spec/unit/resource_spec.rb +18 -20
- data/spec/unit/semver_spec.rb +31 -13
- data/spec/unit/type/exec_spec.rb +8 -15
- data/spec/unit/type/group_spec.rb +0 -9
- data/spec/unit/type/package_spec.rb +10 -0
- data/spec/unit/type/resources_spec.rb +4 -5
- data/spec/unit/type/ssh_authorized_key_spec.rb +4 -15
- data/spec/unit/type/sshkey_spec.rb +9 -11
- data/spec/unit/type/user_spec.rb +123 -127
- data/spec/unit/type_spec.rb +20 -0
- data/spec/unit/util/command_line_spec.rb +2 -2
- data/spec/unit/util/instrumentation/data_spec.rb +1 -1
- data/spec/unit/util/instrumentation/indirection_probe_spec.rb +1 -1
- data/spec/unit/util/instrumentation/instrumentable_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listener_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listeners/log_spec.rb +1 -1
- data/spec/unit/util/instrumentation/listeners/performance_spec.rb +1 -1
- data/spec/unit/util/instrumentation_spec.rb +1 -1
- data/spec/unit/util/log/destinations_spec.rb +4 -8
- data/spec/unit/util/log_spec.rb +47 -0
- data/spec/unit/util/reference_spec.rb +1 -1
- data/spec/unit/util/settings/file_setting_spec.rb +9 -0
- data/spec/unit/util/settings_spec.rb +0 -53
- data/spec/unit/util/terminal_spec.rb +42 -0
- data/spec/unit/util/zaml_spec.rb +7 -0
- data/spec/unit/util_spec.rb +63 -20
- data/tasks/rake/manpages.rake +1 -1
- data/test/data/snippets/arithmetic_expression.pp +1 -1
- data/test/other/puppet.rb +0 -1
- data/test/util/log.rb +6 -6
- metadata +41 -16
- data/lib/puppet/external/event-loop.rb +0 -1
- data/lib/puppet/external/event-loop/better-definers.rb +0 -367
- data/lib/puppet/external/event-loop/event-loop.rb +0 -355
- data/lib/puppet/external/event-loop/signal-system.rb +0 -218
- data/lib/puppet/face/module/clean.rb +0 -30
- data/lib/puppet/module_tool/applications/cleaner.rb +0 -16
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json +0 -12
- data/lib/puppet/module_tool/utils.rb +0 -5
- data/lib/puppet/module_tool/utils/interrogation.rb +0 -25
- data/spec/integration/module_tool_spec.rb +0 -475
- data/spec/unit/module_tool/uninstaller_spec.rb +0 -124
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
require 'puppet/module_tool'
|
4
|
+
|
5
|
+
describe "puppet module uninstall" do
|
6
|
+
subject { Puppet::Face[:module, :current] }
|
7
|
+
|
8
|
+
let(:options) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "option validation" do
|
13
|
+
context "without any options" do
|
14
|
+
it "should require a name" do
|
15
|
+
pattern = /wrong number of arguments/
|
16
|
+
expect { subject.uninstall }.to raise_error ArgumentError, pattern
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not require any options" do
|
20
|
+
Puppet::ModuleTool::Applications::Uninstaller.expects(:run).once
|
21
|
+
subject.uninstall("puppetlabs-apache")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should accept the --environment option" do
|
26
|
+
options[:environment] = "development"
|
27
|
+
expected_options = { :environment => 'development' }
|
28
|
+
Puppet::ModuleTool::Applications::Uninstaller.expects(:run).with("puppetlabs-apache", expected_options).once
|
29
|
+
subject.uninstall("puppetlabs-apache", options)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should accept the --modulepath option" do
|
33
|
+
options[:modulepath] = "/foo/puppet/modules"
|
34
|
+
expected_options = {
|
35
|
+
:modulepath => '/foo/puppet/modules',
|
36
|
+
:environment => 'production',
|
37
|
+
}
|
38
|
+
Puppet::ModuleTool::Applications::Uninstaller.expects(:run).with("puppetlabs-apache", expected_options).once
|
39
|
+
subject.uninstall("puppetlabs-apache", options)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should accept the --version option" do
|
43
|
+
options[:version] = "1.0.0"
|
44
|
+
expected_options = {
|
45
|
+
:version => '1.0.0',
|
46
|
+
:environment => 'production',
|
47
|
+
}
|
48
|
+
Puppet::ModuleTool::Applications::Uninstaller.expects(:run).with("puppetlabs-apache", expected_options).once
|
49
|
+
subject.uninstall("puppetlabs-apache", options)
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should accept the --force flag" do
|
53
|
+
options[:force] = true
|
54
|
+
expected_options = {
|
55
|
+
:environment => 'production',
|
56
|
+
:force => true,
|
57
|
+
}
|
58
|
+
Puppet::ModuleTool::Applications::Uninstaller.expects(:run).with("puppetlabs-apache", expected_options).once
|
59
|
+
subject.uninstall("puppetlabs-apache", options)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "inline documentation" do
|
64
|
+
subject { Puppet::Face[:module, :current].get_action :uninstall }
|
65
|
+
|
66
|
+
its(:summary) { should =~ /uninstall.*module/im }
|
67
|
+
its(:description) { should =~ /uninstall.*module/im }
|
68
|
+
its(:returns) { should =~ /hash of module objects.*/im }
|
69
|
+
its(:examples) { should_not be_empty }
|
70
|
+
|
71
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
72
|
+
context "of the" do
|
73
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppet/face'
|
3
|
+
require 'puppet/module_tool'
|
4
|
+
|
5
|
+
describe "puppet module upgrade" do
|
6
|
+
subject { Puppet::Face[:module, :current] }
|
7
|
+
|
8
|
+
let(:options) do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "inline documentation" do
|
13
|
+
subject { Puppet::Face[:module, :current].get_action :upgrade }
|
14
|
+
|
15
|
+
its(:summary) { should =~ /upgrade.*module/im }
|
16
|
+
its(:description) { should =~ /upgrade.*module/im }
|
17
|
+
its(:returns) { should =~ /hash/i }
|
18
|
+
its(:examples) { should_not be_empty }
|
19
|
+
|
20
|
+
%w{ license copyright summary description returns examples }.each do |doc|
|
21
|
+
context "of the" do
|
22
|
+
its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -8,36 +8,6 @@ describe Puppet::Forge::Repository do
|
|
8
8
|
|
9
9
|
let(:repository) { Puppet::Forge::Repository.new('http://fake.com') }
|
10
10
|
|
11
|
-
describe '#make_http_request' do
|
12
|
-
before do
|
13
|
-
# Do a mock of the Proxy call so we can do proper expects for
|
14
|
-
# Net::HTTP
|
15
|
-
Net::HTTP.expects(:Proxy).returns(Net::HTTP)
|
16
|
-
Net::HTTP.expects(:start)
|
17
|
-
end
|
18
|
-
context "when not given an :authenticate option" do
|
19
|
-
it "should authenticate" do
|
20
|
-
repository.expects(:authenticate).never
|
21
|
-
repository.make_http_request(nil)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
context "when given an :authenticate option" do
|
25
|
-
it "should authenticate" do
|
26
|
-
repository.expects(:authenticate)
|
27
|
-
repository.make_http_request(nil, :authenticate => true)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#authenticate' do
|
33
|
-
it "should set basic auth on the request" do
|
34
|
-
authenticated_request = stub
|
35
|
-
authenticated_request.expects(:basic_auth)
|
36
|
-
repository.expects(:prompt).twice
|
37
|
-
repository.authenticate(authenticated_request)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
11
|
describe '#retrieve' do
|
42
12
|
before do
|
43
13
|
@uri = URI.parse('http://some.url.com')
|
data/spec/unit/forge_spec.rb
CHANGED
@@ -1,114 +1,56 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'puppet/forge'
|
3
3
|
require 'net/http'
|
4
|
+
require 'puppet/module_tool'
|
5
|
+
|
6
|
+
describe Puppet::Forge do
|
7
|
+
include PuppetSpec::Files
|
8
|
+
|
9
|
+
let(:response_body) do
|
10
|
+
<<-EOF
|
11
|
+
[
|
12
|
+
{
|
13
|
+
"author": "puppetlabs",
|
14
|
+
"name": "bacula",
|
15
|
+
"tag_list": ["backup", "bacula"],
|
16
|
+
"releases": [{"version": "0.0.1"}, {"version": "0.0.2"}],
|
17
|
+
"full_name": "puppetlabs/bacula",
|
18
|
+
"version": "0.0.2",
|
19
|
+
"project_url": "http://github.com/puppetlabs/puppetlabs-bacula",
|
20
|
+
"desc": "bacula"
|
21
|
+
}
|
22
|
+
]
|
23
|
+
EOF
|
24
|
+
end
|
25
|
+
let(:response) { stub(:body => response_body, :code => '200') }
|
4
26
|
|
5
|
-
describe Puppet::Forge::Forge do
|
6
27
|
before do
|
7
28
|
Puppet::Forge::Repository.any_instance.stubs(:make_http_request).returns(response)
|
8
29
|
Puppet::Forge::Repository.any_instance.stubs(:retrieve).returns("/tmp/foo")
|
9
30
|
end
|
10
31
|
|
11
|
-
let(:forge) { forge = Puppet::Forge::Forge.new('http://forge.puppetlabs.com') }
|
12
|
-
|
13
32
|
describe "the behavior of the search method" do
|
14
33
|
context "when there are matches for the search term" do
|
15
34
|
before do
|
16
35
|
Puppet::Forge::Repository.any_instance.stubs(:make_http_request).returns(response)
|
17
36
|
end
|
18
37
|
|
19
|
-
let(:response) { stub(:body => response_body, :code => '200') }
|
20
|
-
let(:response_body) do
|
21
|
-
<<-EOF
|
22
|
-
[
|
23
|
-
{
|
24
|
-
"author": "puppetlabs",
|
25
|
-
"name": "bacula",
|
26
|
-
"tag_list": ["backup", "bacula"],
|
27
|
-
"releases": [{"version": "0.0.1"}, {"version": "0.0.2"}],
|
28
|
-
"full_name": "puppetlabs/bacula",
|
29
|
-
"version": "0.0.2",
|
30
|
-
"project_url": "http://github.com/puppetlabs/puppetlabs-bacula",
|
31
|
-
"desc": "bacula"
|
32
|
-
}
|
33
|
-
]
|
34
|
-
EOF
|
35
|
-
end
|
36
|
-
|
37
38
|
it "should return a list of matches from the forge" do
|
38
|
-
|
39
|
+
Puppet::Forge.search('bacula').should == PSON.load(response_body)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
43
|
context "when the connection to the forge fails" do
|
43
|
-
let(:response) { stub(:body => '
|
44
|
+
let(:response) { stub(:body => '{}', :code => '404') }
|
44
45
|
|
45
|
-
it "should raise an error" do
|
46
|
-
lambda {
|
46
|
+
it "should raise an error for search" do
|
47
|
+
lambda { Puppet::Forge.search('bacula') }.should raise_error RuntimeError
|
47
48
|
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "the behavior of the get_release_package method" do
|
52
49
|
|
53
|
-
|
54
|
-
|
55
|
-
response.stubs(:body).returns('{"file": "/system/releases/p/puppetlabs/puppetlabs-apache-0.0.3.tar.gz", "version": "0.0.3"}')
|
56
|
-
response
|
57
|
-
end
|
58
|
-
|
59
|
-
context "when source is not filesystem or repository" do
|
60
|
-
it "should raise an error" do
|
61
|
-
params = { :source => 'foo' }
|
62
|
-
lambda { forge.get_release_package(params) }.should
|
63
|
-
raise_error(ArgumentError, "Could not determine installation source")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when the source is a repository" do
|
68
|
-
let(:params) do
|
69
|
-
{
|
70
|
-
:source => :repository,
|
71
|
-
:author => 'fakeauthor',
|
72
|
-
:modname => 'fakemodule',
|
73
|
-
:version => '0.0.1'
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should require author" do
|
78
|
-
params.delete(:author)
|
79
|
-
lambda { forge.get_release_package(params) }.should
|
80
|
-
raise_error(ArgumentError, ":author and :modename required")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should require modname" do
|
84
|
-
params.delete(:modname)
|
85
|
-
lambda { forge.get_release_package(params) }.should
|
86
|
-
raise_error(ArgumentError, ":author and :modename required")
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should download the release package" do
|
90
|
-
forge.get_release_package(params).should == "/tmp/foo"
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "when the source is a filesystem" do
|
95
|
-
it "should require filename" do
|
96
|
-
params = { :source => :filesystem }
|
97
|
-
lambda { forge.get_release_package(params) }.should
|
98
|
-
raise_error(ArgumentError, ":filename required")
|
50
|
+
it "should raise an error for remote_dependency_info" do
|
51
|
+
lambda { Puppet::Forge.remote_dependency_info('puppetlabs', 'bacula', '0.0.1') }.should raise_error RuntimeError
|
99
52
|
end
|
100
53
|
end
|
101
54
|
end
|
102
55
|
|
103
|
-
describe "the behavior of the get_releases method" do
|
104
|
-
let(:response) do
|
105
|
-
response = mock()
|
106
|
-
response.stubs(:body).returns('{"releases": [{"version": "0.0.1"}, {"version": "0.0.2"}, {"version": "0.0.3"}]}')
|
107
|
-
response
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should return a list of module releases" do
|
111
|
-
forge.get_releases('fakeauthor', 'fakemodule').should == ["0.0.1", "0.0.2", "0.0.3"]
|
112
|
-
end
|
113
|
-
end
|
114
56
|
end
|
@@ -1,35 +1,21 @@
|
|
1
1
|
#!/usr/bin/env rspec
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
|
+
describe "Puppet::Resource::Catalog::ActiveRecord", :if => can_use_scratch_database? do
|
5
|
+
include PuppetSpec::Files
|
4
6
|
|
5
|
-
describe "Puppet::Resource::Catalog::ActiveRecord", :if => Puppet.features.rails? do
|
6
7
|
require 'puppet/rails'
|
7
8
|
|
8
|
-
before :
|
9
|
-
|
10
|
-
|
11
|
-
@columns ||= []
|
12
|
-
end
|
13
|
-
def self.column(name, sql_type=nil, default=nil, null=true)
|
14
|
-
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Host < Tableless
|
19
|
-
column :name, :string, :null => false
|
20
|
-
column :ip, :string
|
21
|
-
column :environment, :string
|
22
|
-
column :last_compile, :datetime
|
23
|
-
end
|
9
|
+
before :each do
|
10
|
+
require 'puppet/indirector/catalog/active_record'
|
11
|
+
setup_scratch_database
|
24
12
|
end
|
25
13
|
|
26
|
-
|
27
|
-
|
28
|
-
Puppet.features.stubs(:rails?).returns true
|
29
|
-
Puppet::Rails.stubs(:init)
|
30
|
-
@terminus = Puppet::Resource::Catalog::ActiveRecord.new
|
14
|
+
let :terminus do
|
15
|
+
Puppet::Resource::Catalog::ActiveRecord.new
|
31
16
|
end
|
32
17
|
|
18
|
+
|
33
19
|
it "should be a subclass of the ActiveRecord terminus class" do
|
34
20
|
Puppet::Resource::Catalog::ActiveRecord.ancestors.should be_include(Puppet::Indirector::ActiveRecord)
|
35
21
|
end
|
@@ -39,35 +25,35 @@ describe "Puppet::Resource::Catalog::ActiveRecord", :if => Puppet.features.rails
|
|
39
25
|
end
|
40
26
|
|
41
27
|
describe "when finding an instance" do
|
42
|
-
|
43
|
-
|
28
|
+
let :request do
|
29
|
+
stub 'request', :key => "foo", :options => {:cache_integration_hack => true}
|
44
30
|
end
|
45
31
|
|
46
32
|
# This hack is here because we don't want to look in the db unless we actually want
|
47
33
|
# to look in the db, but our indirection architecture in 0.24.x isn't flexible
|
48
34
|
# enough to tune that via configuration.
|
49
35
|
it "should return nil unless ':cache_integration_hack' is set to true" do
|
50
|
-
|
36
|
+
request.options[:cache_integration_hack] = false
|
51
37
|
Puppet::Rails::Host.expects(:find_by_name).never
|
52
|
-
|
38
|
+
terminus.find(request).should be_nil
|
53
39
|
end
|
54
40
|
|
55
41
|
it "should use the Hosts ActiveRecord class to find the host" do
|
56
42
|
Puppet::Rails::Host.expects(:find_by_name).with { |key, args| key == "foo" }
|
57
|
-
|
43
|
+
terminus.find(request)
|
58
44
|
end
|
59
45
|
|
60
46
|
it "should return nil if no host instance can be found" do
|
61
47
|
Puppet::Rails::Host.expects(:find_by_name).returns nil
|
62
48
|
|
63
|
-
|
49
|
+
terminus.find(request).should be_nil
|
64
50
|
end
|
65
51
|
|
66
52
|
it "should return a catalog with the same name as the host if the host can be found" do
|
67
53
|
host = stub 'host', :name => "foo", :resources => []
|
68
54
|
Puppet::Rails::Host.expects(:find_by_name).returns host
|
69
55
|
|
70
|
-
result =
|
56
|
+
result = terminus.find(request)
|
71
57
|
result.should be_instance_of(Puppet::Resource::Catalog)
|
72
58
|
result.name.should == "foo"
|
73
59
|
end
|
@@ -87,70 +73,64 @@ describe "Puppet::Resource::Catalog::ActiveRecord", :if => Puppet.features.rails
|
|
87
73
|
catalog.expects(:add_resource).with "trans_res1"
|
88
74
|
catalog.expects(:add_resource).with "trans_res2"
|
89
75
|
|
90
|
-
|
76
|
+
terminus.find(request)
|
91
77
|
end
|
92
78
|
end
|
93
79
|
|
94
80
|
describe "when saving an instance" do
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
@node = Puppet::Node.new("foo", :environment => "environment")
|
102
|
-
Puppet::Node.indirection.stubs(:find).with("foo").returns(@node)
|
103
|
-
|
104
|
-
Puppet::Rails::Host.stubs(:find_by_name).returns @host
|
105
|
-
@catalog = Puppet::Resource::Catalog.new("foo")
|
106
|
-
@request = Puppet::Indirector::Request.new(:active_record, :save, @catalog)
|
81
|
+
let :catalog do Puppet::Resource::Catalog.new("foo") end
|
82
|
+
let :request do Puppet::Indirector::Request.new(:active_record, :save, catalog) end
|
83
|
+
let :node do Puppet::Node.new("foo", :environment => "environment") end
|
84
|
+
|
85
|
+
before :each do
|
86
|
+
Puppet::Node.indirection.stubs(:find).with("foo").returns(node)
|
107
87
|
end
|
108
88
|
|
109
89
|
it "should find the Rails host with the same name" do
|
110
|
-
Puppet::Rails::Host.expects(:find_by_name).with("foo")
|
111
|
-
|
112
|
-
@terminus.save(@request)
|
90
|
+
Puppet::Rails::Host.expects(:find_by_name).with("foo")
|
91
|
+
terminus.save(request)
|
113
92
|
end
|
114
93
|
|
115
94
|
it "should create a new Rails host if none can be found" do
|
116
|
-
Puppet::Rails::Host.
|
117
|
-
|
118
|
-
Puppet::Rails::Host.
|
119
|
-
|
120
|
-
@terminus.save(@request)
|
95
|
+
Puppet::Rails::Host.find_by_name('foo').should be_nil
|
96
|
+
terminus.save(request)
|
97
|
+
Puppet::Rails::Host.find_by_name('foo').should be_valid
|
121
98
|
end
|
122
99
|
|
123
100
|
it "should set the catalog vertices as resources on the Rails host instance" do
|
124
|
-
|
125
|
-
|
101
|
+
# We need to stub this so we get the same object, not just the same
|
102
|
+
# content, otherwise the expect can't fire. :(
|
103
|
+
host = Puppet::Rails::Host.create!(:name => "foo")
|
104
|
+
Puppet::Rails::Host.expects(:find_by_name).with("foo").returns(host)
|
105
|
+
catalog.expects(:vertices).returns("foo")
|
106
|
+
host.expects(:merge_resources).with("foo")
|
126
107
|
|
127
|
-
|
108
|
+
terminus.save(request)
|
128
109
|
end
|
129
110
|
|
130
111
|
it "should set host ip if we could find a matching node" do
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
@host.ip.should == '192.168.0.1'
|
112
|
+
node.merge("ipaddress" => "192.168.0.1")
|
113
|
+
terminus.save(request)
|
114
|
+
Puppet::Rails::Host.find_by_name("foo").ip.should == '192.168.0.1'
|
135
115
|
end
|
136
116
|
|
137
117
|
it "should set host environment if we could find a matching node" do
|
138
|
-
|
139
|
-
|
118
|
+
terminus.save(request)
|
119
|
+
Puppet::Rails::Host.find_by_name("foo").environment.should == "environment"
|
140
120
|
end
|
141
121
|
|
142
122
|
it "should set the last compile time on the host" do
|
143
123
|
now = Time.now
|
144
|
-
|
145
|
-
|
146
|
-
@terminus.save(@request)
|
147
|
-
@host.last_compile.should == now
|
124
|
+
terminus.save(request)
|
125
|
+
Puppet::Rails::Host.find_by_name("foo").last_compile.should be_within(1).of(now)
|
148
126
|
end
|
149
127
|
|
150
128
|
it "should save the Rails host instance" do
|
151
|
-
|
129
|
+
host = Puppet::Rails::Host.create!(:name => "foo")
|
130
|
+
Puppet::Rails::Host.expects(:find_by_name).with("foo").returns(host)
|
131
|
+
host.expects(:save)
|
152
132
|
|
153
|
-
|
133
|
+
terminus.save(request)
|
154
134
|
end
|
155
135
|
end
|
156
136
|
end
|