ohai 15.3.1 → 15.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
- data/lib/ohai/plugins/aix/network.rb +3 -8
- data/lib/ohai/plugins/darwin/network.rb +6 -4
- data/lib/ohai/plugins/filesystem.rb +166 -0
- data/lib/ohai/plugins/network.rb +5 -5
- data/lib/ohai/plugins/openstack.rb +2 -1
- data/lib/ohai/plugins/solaris2/network.rb +6 -4
- data/lib/ohai/version.rb +1 -1
- data/ohai.gemspec +1 -1
- metadata +3 -162
- data/Rakefile +0 -42
- data/lib/ohai/plugins/windows/filesystem.rb +0 -147
- data/spec/data/plugins/dpkg-query.output +0 -4
- data/spec/data/plugins/lslpp.output +0 -50
- data/spec/data/plugins/pacman.output +0 -51
- data/spec/data/plugins/pkg-query.output +0 -58
- data/spec/data/plugins/pkginfo.output +0 -50
- data/spec/data/plugins/pkglist.output +0 -24
- data/spec/data/plugins/rpmquery.output +0 -7
- data/spec/functional/application_spec.rb +0 -107
- data/spec/functional/loader_spec.rb +0 -53
- data/spec/functional/plugins/powershell_spec.rb +0 -88
- data/spec/functional/plugins/root_group_spec.rb +0 -41
- data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
- data/spec/ohai_spec.rb +0 -27
- data/spec/rcov.opts +0 -2
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -124
- data/spec/support/integration_helper.rb +0 -61
- data/spec/support/platform_helpers.rb +0 -38
- data/spec/unit/application_spec.rb +0 -96
- data/spec/unit/config_spec.rb +0 -57
- data/spec/unit/dsl/plugin_spec.rb +0 -634
- data/spec/unit/hints_spec.rb +0 -65
- data/spec/unit/loader_spec.rb +0 -195
- data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
- data/spec/unit/mixin/command_spec.rb +0 -151
- data/spec/unit/mixin/dmi_decode.rb +0 -75
- data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
- data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
- data/spec/unit/plugin_config_spec.rb +0 -117
- data/spec/unit/plugins/abort_spec.rb +0 -69
- data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
- data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
- data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
- data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
- data/spec/unit/plugins/aix/memory_spec.rb +0 -49
- data/spec/unit/plugins/aix/network_spec.rb +0 -313
- data/spec/unit/plugins/aix/platform_spec.rb +0 -44
- data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
- data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
- data/spec/unit/plugins/azure_spec.rb +0 -243
- data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
- data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
- data/spec/unit/plugins/c_spec.rb +0 -341
- data/spec/unit/plugins/chef_spec.rb +0 -44
- data/spec/unit/plugins/cloud_spec.rb +0 -484
- data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
- data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
- data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
- data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
- data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
- data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
- data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
- data/spec/unit/plugins/darwin/network_spec.rb +0 -849
- data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
- data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
- data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
- data/spec/unit/plugins/dmi_spec.rb +0 -156
- data/spec/unit/plugins/docker_spec.rb +0 -100
- data/spec/unit/plugins/ec2_spec.rb +0 -452
- data/spec/unit/plugins/elixir_spec.rb +0 -55
- data/spec/unit/plugins/erlang_spec.rb +0 -71
- data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
- data/spec/unit/plugins/fail_spec.rb +0 -260
- data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
- data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
- data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/gce_spec.rb +0 -81
- data/spec/unit/plugins/go_spec.rb +0 -48
- data/spec/unit/plugins/groovy_spec.rb +0 -66
- data/spec/unit/plugins/haskell_spec.rb +0 -231
- data/spec/unit/plugins/hostname_spec.rb +0 -162
- data/spec/unit/plugins/init_package_spec.rb +0 -60
- data/spec/unit/plugins/java_spec.rb +0 -230
- data/spec/unit/plugins/joyent_spec.rb +0 -100
- data/spec/unit/plugins/kernel_spec.rb +0 -38
- data/spec/unit/plugins/linode_spec.rb +0 -135
- data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
- data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
- data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
- data/spec/unit/plugins/linux/fips_spec.rb +0 -60
- data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
- data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
- data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
- data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
- data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
- data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
- data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
- data/spec/unit/plugins/linux/memory_spec.rb +0 -256
- data/spec/unit/plugins/linux/network_spec.rb +0 -1392
- data/spec/unit/plugins/linux/platform_spec.rb +0 -812
- data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
- data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
- data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
- data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
- data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
- data/spec/unit/plugins/lua_spec.rb +0 -60
- data/spec/unit/plugins/mono_spec.rb +0 -67
- data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
- data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
- data/spec/unit/plugins/network_spec.rb +0 -1078
- data/spec/unit/plugins/nodejs_spec.rb +0 -55
- data/spec/unit/plugins/ohai_spec.rb +0 -32
- data/spec/unit/plugins/ohai_time_spec.rb +0 -44
- data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
- data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
- data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
- data/spec/unit/plugins/openstack_spec.rb +0 -311
- data/spec/unit/plugins/os_spec.rb +0 -115
- data/spec/unit/plugins/packages_spec.rb +0 -353
- data/spec/unit/plugins/passwd_spec.rb +0 -65
- data/spec/unit/plugins/perl_spec.rb +0 -62
- data/spec/unit/plugins/php_spec.rb +0 -97
- data/spec/unit/plugins/platform_spec.rb +0 -65
- data/spec/unit/plugins/powershell_spec.rb +0 -71
- data/spec/unit/plugins/python_spec.rb +0 -51
- data/spec/unit/plugins/rackspace_spec.rb +0 -350
- data/spec/unit/plugins/root_group_spec.rb +0 -90
- data/spec/unit/plugins/ruby_spec.rb +0 -60
- data/spec/unit/plugins/rust_spec.rb +0 -43
- data/spec/unit/plugins/scala_spec.rb +0 -58
- data/spec/unit/plugins/scaleway_spec.rb +0 -93
- data/spec/unit/plugins/scsi_spec.rb +0 -69
- data/spec/unit/plugins/shard_spec.rb +0 -121
- data/spec/unit/plugins/shells_spec.rb +0 -56
- data/spec/unit/plugins/softlayer_spec.rb +0 -60
- data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
- data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
- data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
- data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
- data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
- data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
- data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
- data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
- data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
- data/spec/unit/plugins/sysconf_spec.rb +0 -680
- data/spec/unit/plugins/timezone_spec.rb +0 -30
- data/spec/unit/plugins/vbox_host_spec.rb +0 -14
- data/spec/unit/plugins/virtualbox_spec.rb +0 -375
- data/spec/unit/plugins/vmware_spec.rb +0 -81
- data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
- data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
- data/spec/unit/plugins/windows/fips_spec.rb +0 -60
- data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
- data/spec/unit/plugins/windows/memory_spec.rb +0 -52
- data/spec/unit/plugins/windows/network_spec.rb +0 -137
- data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
- data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
- data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
- data/spec/unit/plugins/zpools_spec.rb +0 -244
- data/spec/unit/provides_map_spec.rb +0 -208
- data/spec/unit/runner_spec.rb +0 -422
- data/spec/unit/system_spec.rb +0 -416
- data/spec/unit/util/file_helper_spec.rb +0 -47
- data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,55 +0,0 @@
|
|
1
|
-
# Author:: Christopher M Luciano (<cmlucian@us.ibm.com>)
|
2
|
-
# License:: Apache License, Version 2.0
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language elixirverning permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
#
|
16
|
-
|
17
|
-
require "spec_helper"
|
18
|
-
|
19
|
-
describe Ohai::System, "plugin elixir" do
|
20
|
-
let(:plugin) { get_plugin("elixir") }
|
21
|
-
|
22
|
-
before do
|
23
|
-
plugin[:languages] = Mash.new
|
24
|
-
end
|
25
|
-
|
26
|
-
it "shellouts to elixir -v" do
|
27
|
-
expect(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(0, "Elixir 1.0.2", ""))
|
28
|
-
plugin.run
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets languages[:elixir][:version] on older elixir" do
|
32
|
-
allow(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(0, "Elixir 1.0.2", ""))
|
33
|
-
plugin.run
|
34
|
-
expect(plugin.languages[:elixir][:version]).to eql("1.0.2")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "sets languages[:elixir][:version] on newer elixir" do
|
38
|
-
new_stdout = "Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]\n\nElixir 1.2.4\n"
|
39
|
-
allow(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(0, new_stdout, ""))
|
40
|
-
plugin.run
|
41
|
-
expect(plugin.languages[:elixir][:version]).to eql("1.2.4")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "does not set languages[:elixir] if elixir command fails" do
|
45
|
-
allow(plugin).to receive(:shell_out).with("elixir -v").and_return(mock_shell_out(1, "", ""))
|
46
|
-
plugin.run
|
47
|
-
expect(plugin.languages).not_to have_key(:elixir)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "does not set languages[:elixir] if elixir command doesn't exist" do
|
51
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
52
|
-
plugin.run
|
53
|
-
expect(plugin.languages).not_to have_key(:elixir)
|
54
|
-
end
|
55
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
describe Ohai::System, "plugin erlang" do
|
23
|
-
let(:plugin) { get_plugin("erlang") }
|
24
|
-
|
25
|
-
before do
|
26
|
-
plugin[:languages] = Mash.new
|
27
|
-
erl_v_output = "Erlang (SMP,ASYNC_THREADS,HIPE) (BEAM) emulator version 7.3\n"
|
28
|
-
erl_systeminfo_output = "19.1,8.1,2.11"
|
29
|
-
allow(plugin).to receive(:shell_out).with("erl +V")
|
30
|
-
.and_return(mock_shell_out(0, "", erl_v_output))
|
31
|
-
allow(plugin).to receive(:shell_out).with("erl -eval '{ok, Ver} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), Vsn = binary:bin_to_list(Ver, {0, byte_size(Ver) - 1}), io:format(\"~s,~s,~s\", [Vsn, erlang:system_info(version), erlang:system_info(nif_version)]), halt().' -noshell")
|
32
|
-
.and_return(mock_shell_out(0, erl_systeminfo_output, ""))
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sets languages[:erlang][:options]" do
|
36
|
-
plugin.run
|
37
|
-
expect(plugin.languages[:erlang][:options]).to eql(%w{SMP ASYNC_THREADS HIPE})
|
38
|
-
end
|
39
|
-
|
40
|
-
it "sets languages[:erlang][:emulator]" do
|
41
|
-
plugin.run
|
42
|
-
expect(plugin.languages[:erlang][:emulator]).to eql("BEAM")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "sets languages[:erlang][:version]" do
|
46
|
-
plugin.run
|
47
|
-
expect(plugin.languages[:erlang][:version]).to eql("19.1")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sets languages[:erlang][:erts_version]" do
|
51
|
-
plugin.run
|
52
|
-
expect(plugin.languages[:erlang][:erts_version]).to eql("8.1")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "sets languages[:erlang][:nif_version]" do
|
56
|
-
plugin.run
|
57
|
-
expect(plugin.languages[:erlang][:nif_version]).to eql("2.11")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "does not set languages[:erlang] if the erl commands fails" do
|
61
|
-
allow(plugin).to receive(:shell_out).and_return(mock_shell_out(1, "", ""))
|
62
|
-
plugin.run
|
63
|
-
expect(plugin.languages).not_to have_key(:erlang)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "does not set languages[:erlang] if the erl command doesn't exist" do
|
67
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
68
|
-
plugin.run
|
69
|
-
expect(plugin.languages).not_to have_key(:erlang)
|
70
|
-
end
|
71
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Tim Dysinger (<tim@dysinger.net>)
|
3
|
-
# Author:: Christopher Brown (cb@chef.io)
|
4
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
require "open-uri"
|
22
|
-
|
23
|
-
describe Ohai::System, "plugin eucalyptus" do
|
24
|
-
let(:plugin) { get_plugin("eucalyptus") }
|
25
|
-
|
26
|
-
shared_examples_for "!eucalyptus" do
|
27
|
-
it "does NOT attempt to fetch the eucalyptus metadata" do
|
28
|
-
expect(OpenURI).not_to receive(:open)
|
29
|
-
plugin.run
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
shared_examples_for "eucalyptus" do
|
34
|
-
before do
|
35
|
-
@http_client = double("Net::HTTP client")
|
36
|
-
allow(plugin).to receive(:http_client).and_return(@http_client)
|
37
|
-
|
38
|
-
expect(@http_client).to receive(:get)
|
39
|
-
.with("/")
|
40
|
-
.and_return(double("Net::HTTP Response", body: "2012-01-12", code: "200"))
|
41
|
-
expect(@http_client).to receive(:get)
|
42
|
-
.with("/2012-01-12/meta-data/")
|
43
|
-
.and_return(double("Net::HTTP Response", body: "instance_type\nami_id\nsecurity-groups", code: "200"))
|
44
|
-
expect(@http_client).to receive(:get)
|
45
|
-
.with("/2012-01-12/meta-data/instance_type")
|
46
|
-
.and_return(double("Net::HTTP Response", body: "c1.medium", code: "200"))
|
47
|
-
expect(@http_client).to receive(:get)
|
48
|
-
.with("/2012-01-12/meta-data/ami_id")
|
49
|
-
.and_return(double("Net::HTTP Response", body: "ami-5d2dc934", code: "200"))
|
50
|
-
expect(@http_client).to receive(:get)
|
51
|
-
.with("/2012-01-12/meta-data/security-groups")
|
52
|
-
.and_return(double("Net::HTTP Response", body: "group1\ngroup2", code: "200"))
|
53
|
-
expect(@http_client).to receive(:get)
|
54
|
-
.with("/2012-01-12/user-data/")
|
55
|
-
.and_return(double("Net::HTTP Response", body: "By the pricking of my thumb...", code: "200"))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "recursively fetches all the eucalyptus metadata" do
|
59
|
-
allow(IO).to receive(:select).and_return([[], [1], []])
|
60
|
-
t = double("connection")
|
61
|
-
allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
|
62
|
-
allow(Socket).to receive(:new).and_return(t)
|
63
|
-
plugin.run
|
64
|
-
expect(plugin[:eucalyptus]).not_to be_nil
|
65
|
-
expect(plugin[:eucalyptus]["instance_type"]).to eq("c1.medium")
|
66
|
-
expect(plugin[:eucalyptus]["ami_id"]).to eq("ami-5d2dc934")
|
67
|
-
expect(plugin[:eucalyptus]["security_groups"]).to eql %w{group1 group2}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "with eucalyptus mac and metadata address connected" do
|
72
|
-
before do
|
73
|
-
allow(IO).to receive(:select).and_return([[], [1], []])
|
74
|
-
plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "d0:0d:95:47:6E:ED" => { "family" => "lladdr" } } } } }
|
75
|
-
end
|
76
|
-
|
77
|
-
it_behaves_like "eucalyptus"
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "without eucalyptus mac and metadata address connected" do
|
82
|
-
before do
|
83
|
-
plugin[:network] = { "interfaces" => { "eth0" => { "addresses" => { "ff:ff:95:47:6E:ED" => { "family" => "lladdr" } } } } }
|
84
|
-
end
|
85
|
-
|
86
|
-
it_behaves_like "!eucalyptus"
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "with eucalyptus hint file" do
|
91
|
-
before do
|
92
|
-
allow(plugin).to receive(:hint?).with("eucalyptus").and_return(true)
|
93
|
-
end
|
94
|
-
|
95
|
-
it_behaves_like "eucalyptus"
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
describe "without hint file" do
|
100
|
-
before do
|
101
|
-
plugin[:network] = { interfaces: {} }
|
102
|
-
allow(plugin).to receive(:hint?).with("eucalyptus").and_return(false)
|
103
|
-
end
|
104
|
-
|
105
|
-
it_behaves_like "!eucalyptus"
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Toomas Pelberg (toomas.pelberg@playtech.com>)
|
3
|
-
# Author:: Claire McQuin (claire@chef.io)
|
4
|
-
# Copyright:: Copyright (c) 2011, 2013-2016 Chef Software, Inc.
|
5
|
-
# License:: Apache License, Version 2.0
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
#
|
19
|
-
|
20
|
-
require "spec_helper"
|
21
|
-
|
22
|
-
tmp = ENV["TMPDIR"] || ENV["TMP"] || ENV["TEMP"] || "/tmp"
|
23
|
-
|
24
|
-
shared_examples "a v7 loading failure" do
|
25
|
-
before(:all) do
|
26
|
-
|
27
|
-
Dir.mkdir("#{tmp}/plugins")
|
28
|
-
rescue Errno::EEXIST
|
29
|
-
# ignore
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
before do
|
34
|
-
fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
|
35
|
-
fail_file.write(failstr)
|
36
|
-
fail_file.close
|
37
|
-
end
|
38
|
-
|
39
|
-
after do
|
40
|
-
File.delete("#{tmp}/plugins/fail.rb")
|
41
|
-
end
|
42
|
-
|
43
|
-
after(:all) do
|
44
|
-
|
45
|
-
Dir.delete("#{tmp}/plugins")
|
46
|
-
rescue
|
47
|
-
# ignore
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
before do
|
52
|
-
@ohai = Ohai::System.new
|
53
|
-
@loader = Ohai::Loader.new(@ohai)
|
54
|
-
end
|
55
|
-
|
56
|
-
it "does not have attribute keys" do
|
57
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
58
|
-
# @ohai.attributes.should_not have_key("fail")
|
59
|
-
expect { @ohai.provides_map.find_providers_for(["fail"]) }.to raise_error(Ohai::Exceptions::AttributeNotFound)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "writes to Ohai::Log" do
|
63
|
-
expect(@loader.logger).to receive(:warn).once
|
64
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
shared_examples "a v7 loading success" do
|
69
|
-
before(:all) do
|
70
|
-
|
71
|
-
Dir.mkdir("#{tmp}/plugins")
|
72
|
-
rescue Errno::EEXIST
|
73
|
-
# ignore
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
before do
|
78
|
-
fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
|
79
|
-
fail_file.write(failstr)
|
80
|
-
fail_file.close
|
81
|
-
end
|
82
|
-
|
83
|
-
after do
|
84
|
-
File.delete("#{tmp}/plugins/fail.rb")
|
85
|
-
end
|
86
|
-
|
87
|
-
after(:all) do
|
88
|
-
|
89
|
-
Dir.delete("#{tmp}/plugins")
|
90
|
-
rescue
|
91
|
-
# ignore
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
before do
|
96
|
-
@ohai = Ohai::System.new
|
97
|
-
@loader = Ohai::Loader.new(@ohai)
|
98
|
-
end
|
99
|
-
|
100
|
-
it "has attribute keys" do
|
101
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
102
|
-
expect(@ohai.provides_map).to have_key("fail")
|
103
|
-
end
|
104
|
-
|
105
|
-
it "does not write to Ohai::Log" do
|
106
|
-
expect(@loader.logger).not_to receive(:warn)
|
107
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb")
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
shared_examples "a v7 run failure" do
|
112
|
-
before(:all) do
|
113
|
-
|
114
|
-
Dir.mkdir("#{tmp}/plugins")
|
115
|
-
rescue Errno::EEXIST
|
116
|
-
# ignore
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
before do
|
121
|
-
fail_file = File.open("#{tmp}/plugins/fail.rb", "w+")
|
122
|
-
fail_file.write(failstr)
|
123
|
-
fail_file.close
|
124
|
-
end
|
125
|
-
|
126
|
-
after do
|
127
|
-
File.delete("#{tmp}/plugins/fail.rb")
|
128
|
-
end
|
129
|
-
|
130
|
-
after(:all) do
|
131
|
-
|
132
|
-
Dir.delete("#{tmp}/plugins")
|
133
|
-
rescue
|
134
|
-
# ignore
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
before do
|
139
|
-
@ohai = Ohai::System.new
|
140
|
-
@loader = Ohai::Loader.new(@ohai)
|
141
|
-
end
|
142
|
-
|
143
|
-
it "does not have new attribute keys" do
|
144
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
|
145
|
-
expect(@ohai.provides_map).not_to have_key("other")
|
146
|
-
end
|
147
|
-
|
148
|
-
it "writes to Ohai::Log" do
|
149
|
-
expect(@loader.logger).to receive(:warn).once
|
150
|
-
@loader.load_plugin("#{tmp}/plugins/fail.rb").new(@ohai).run
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "when using DSL commands outside Ohai.plugin block" do
|
155
|
-
failstr1 = <<~EOF
|
156
|
-
provides "fail"
|
157
|
-
Ohai.plugin do
|
158
|
-
end
|
159
|
-
EOF
|
160
|
-
|
161
|
-
failstr2 = <<~EOF
|
162
|
-
depends "fail"
|
163
|
-
Ohai.plugin do
|
164
|
-
end
|
165
|
-
EOF
|
166
|
-
|
167
|
-
failstr3 = <<~EOF
|
168
|
-
collect_data do
|
169
|
-
end
|
170
|
-
Ohai.plugin do
|
171
|
-
end
|
172
|
-
EOF
|
173
|
-
|
174
|
-
it_behaves_like "a v7 loading failure" do
|
175
|
-
let(:failstr) { failstr1 }
|
176
|
-
end
|
177
|
-
|
178
|
-
it_behaves_like "a v7 loading failure" do
|
179
|
-
let(:failstr) { failstr2 }
|
180
|
-
end
|
181
|
-
|
182
|
-
it_behaves_like "a v7 loading failure" do
|
183
|
-
let(:failstr) { failstr3 }
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "when using nonexistent DSL commands in Ohai.plugin block" do
|
188
|
-
failstr = "Ohai.plugin do\n\tcreates \"fail\"\nend\n"
|
189
|
-
|
190
|
-
it_behaves_like "a v7 loading failure" do
|
191
|
-
let(:failstr) { failstr }
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
=begin
|
196
|
-
describe "when using DSL commands in collect_data block" do
|
197
|
-
failstr1 = <<EOF
|
198
|
-
Ohai.plugin do
|
199
|
-
provides "fail"
|
200
|
-
collect_data do
|
201
|
-
provides "other"
|
202
|
-
end
|
203
|
-
end
|
204
|
-
EOF
|
205
|
-
|
206
|
-
failstr2 =<<EOF
|
207
|
-
Ohai.plugin do
|
208
|
-
provides "fail"
|
209
|
-
collect_data do
|
210
|
-
provides "other"
|
211
|
-
end
|
212
|
-
end
|
213
|
-
EOF
|
214
|
-
|
215
|
-
it_behaves_like "a v7 loading success" do
|
216
|
-
let(:failstr) { failstr1 }
|
217
|
-
end
|
218
|
-
|
219
|
-
it_behaves_like "a v7 run failure" do
|
220
|
-
let(:failstr) { failstr1 }
|
221
|
-
end
|
222
|
-
|
223
|
-
it_behaves_like "a v7 loading success" do
|
224
|
-
let(:failstr) { failstr2 }
|
225
|
-
end
|
226
|
-
|
227
|
-
it_behaves_like "a v7 run failure" do
|
228
|
-
let(:failstr) { failstr2 }
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "when setting undeclared attribute in collect_data block" do
|
233
|
-
failstr = <<EOF
|
234
|
-
Ohai.plugin do
|
235
|
-
provides "fail"
|
236
|
-
collect_data do
|
237
|
-
creates "other"
|
238
|
-
end
|
239
|
-
end
|
240
|
-
EOF
|
241
|
-
it_behaves_like "a v7 loading success" do
|
242
|
-
let(:failstr) { failstr }
|
243
|
-
end
|
244
|
-
|
245
|
-
it_behaves_like "a v7 run failure" do
|
246
|
-
let(:failstr) { failstr }
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
describe "when setting undeclared attribute" do
|
251
|
-
failstr = <<EOF
|
252
|
-
provides "fail"
|
253
|
-
other "attribute"
|
254
|
-
EOF
|
255
|
-
|
256
|
-
it_behaves_like "a v6 run failure" do
|
257
|
-
let(:failstr) { failstr }
|
258
|
-
end
|
259
|
-
end
|
260
|
-
=end
|