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,162 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
require "wmi-lite/wmi"
|
21
|
-
require "socket"
|
22
|
-
|
23
|
-
describe Ohai::System, "hostname plugin" do
|
24
|
-
before do
|
25
|
-
@plugin = get_plugin("hostname")
|
26
|
-
allow(@plugin).to receive(:collect_os).and_return(:default)
|
27
|
-
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
|
28
|
-
end
|
29
|
-
|
30
|
-
context "default behavior"
|
31
|
-
before do
|
32
|
-
allow(@plugin).to receive(:resolve_fqdn).and_return("katie.bethell")
|
33
|
-
end
|
34
|
-
|
35
|
-
it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
|
36
|
-
|
37
|
-
it "uses #resolve_fqdn to find the fqdn" do
|
38
|
-
@plugin.run
|
39
|
-
expect(@plugin[:fqdn]).to eq("katie.bethell")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "sets the domain to everything after the first dot of the fqdn" do
|
43
|
-
@plugin.run
|
44
|
-
expect(@plugin[:domain]).to eq("bethell")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "sets the [short] hostname to everything before the first dot of the fqdn" do
|
48
|
-
@plugin.run
|
49
|
-
expect(@plugin[:hostname]).to eq("katie")
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when a system has a bare hostname without a FQDN" do
|
53
|
-
before do
|
54
|
-
allow(@plugin).to receive(:collect_os).and_return(:default)
|
55
|
-
allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie", ""))
|
56
|
-
end
|
57
|
-
|
58
|
-
it "correctlies set the [short] hostname" do
|
59
|
-
@plugin.run
|
60
|
-
expect(@plugin[:hostname]).to eq("katie")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context "hostname --fqdn when it returns empty string" do
|
65
|
-
before do
|
66
|
-
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
67
|
-
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
|
68
|
-
mock_shell_out(0, "katie", "")
|
69
|
-
)
|
70
|
-
allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
|
71
|
-
mock_shell_out(0, "", ""), mock_shell_out(0, "katie.local", "")
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "is called twice" do
|
76
|
-
@plugin.run
|
77
|
-
expect(@plugin[:fqdn]).to eq("katie.local")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context "hostname --fqdn when it works" do
|
82
|
-
before do
|
83
|
-
allow(@plugin).to receive(:collect_os).and_return(:linux)
|
84
|
-
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
|
85
|
-
mock_shell_out(0, "katie", "")
|
86
|
-
)
|
87
|
-
allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
|
88
|
-
mock_shell_out(0, "katie.local", "")
|
89
|
-
)
|
90
|
-
end
|
91
|
-
|
92
|
-
it "is not be called twice" do
|
93
|
-
@plugin.run
|
94
|
-
expect(@plugin[:fqdn]).to eq("katie.local")
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe Ohai::System, "hostname plugin for windows", :windows_only do
|
100
|
-
let(:success) { true }
|
101
|
-
|
102
|
-
let(:host) do
|
103
|
-
{
|
104
|
-
"name" => "local",
|
105
|
-
"dnshostname" => "local",
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
let(:info) do
|
110
|
-
[
|
111
|
-
"local",
|
112
|
-
[],
|
113
|
-
23,
|
114
|
-
"address1",
|
115
|
-
"address2",
|
116
|
-
"address3",
|
117
|
-
"address4",
|
118
|
-
]
|
119
|
-
end
|
120
|
-
|
121
|
-
let(:local_hostent) do
|
122
|
-
[
|
123
|
-
"local",
|
124
|
-
[],
|
125
|
-
23,
|
126
|
-
"address",
|
127
|
-
]
|
128
|
-
end
|
129
|
-
|
130
|
-
let(:fqdn_hostent) do
|
131
|
-
[
|
132
|
-
"local.dx.internal.cloudapp.net",
|
133
|
-
[],
|
134
|
-
23,
|
135
|
-
"address",
|
136
|
-
]
|
137
|
-
end
|
138
|
-
|
139
|
-
before do
|
140
|
-
@plugin = get_plugin("hostname")
|
141
|
-
allow(WmiLite::Wmi).to receive(:new).and_return(success)
|
142
|
-
allow(success).to receive(:first_of).with("Win32_ComputerSystem").and_return(host)
|
143
|
-
allow(Socket).to receive(:gethostname).and_return("local")
|
144
|
-
allow(Socket).to receive(:gethostbyname).with(anything).and_return(info)
|
145
|
-
end
|
146
|
-
|
147
|
-
context "when hostname is not set for the machine" do
|
148
|
-
it "returns short machine name" do
|
149
|
-
allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(local_hostent)
|
150
|
-
@plugin.run
|
151
|
-
expect(@plugin[:fqdn]).to eq("local")
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "when hostname is set for the machine" do
|
156
|
-
it "returns the fqdn of the machine" do
|
157
|
-
allow(Socket).to receive(:gethostbyaddr).with(anything).and_return(fqdn_hostent)
|
158
|
-
@plugin.run
|
159
|
-
expect(@plugin[:fqdn]).to eq("local.dx.internal.cloudapp.net")
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Caleb Tennis (<caleb.tennis@gmail.com>)
|
3
|
-
# Copyright:: Copyright (c) 2012-2016 Chef Software, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require "spec_helper"
|
20
|
-
|
21
|
-
describe Ohai::System, "Init package" do
|
22
|
-
let(:plugin) do
|
23
|
-
p = get_plugin("init_package")
|
24
|
-
allow(p).to receive(:collect_os).and_return("linux")
|
25
|
-
p
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:proc1_content) { "init\n" }
|
29
|
-
let(:proc1_exists) { true }
|
30
|
-
let(:proc_1_file_path) { "/proc/1/comm" }
|
31
|
-
let(:proc_1_file) { double(proc_1_file_path, gets: proc1_content) }
|
32
|
-
|
33
|
-
before do
|
34
|
-
allow(File).to receive(:exist?).with(proc_1_file_path).and_return(proc1_exists)
|
35
|
-
allow(File).to receive(:open).with(proc_1_file_path).and_return(proc_1_file)
|
36
|
-
end
|
37
|
-
|
38
|
-
it "sets init_package to init" do
|
39
|
-
plugin.run
|
40
|
-
expect(plugin[:init_package]).to eq("init")
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "when init_package is systemd" do
|
44
|
-
let(:proc1_content) { "systemd\n" }
|
45
|
-
|
46
|
-
it "sets init_package to systemd" do
|
47
|
-
plugin.run
|
48
|
-
expect(plugin[:init_package]).to eq("systemd")
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "when /proc/1/comm doesn't exist" do
|
53
|
-
let(:proc1_exists) { false }
|
54
|
-
|
55
|
-
it "sets init_package to init" do
|
56
|
-
plugin.run
|
57
|
-
expect(plugin[:init_package]).to eq("init")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,230 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Benjamin Black (<bb@chef.io>)
|
3
|
-
# Author:: Theodore Nordsieck (<theo@chef.io>)
|
4
|
-
# Copyright:: Copyright (c) 2009-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 java (Java5 Client VM)" do
|
23
|
-
let(:plugin) { get_plugin("java") }
|
24
|
-
|
25
|
-
before do
|
26
|
-
plugin[:languages] = Mash.new
|
27
|
-
end
|
28
|
-
|
29
|
-
shared_examples_for "when the JRE is installed" do
|
30
|
-
before do
|
31
|
-
stderr = "java version \"1.5.0_16\"\nJava(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)\nJava HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)"
|
32
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr))
|
33
|
-
end
|
34
|
-
|
35
|
-
it "runs java -mx64m -version" do
|
36
|
-
expect(plugin).to receive(:shell_out).with("java -mx64m -version")
|
37
|
-
plugin.run
|
38
|
-
end
|
39
|
-
|
40
|
-
it "sets java[:version]" do
|
41
|
-
plugin.run
|
42
|
-
expect(plugin[:languages][:java][:version]).to eql("1.5.0_16")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "sets java[:runtime][:name] to runtime name" do
|
46
|
-
plugin.run
|
47
|
-
expect(plugin[:languages][:java][:runtime][:name]).to eql("Java(TM) 2 Runtime Environment, Standard Edition")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sets java[:runtime][:build] to runtime build" do
|
51
|
-
plugin.run
|
52
|
-
expect(plugin[:languages][:java][:runtime][:build]).to eql("1.5.0_16-b06-284")
|
53
|
-
end
|
54
|
-
|
55
|
-
it "sets java[:hotspot][:name] to hotspot name" do
|
56
|
-
plugin.run
|
57
|
-
expect(plugin[:languages][:java][:hotspot][:name]).to eql("Java HotSpot(TM) Client VM")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "sets java[:hotspot][:build] to hotspot build" do
|
61
|
-
plugin.run
|
62
|
-
expect(plugin[:languages][:java][:hotspot][:build]).to eql("1.5.0_16-133, mixed mode, sharing")
|
63
|
-
end
|
64
|
-
|
65
|
-
it "does not set the languages[:java] tree up if java command fails" do
|
66
|
-
stderr = "Some error output here"
|
67
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(1, "", stderr))
|
68
|
-
plugin.run
|
69
|
-
expect(plugin[:languages]).not_to have_key(:java)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "does not set the languages[:java] tree up if java command doesn't exist" do
|
73
|
-
allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
|
74
|
-
plugin.run
|
75
|
-
expect(plugin[:languages]).not_to have_key(:java)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
shared_examples_for "when the Server JRE is installed" do
|
80
|
-
|
81
|
-
before do
|
82
|
-
stderr = "java version \"1.6.0_22\"\nJava(TM) 2 Runtime Environment (build 1.6.0_22-b04)\nJava HotSpot(TM) Server VM (build 17.1-b03, mixed mode)"
|
83
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr))
|
84
|
-
end
|
85
|
-
|
86
|
-
it "runs java -mx64m -version" do
|
87
|
-
expect(plugin).to receive(:shell_out).with("java -mx64m -version")
|
88
|
-
plugin.run
|
89
|
-
end
|
90
|
-
|
91
|
-
it "sets java[:version]" do
|
92
|
-
plugin.run
|
93
|
-
expect(plugin[:languages][:java][:version]).to eql("1.6.0_22")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "sets java[:runtime][:name] to runtime name" do
|
97
|
-
plugin.run
|
98
|
-
expect(plugin[:languages][:java][:runtime][:name]).to eql("Java(TM) 2 Runtime Environment")
|
99
|
-
end
|
100
|
-
|
101
|
-
it "sets java[:runtime][:build] to runtime build" do
|
102
|
-
plugin.run
|
103
|
-
expect(plugin[:languages][:java][:runtime][:build]).to eql("1.6.0_22-b04")
|
104
|
-
end
|
105
|
-
|
106
|
-
it "sets java[:hotspot][:name] to hotspot name" do
|
107
|
-
plugin.run
|
108
|
-
expect(plugin[:languages][:java][:hotspot][:name]).to eql("Java HotSpot(TM) Server VM")
|
109
|
-
end
|
110
|
-
|
111
|
-
it "sets java[:hotspot][:build] to hotspot build" do
|
112
|
-
plugin.run
|
113
|
-
expect(plugin[:languages][:java][:hotspot][:build]).to eql("17.1-b03, mixed mode")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "does not set the languages[:java] tree up if java command fails" do
|
117
|
-
stderr = "Some error output here"
|
118
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr))
|
119
|
-
plugin.run
|
120
|
-
expect(plugin[:languages]).not_to have_key(:java)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
shared_examples_for "when the openjdk 1.8 is installed" do
|
125
|
-
|
126
|
-
before do
|
127
|
-
stderr = "openjdk version \"1.8.0_71\"\nOpenJDK Runtime Environment (build 1.8.0_71-b15)\nOpenJDK 64-Bit Server VM (build 25.71-b15, mixed mode)"
|
128
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr))
|
129
|
-
end
|
130
|
-
|
131
|
-
it "runs java -mx64m -version" do
|
132
|
-
expect(plugin).to receive(:shell_out).with("java -mx64m -version")
|
133
|
-
plugin.run
|
134
|
-
end
|
135
|
-
|
136
|
-
it "sets java[:version]" do
|
137
|
-
plugin.run
|
138
|
-
expect(plugin[:languages][:java][:version]).to eql("1.8.0_71")
|
139
|
-
end
|
140
|
-
|
141
|
-
it "sets java[:runtime][:name] to runtime name" do
|
142
|
-
plugin.run
|
143
|
-
expect(plugin[:languages][:java][:runtime][:name]).to eql("OpenJDK Runtime Environment")
|
144
|
-
end
|
145
|
-
|
146
|
-
it "sets java[:runtime][:build] to runtime build" do
|
147
|
-
plugin.run
|
148
|
-
expect(plugin[:languages][:java][:runtime][:build]).to eql("1.8.0_71-b15")
|
149
|
-
end
|
150
|
-
|
151
|
-
it "sets java[:hotspot][:name] to hotspot name" do
|
152
|
-
plugin.run
|
153
|
-
expect(plugin[:languages][:java][:hotspot][:name]).to eql("OpenJDK 64-Bit Server VM")
|
154
|
-
end
|
155
|
-
|
156
|
-
it "sets java[:hotspot][:build] to hotspot build" do
|
157
|
-
plugin.run
|
158
|
-
expect(plugin[:languages][:java][:hotspot][:build]).to eql("25.71-b15, mixed mode")
|
159
|
-
end
|
160
|
-
|
161
|
-
it "does not set the languages[:java] tree up if java command fails" do
|
162
|
-
stderr = "Some error output here"
|
163
|
-
allow(plugin).to receive(:shell_out).with("java -mx64m -version").and_return(mock_shell_out(0, "", stderr))
|
164
|
-
plugin.run
|
165
|
-
expect(plugin[:languages]).not_to have_key(:java)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
context "when not on Mac OS X" do
|
170
|
-
before do
|
171
|
-
stub_const("RUBY_PLATFORM", "x86_64-linux")
|
172
|
-
end
|
173
|
-
|
174
|
-
context "and the client JRE is installed" do
|
175
|
-
include_examples "when the JRE is installed"
|
176
|
-
end
|
177
|
-
|
178
|
-
context "and the server JRE is installed" do
|
179
|
-
include_examples "when the Server JRE is installed"
|
180
|
-
end
|
181
|
-
|
182
|
-
context "and the openjdk 1.8 is installed" do
|
183
|
-
include_examples "when the openjdk 1.8 is installed"
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
context "when on Mac OS X with Java installed" do
|
188
|
-
before do
|
189
|
-
stub_const("RUBY_PLATFORM", "x86_64-darwin12.3.0")
|
190
|
-
end
|
191
|
-
|
192
|
-
it "detects that it is on a darwin platform" do
|
193
|
-
expect(plugin).to be_on_darwin
|
194
|
-
end
|
195
|
-
|
196
|
-
context "and real Java is installed" do
|
197
|
-
before do
|
198
|
-
java_home_status = double(Process::Status, success?: true)
|
199
|
-
java_home_cmd = double(Mixlib::ShellOut, status: java_home_status)
|
200
|
-
expect(plugin).to receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
|
201
|
-
end
|
202
|
-
|
203
|
-
context "and the client JRE is installed" do
|
204
|
-
include_examples "when the JRE is installed"
|
205
|
-
end
|
206
|
-
|
207
|
-
context "and the server JRE is installed" do
|
208
|
-
include_examples "when the Server JRE is installed"
|
209
|
-
end
|
210
|
-
|
211
|
-
context "and the openjdk 1.8 is installed" do
|
212
|
-
include_examples "when the openjdk 1.8 is installed"
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context "and the JVM stubs are installed" do
|
217
|
-
before do
|
218
|
-
java_home_status = double(Process::Status, success?: false)
|
219
|
-
java_home_cmd = double(Mixlib::ShellOut, status: java_home_status)
|
220
|
-
expect(plugin).to receive(:shell_out).with("/usr/libexec/java_home").and_return(java_home_cmd)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "does not attempt to get java info" do
|
224
|
-
expect(plugin).not_to receive(:shell_out).with("java -mx64m -version")
|
225
|
-
plugin.run
|
226
|
-
expect(plugin[:languages]).not_to have_key(:java)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|