ohai 15.3.1 → 15.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -6
  3. data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
  4. data/lib/ohai/plugins/aix/network.rb +3 -8
  5. data/lib/ohai/plugins/darwin/network.rb +6 -4
  6. data/lib/ohai/plugins/filesystem.rb +166 -0
  7. data/lib/ohai/plugins/network.rb +5 -5
  8. data/lib/ohai/plugins/openstack.rb +2 -1
  9. data/lib/ohai/plugins/solaris2/network.rb +6 -4
  10. data/lib/ohai/version.rb +1 -1
  11. data/ohai.gemspec +1 -1
  12. metadata +3 -162
  13. data/Rakefile +0 -42
  14. data/lib/ohai/plugins/windows/filesystem.rb +0 -147
  15. data/spec/data/plugins/dpkg-query.output +0 -4
  16. data/spec/data/plugins/lslpp.output +0 -50
  17. data/spec/data/plugins/pacman.output +0 -51
  18. data/spec/data/plugins/pkg-query.output +0 -58
  19. data/spec/data/plugins/pkginfo.output +0 -50
  20. data/spec/data/plugins/pkglist.output +0 -24
  21. data/spec/data/plugins/rpmquery.output +0 -7
  22. data/spec/functional/application_spec.rb +0 -107
  23. data/spec/functional/loader_spec.rb +0 -53
  24. data/spec/functional/plugins/powershell_spec.rb +0 -88
  25. data/spec/functional/plugins/root_group_spec.rb +0 -41
  26. data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
  27. data/spec/ohai_spec.rb +0 -27
  28. data/spec/rcov.opts +0 -2
  29. data/spec/spec.opts +0 -2
  30. data/spec/spec_helper.rb +0 -124
  31. data/spec/support/integration_helper.rb +0 -61
  32. data/spec/support/platform_helpers.rb +0 -38
  33. data/spec/unit/application_spec.rb +0 -96
  34. data/spec/unit/config_spec.rb +0 -57
  35. data/spec/unit/dsl/plugin_spec.rb +0 -634
  36. data/spec/unit/hints_spec.rb +0 -65
  37. data/spec/unit/loader_spec.rb +0 -195
  38. data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
  39. data/spec/unit/mixin/command_spec.rb +0 -151
  40. data/spec/unit/mixin/dmi_decode.rb +0 -75
  41. data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
  42. data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
  43. data/spec/unit/plugin_config_spec.rb +0 -117
  44. data/spec/unit/plugins/abort_spec.rb +0 -69
  45. data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
  46. data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
  47. data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
  48. data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
  49. data/spec/unit/plugins/aix/memory_spec.rb +0 -49
  50. data/spec/unit/plugins/aix/network_spec.rb +0 -313
  51. data/spec/unit/plugins/aix/platform_spec.rb +0 -44
  52. data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
  53. data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
  54. data/spec/unit/plugins/azure_spec.rb +0 -243
  55. data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
  56. data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
  57. data/spec/unit/plugins/c_spec.rb +0 -341
  58. data/spec/unit/plugins/chef_spec.rb +0 -44
  59. data/spec/unit/plugins/cloud_spec.rb +0 -484
  60. data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
  61. data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
  62. data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
  63. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
  64. data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
  65. data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
  66. data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
  67. data/spec/unit/plugins/darwin/network_spec.rb +0 -849
  68. data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
  69. data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
  70. data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
  71. data/spec/unit/plugins/dmi_spec.rb +0 -156
  72. data/spec/unit/plugins/docker_spec.rb +0 -100
  73. data/spec/unit/plugins/ec2_spec.rb +0 -452
  74. data/spec/unit/plugins/elixir_spec.rb +0 -55
  75. data/spec/unit/plugins/erlang_spec.rb +0 -71
  76. data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
  77. data/spec/unit/plugins/fail_spec.rb +0 -260
  78. data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
  79. data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
  80. data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
  81. data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
  82. data/spec/unit/plugins/gce_spec.rb +0 -81
  83. data/spec/unit/plugins/go_spec.rb +0 -48
  84. data/spec/unit/plugins/groovy_spec.rb +0 -66
  85. data/spec/unit/plugins/haskell_spec.rb +0 -231
  86. data/spec/unit/plugins/hostname_spec.rb +0 -162
  87. data/spec/unit/plugins/init_package_spec.rb +0 -60
  88. data/spec/unit/plugins/java_spec.rb +0 -230
  89. data/spec/unit/plugins/joyent_spec.rb +0 -100
  90. data/spec/unit/plugins/kernel_spec.rb +0 -38
  91. data/spec/unit/plugins/linode_spec.rb +0 -135
  92. data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
  93. data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
  94. data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
  95. data/spec/unit/plugins/linux/fips_spec.rb +0 -60
  96. data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
  97. data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
  98. data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
  99. data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
  100. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  101. data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
  102. data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
  103. data/spec/unit/plugins/linux/memory_spec.rb +0 -256
  104. data/spec/unit/plugins/linux/network_spec.rb +0 -1392
  105. data/spec/unit/plugins/linux/platform_spec.rb +0 -812
  106. data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
  107. data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
  108. data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
  109. data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
  110. data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
  111. data/spec/unit/plugins/lua_spec.rb +0 -60
  112. data/spec/unit/plugins/mono_spec.rb +0 -67
  113. data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
  114. data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
  115. data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
  116. data/spec/unit/plugins/network_spec.rb +0 -1078
  117. data/spec/unit/plugins/nodejs_spec.rb +0 -55
  118. data/spec/unit/plugins/ohai_spec.rb +0 -32
  119. data/spec/unit/plugins/ohai_time_spec.rb +0 -44
  120. data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
  121. data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
  122. data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
  123. data/spec/unit/plugins/openstack_spec.rb +0 -311
  124. data/spec/unit/plugins/os_spec.rb +0 -115
  125. data/spec/unit/plugins/packages_spec.rb +0 -353
  126. data/spec/unit/plugins/passwd_spec.rb +0 -65
  127. data/spec/unit/plugins/perl_spec.rb +0 -62
  128. data/spec/unit/plugins/php_spec.rb +0 -97
  129. data/spec/unit/plugins/platform_spec.rb +0 -65
  130. data/spec/unit/plugins/powershell_spec.rb +0 -71
  131. data/spec/unit/plugins/python_spec.rb +0 -51
  132. data/spec/unit/plugins/rackspace_spec.rb +0 -350
  133. data/spec/unit/plugins/root_group_spec.rb +0 -90
  134. data/spec/unit/plugins/ruby_spec.rb +0 -60
  135. data/spec/unit/plugins/rust_spec.rb +0 -43
  136. data/spec/unit/plugins/scala_spec.rb +0 -58
  137. data/spec/unit/plugins/scaleway_spec.rb +0 -93
  138. data/spec/unit/plugins/scsi_spec.rb +0 -69
  139. data/spec/unit/plugins/shard_spec.rb +0 -121
  140. data/spec/unit/plugins/shells_spec.rb +0 -56
  141. data/spec/unit/plugins/softlayer_spec.rb +0 -60
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
  143. data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
  144. data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
  145. data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
  146. data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
  147. data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
  148. data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
  149. data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
  150. data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
  151. data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
  152. data/spec/unit/plugins/sysconf_spec.rb +0 -680
  153. data/spec/unit/plugins/timezone_spec.rb +0 -30
  154. data/spec/unit/plugins/vbox_host_spec.rb +0 -14
  155. data/spec/unit/plugins/virtualbox_spec.rb +0 -375
  156. data/spec/unit/plugins/vmware_spec.rb +0 -81
  157. data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
  158. data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
  159. data/spec/unit/plugins/windows/fips_spec.rb +0 -60
  160. data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
  161. data/spec/unit/plugins/windows/memory_spec.rb +0 -52
  162. data/spec/unit/plugins/windows/network_spec.rb +0 -137
  163. data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
  164. data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
  165. data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
  166. data/spec/unit/plugins/zpools_spec.rb +0 -244
  167. data/spec/unit/provides_map_spec.rb +0 -208
  168. data/spec/unit/runner_spec.rb +0 -422
  169. data/spec/unit/system_spec.rb +0 -416
  170. data/spec/unit/util/file_helper_spec.rb +0 -47
  171. data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,100 +0,0 @@
1
- #
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 governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require "spec_helper"
18
-
19
- describe Ohai::System, "plugin joyent" do
20
- let(:plugin) { get_plugin("joyent") }
21
-
22
- describe "without joyent" do
23
- before do
24
- allow(plugin).to receive(:is_smartos?).and_return(false)
25
- end
26
-
27
- it "DOES NOT create joyent mash" do
28
- plugin.run
29
- expect(plugin[:joyent]).to be_nil
30
- end
31
- end
32
-
33
- describe "with joyent" do
34
- before do
35
- allow(plugin).to receive(:is_smartos?).and_return(true)
36
- plugin[:virtualization] = Mash.new
37
- plugin[:virtualization][:guest_uuid] = "global"
38
- end
39
-
40
- it "creates joyent mash" do
41
- plugin.run
42
- expect(plugin[:joyent]).not_to be_nil
43
- end
44
-
45
- describe "under global zone" do
46
- before do
47
- plugin.run
48
- end
49
-
50
- it "detects global zone" do
51
- expect(plugin[:joyent][:sm_uuid]).to eql "global"
52
- end
53
-
54
- it "DOES NOT create sm_id" do
55
- expect(plugin[:joyent][:sm_id]).to be_nil
56
- end
57
- end
58
-
59
- describe "under smartmachine" do
60
- before do
61
- plugin[:virtualization][:guest_uuid] = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
62
- plugin[:virtualization][:guest_id] = "30"
63
-
64
- etc_product = <<~EOS
65
- Name: Joyent Instance
66
- Image: pkgbuild 16.3.1
67
- Documentation: https://docs.joyent.com/images/smartos/pkgbuild
68
- EOS
69
-
70
- pkg_install_conf = <<~EOS
71
- GPG_KEYRING_VERIFY=/opt/local/etc/gnupg/pkgsrc.gpg
72
- GPG_KEYRING_PKGVULN=/opt/local/share/gnupg/pkgsrc-security.gpg
73
- PKG_PATH=https://pkgsrc.joyent.com/packages/SmartOS/2016Q3/x86_64/All
74
- VERIFIED_INSTALLATION=trusted
75
- EOS
76
-
77
- allow(::File).to receive(:read).with("/etc/product").and_return(etc_product)
78
- allow(::File).to receive(:read).with("/opt/local/etc/pkg_install.conf").and_return(pkg_install_conf)
79
- plugin.run
80
- end
81
-
82
- it "retrieves zone uuid" do
83
- expect(plugin[:joyent][:sm_uuid]).to eql "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
84
- end
85
-
86
- it "collects sm_id" do
87
- expect(plugin[:joyent][:sm_id]).to eql "30"
88
- end
89
-
90
- it "collects images" do
91
- expect(plugin[:joyent][:sm_image_id]).to eql "pkgbuild"
92
- expect(plugin[:joyent][:sm_image_ver]).to eql "16.3.1"
93
- end
94
-
95
- it "collects pkgsrc" do
96
- expect(plugin[:joyent][:sm_pkgsrc]).to eql "https://pkgsrc.joyent.com/packages/SmartOS/2016Q3/x86_64/All"
97
- end
98
- end
99
- end
100
- end
@@ -1,38 +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
-
21
- describe Ohai::System, "plugin kernel" do
22
- before do
23
- @plugin = get_plugin("kernel")
24
- allow(@plugin).to receive(:collect_os).and_return(:default) # for debugging
25
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "Darwin\n", ""))
26
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "9.5.0\n", ""))
27
- allow(@plugin).to receive(:shell_out).with("uname -v").and_return(mock_shell_out(0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""))
28
- allow(@plugin).to receive(:shell_out).with("uname -m").and_return(mock_shell_out(0, "i386\n", ""))
29
- allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux\n", ""))
30
- allow(@plugin).to receive(:shell_out).with("uname -p").and_return(mock_shell_out(0, "i386\n", ""))
31
- end
32
-
33
- it_should_check_from_mash("kernel", "name", "uname -s", [0, "Darwin\n", ""])
34
- it_should_check_from_mash("kernel", "release", "uname -r", [0, "9.5.0\n", ""])
35
- it_should_check_from_mash("kernel", "version", "uname -v", [0, "Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1\/RELEASE_I386\n", ""])
36
- it_should_check_from_mash("kernel", "machine", "uname -m", [0, "i386\n", ""])
37
- it_should_check_from_mash("kernel", "processor", "uname -p", [0, "i386\n", ""])
38
- end
@@ -1,135 +0,0 @@
1
- #
2
- # Author:: Aaron Kalin (<akalin@martinisoftware.com>)
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "spec_helper"
19
-
20
- describe Ohai::System, "plugin linode" do
21
- let(:plugin) { get_plugin("linode") }
22
-
23
- before do
24
- plugin[:network] = {
25
- "interfaces" => {
26
- "eth0" => {
27
- "addresses" => {
28
- "1.2.3.4" => {
29
- "broadcast" => "67.23.20.255",
30
- "netmask" => "255.255.255.0",
31
- "family" => "inet",
32
- },
33
- "fe80::4240:95ff:fe47:6eed" => {
34
- "scope" => "Link",
35
- "prefixlen" => "64",
36
- "family" => "inet6",
37
- },
38
- "40:40:95:47:6E:ED" => {
39
- "family" => "lladdr",
40
- },
41
- },
42
- },
43
- },
44
- }
45
- end
46
-
47
- shared_examples_for "!linode" do
48
- it "does not create the linode mash" do
49
- plugin.run
50
- expect(plugin[:linode]).to be_nil
51
- end
52
- end
53
-
54
- shared_examples_for "linode" do
55
- it "creates the linode mash" do
56
- plugin.run
57
- expect(plugin[:linode]).not_to be_nil
58
- end
59
-
60
- it "has public_ip attribute" do
61
- plugin.run
62
- expect(plugin[:linode][:public_ip]).not_to be_nil
63
- end
64
-
65
- it "has correct value for public_ip attribute" do
66
- plugin.run
67
- expect(plugin[:linode][:public_ip]).to eq("1.2.3.4")
68
- end
69
-
70
- end
71
-
72
- context "without linode kernel" do
73
- before do
74
- plugin[:kernel] = { "release" => "3.5.2-x86_64" }
75
- end
76
-
77
- it_behaves_like "!linode"
78
- end
79
-
80
- context "with linode kernel" do
81
- before do
82
- plugin[:kernel] = { "release" => "3.5.2-x86_64-linode24" }
83
- end
84
-
85
- it_behaves_like "linode"
86
-
87
- # This test is an interface created according to this guide by Linode
88
- # http://library.linode.com/networking/configuring-static-ip-interfaces
89
- context "with configured private ip address as suggested by linode" do
90
- before do
91
- plugin[:network][:interfaces]["eth0:1"] = {
92
- "addresses" => {
93
- "5.6.7.8" => {
94
- "broadcast" => "10.176.191.255",
95
- "netmask" => "255.255.224.0",
96
- "family" => "inet",
97
- },
98
- "fe80::4240:f5ff:feab:2836" => {
99
- "scope" => "Link",
100
- "prefixlen" => "64",
101
- "family" => "inet6",
102
- },
103
- "40:40:F5:AB:28:36" => {
104
- "family" => "lladdr",
105
- },
106
- },
107
- }
108
- end
109
-
110
- it "detects and sets the private ip" do
111
- plugin.run
112
- expect(plugin[:linode][:private_ip]).not_to be_nil
113
- expect(plugin[:linode][:private_ip]).to eq("5.6.7.8")
114
- end
115
- end
116
-
117
- end
118
-
119
- describe "with linode hint file" do
120
- before do
121
- allow(plugin).to receive(:hint?).with("linode").and_return({})
122
- end
123
-
124
- it_behaves_like "linode"
125
- end
126
-
127
- describe "without hint file" do
128
- before do
129
- allow(plugin).to receive(:hint?).with("linode").and_return(false)
130
- end
131
-
132
- it_behaves_like "!linode"
133
- end
134
-
135
- end
@@ -1,75 +0,0 @@
1
- #
2
- # Author:: Jennifer Marie Howard-Brown <jm.howardbrown@gmail.com>
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require "spec_helper"
19
-
20
- describe Ohai::System, "Linux Block Device Plugin" do
21
- DISKS = {
22
- "sda" => {
23
- "size" => "7814037168",
24
- "removable" => "0",
25
- "model" => "WDC WD4000F9YZ-0",
26
- "rev" => "1A01",
27
- "state" => "running",
28
- "timeout" => "30",
29
- "queue_depth" => "1",
30
- "vendor" => "ATA",
31
- },
32
- "dm-0" => {
33
- "size" => "7806976",
34
- "removable" => "0",
35
- },
36
- }.freeze
37
-
38
- def file_double(value)
39
- tmp_double = double
40
- expect(tmp_double).to receive(:read_nonblock).and_return(value)
41
- tmp_double
42
- end
43
-
44
- before do
45
- @plugin = get_plugin("linux/block_device")
46
- allow(@plugin).to receive(:collect_os).and_return(:linux)
47
-
48
- allow(File).to receive(:exist?).with("/sys/block").and_return(true)
49
- allow(Dir).to receive(:[]).with("/sys/block/*") do
50
- DISKS.collect { |disk, _files| "/sys/block/#{disk}" }
51
- end
52
-
53
- DISKS.each do |disk, checks|
54
- checks.each do |check, value|
55
- allow(File).to receive(:open).with(Regexp.new("#{disk}.*#{check}")).and_yield(file_double(value))
56
- end
57
-
58
- allow(File).to receive(:exist?).with(Regexp.new(disk)) do |arg|
59
- filepath = arg.split("/")
60
- checks[filepath.last].nil? ? false : true
61
- end
62
-
63
- allow(File).to receive(:basename) do |arg|
64
- arg.split("/").last
65
- end
66
- end
67
- end
68
-
69
- it "collects all relevant data from disks" do
70
- @plugin.run
71
- DISKS.each do |disk, checks|
72
- expect(@plugin[:block_device][disk.to_sym]).to include(checks)
73
- end
74
- end
75
- end
@@ -1,441 +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 "tempfile"
20
- require "spec_helper"
21
-
22
- shared_examples "Common cpu info" do |total_cpu, real_cpu|
23
- describe "cpu" do
24
- it "has cpu[:total] equals to #{total_cpu}" do
25
- plugin.run
26
- expect(plugin[:cpu][:total]).to eq(total_cpu)
27
- end
28
-
29
- it "has cpu[:real] equals to #{real_cpu}" do
30
- plugin.run
31
- expect(plugin[:cpu][:real]).to eq(real_cpu)
32
- end
33
-
34
- it "has a cpu 0" do
35
- plugin.run
36
- expect(plugin[:cpu]).to have_key("0")
37
- end
38
- end
39
- end
40
-
41
- shared_examples "S390 processor info" do |cpu_no, version, identification, machine|
42
- describe "S390 processor" do
43
- it "has a version for cpu #{cpu_no}" do
44
- plugin.run
45
- expect(plugin[:cpu][cpu_no.to_s]).to have_key("version")
46
- expect(plugin[:cpu][cpu_no.to_s]["version"]).to eql(version)
47
- end
48
-
49
- it "has a identification for cpu #{cpu_no}" do
50
- plugin.run
51
- expect(plugin[:cpu][cpu_no.to_s]).to have_key("identification")
52
- expect(plugin[:cpu][cpu_no.to_s]["identification"]).to eql(identification)
53
- end
54
-
55
- it "has a machine for cpu #{cpu_no}" do
56
- plugin.run
57
- expect(plugin[:cpu][cpu_no.to_s]).to have_key("machine")
58
- expect(plugin[:cpu][cpu_no.to_s]["machine"]).to eql(machine)
59
- end
60
- end
61
- end
62
-
63
- shared_examples "arm64 processor info" do |cpu_no, bogomips, features|
64
- describe "arm64 processor" do
65
- it "has bogomips for cpu #{cpu_no}" do
66
- plugin.run
67
- expect(plugin[:cpu][cpu_no.to_s]).to have_key("bogomips")
68
- expect(plugin[:cpu][cpu_no.to_s]["bogomips"]).to eql(bogomips)
69
- end
70
-
71
- it "has features for cpu #{cpu_no}" do
72
- plugin.run
73
- expect(plugin[:cpu][cpu_no.to_s]).to have_key("features")
74
- expect(plugin[:cpu][cpu_no.to_s]["features"]).to eql(features)
75
- end
76
- end
77
- end
78
-
79
- describe Ohai::System, "General Linux cpu plugin" do
80
- let(:plugin) { get_plugin("cpu") }
81
-
82
- let(:tempfile_handle) do
83
- tempfile = Tempfile.new("ohai-rspec-proc-cpuinfo")
84
- tempfile.write cpuinfo_contents
85
- tempfile.rewind
86
- tempfile
87
- end
88
-
89
- before do
90
- allow(plugin).to receive(:collect_os).and_return(:linux)
91
- allow(File).to receive(:open).with("/proc/cpuinfo").and_return(tempfile_handle)
92
- end
93
-
94
- after do
95
-
96
- tempfile.close
97
- tempfile.unlink
98
- rescue
99
- # really do not care
100
-
101
- end
102
-
103
- context "with old kernel that doesn't include cores in /proc/cpuinfo" do
104
- let(:cpuinfo_contents) do
105
- <<-EOF
106
- processor : 0
107
- vendor_id : GenuineIntel
108
- cpu family : 6
109
- model : 23
110
- model name : Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
111
- stepping : 6
112
- cpu MHz : 1968.770
113
- cache size : 64 KB
114
- fdiv_bug : no
115
- hlt_bug : no
116
- f00f_bug : no
117
- coma_bug : no
118
- fpu : yes
119
- fpu_exception : yes
120
- cpuid level : 10
121
- wp : yes
122
- flags : fpu pse tsc msr mce cx8 sep mtrr pge cmov
123
- bogomips : 2575.86
124
- clflush size : 32
125
- EOF
126
- end
127
-
128
- let(:lscpu) do
129
- <<~EOF
130
- Architecture: x86_64
131
- CPU op-mode(s): 32-bit, 64-bit
132
- Byte Order: Little Endian
133
- CPU(s): 1
134
- On-line CPU(s) list: 0
135
- Thread(s) per core: 1
136
- Core(s) per socket: 1
137
- Socket(s): 1
138
- NUMA node(s): 1
139
- Vendor ID: GenuineIntel
140
- CPU family: 6
141
- Model: 23
142
- Model name: Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz
143
- Stepping: 2
144
- CPU MHz: 1968.770
145
- BogoMIPS: 2575.86
146
- Hypervisor vendor: Xen
147
- Virtualization type: full
148
- L1d cache: 32K
149
- L1i cache: 32K
150
- L2 cache: 256K
151
- L3 cache: 30720K
152
- NUMA node0 CPU(s): 0
153
- Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx rdtscp lm constant_tsc rep_good nopl xtopology pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm fsgsbase bmi1 avx2 smep bmi2 erms invpcid xsaveopt
154
- EOF
155
- end
156
-
157
- before do
158
- allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(0, lscpu, ""))
159
- end
160
-
161
- it_behaves_like "Common cpu info", 1, 1
162
-
163
- it "gets total cores" do
164
- plugin.run
165
- expect(plugin[:cpu][:cores]).to be(1)
166
- end
167
-
168
- it "doesn't have a cpu 1" do
169
- plugin.run
170
- expect(plugin[:cpu]).not_to have_key("1")
171
- end
172
-
173
- it "has a vendor_id for cpu 0" do
174
- plugin.run
175
- expect(plugin[:cpu]["0"]).to have_key("vendor_id")
176
- expect(plugin[:cpu]["0"]["vendor_id"]).to eql("GenuineIntel")
177
- end
178
-
179
- it "has a family for cpu 0" do
180
- plugin.run
181
- expect(plugin[:cpu]["0"]).to have_key("family")
182
- expect(plugin[:cpu]["0"]["family"]).to eql("6")
183
- end
184
-
185
- it "has a model for cpu 0" do
186
- plugin.run
187
- expect(plugin[:cpu]["0"]).to have_key("model")
188
- expect(plugin[:cpu]["0"]["model"]).to eql("23")
189
- end
190
-
191
- it "has a stepping for cpu 0" do
192
- plugin.run
193
- expect(plugin[:cpu]["0"]).to have_key("stepping")
194
- expect(plugin[:cpu]["0"]["stepping"]).to eql("6")
195
- end
196
-
197
- it "doesn't have a phyiscal_id for cpu 0" do
198
- plugin.run
199
- expect(plugin[:cpu]["0"]).not_to have_key("physical_id")
200
- end
201
-
202
- it "doesn't have a core_id for cpu 0" do
203
- plugin.run
204
- expect(plugin[:cpu]["0"]).not_to have_key("core_id")
205
- end
206
-
207
- it "doesn't have a cores for cpu 0" do
208
- plugin.run
209
- expect(plugin[:cpu]["0"]).not_to have_key("cores")
210
- end
211
-
212
- it "has a model name for cpu 0" do
213
- plugin.run
214
- expect(plugin[:cpu]["0"]).to have_key("model_name")
215
- expect(plugin[:cpu]["0"]["model_name"]).to eql("Intel(R) Core(TM)2 Duo CPU T8300 @ 2.40GHz")
216
- end
217
-
218
- it "has a mhz for cpu 0" do
219
- plugin.run
220
- expect(plugin[:cpu]["0"]).to have_key("mhz")
221
- expect(plugin[:cpu]["0"]["mhz"]).to eql("1968.770")
222
- end
223
-
224
- it "has a cache_size for cpu 0" do
225
- plugin.run
226
- expect(plugin[:cpu]["0"]).to have_key("cache_size")
227
- expect(plugin[:cpu]["0"]["cache_size"]).to eql("64 KB")
228
- end
229
-
230
- it "has flags for cpu 0" do
231
- plugin.run
232
- expect(plugin[:cpu]["0"]).to have_key("flags")
233
- expect(plugin[:cpu]["0"]["flags"]).to eq(%w{fpu pse tsc msr mce cx8 sep mtrr pge cmov})
234
- end
235
- end
236
-
237
- context "with a dual-core hyperthreaded /proc/cpuinfo" do
238
- let(:cpuinfo_contents) do
239
- <<~EOF
240
- processor : 0
241
- vendor_id : GenuineIntel
242
- cpu family : 6
243
- model : 69
244
- model name : Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
245
- stepping : 1
246
- microcode : 0x17
247
- cpu MHz : 774.000
248
- cache size : 4096 KB
249
- physical id : 0
250
- siblings : 4
251
- core id : 0
252
- cpu cores : 2
253
- apicid : 0
254
- initial apicid : 0
255
- fpu : yes
256
- fpu_exception : yes
257
- cpuid level : 13
258
- wp : yes
259
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
260
- bogomips : 3591.40
261
- clflush size : 64
262
- cache_alignment : 64
263
- address sizes : 39 bits physical, 48 bits virtual
264
- power management:
265
-
266
- processor : 1
267
- vendor_id : GenuineIntel
268
- cpu family : 6
269
- model : 69
270
- model name : Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
271
- stepping : 1
272
- microcode : 0x17
273
- cpu MHz : 1600.000
274
- cache size : 4096 KB
275
- physical id : 0
276
- siblings : 4
277
- core id : 0
278
- cpu cores : 2
279
- apicid : 1
280
- initial apicid : 1
281
- fpu : yes
282
- fpu_exception : yes
283
- cpuid level : 13
284
- wp : yes
285
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
286
- bogomips : 3591.40
287
- clflush size : 64
288
- cache_alignment : 64
289
- address sizes : 39 bits physical, 48 bits virtual
290
- power management:
291
-
292
- processor : 2
293
- vendor_id : GenuineIntel
294
- cpu family : 6
295
- model : 69
296
- model name : Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
297
- stepping : 1
298
- microcode : 0x17
299
- cpu MHz : 800.000
300
- cache size : 4096 KB
301
- physical id : 0
302
- siblings : 4
303
- core id : 1
304
- cpu cores : 2
305
- apicid : 2
306
- initial apicid : 2
307
- fpu : yes
308
- fpu_exception : yes
309
- cpuid level : 13
310
- wp : yes
311
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
312
- bogomips : 3591.40
313
- clflush size : 64
314
- cache_alignment : 64
315
- address sizes : 39 bits physical, 48 bits virtual
316
- power management:
317
-
318
- processor : 3
319
- vendor_id : GenuineIntel
320
- cpu family : 6
321
- model : 69
322
- model name : Intel(R) Core(TM) i7-4500U CPU @ 1.80GHz
323
- stepping : 1
324
- microcode : 0x17
325
- cpu MHz : 774.000
326
- cache size : 4096 KB
327
- physical id : 0
328
- siblings : 4
329
- core id : 1
330
- cpu cores : 2
331
- apicid : 3
332
- initial apicid : 3
333
- fpu : yes
334
- fpu_exception : yes
335
- cpuid level : 13
336
- wp : yes
337
- flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid
338
- bogomips : 3591.40
339
- clflush size : 64
340
- cache_alignment : 64
341
- address sizes : 39 bits physical, 48 bits virtual
342
- power management:
343
-
344
- EOF
345
- end
346
-
347
- it "has 1 physical socket" do
348
- plugin.run
349
- expect(plugin[:cpu][:real]).to eq(1)
350
- end
351
-
352
- it "has 2 physical cores" do
353
- plugin.run
354
- expect(plugin[:cpu][:cores]).to eq(2)
355
- end
356
-
357
- it "has 4 logical, hyper-threaded cores" do
358
- plugin.run
359
- expect(plugin[:cpu][:total]).to eq(4)
360
- end
361
- end
362
- end
363
-
364
- describe Ohai::System, "S390 linux cpu plugin" do
365
- let(:plugin) { get_plugin("cpu") }
366
-
367
- before do
368
- allow(plugin).to receive(:collect_os).and_return(:linux)
369
- allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", ""))
370
-
371
- @double_file = double("/proc/cpuinfo")
372
- allow(@double_file).to receive(:each)
373
- .and_yield("vendor_id : IBM/S390")
374
- .and_yield("# processors : 2")
375
- .and_yield("bogomips per cpu: 9328.00")
376
- .and_yield("features : esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs")
377
- .and_yield("processor 0: version = EE, identification = 06E276, machine = 2717")
378
- .and_yield("processor 1: version = FF, identification = 06E278, machine = 2818")
379
- allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
380
- end
381
-
382
- it_behaves_like "Common cpu info", 2, nil
383
-
384
- it "has a cpu 1" do
385
- plugin.run
386
- expect(plugin[:cpu]).to have_key("1")
387
- end
388
-
389
- it "has a vendor_id" do
390
- plugin.run
391
- expect(plugin[:cpu]).to have_key("vendor_id")
392
- expect(plugin[:cpu]["vendor_id"]).to eql("IBM/S390")
393
- end
394
-
395
- it "has a bogomips per cpu" do
396
- plugin.run
397
- expect(plugin[:cpu]).to have_key("bogomips_per_cpu")
398
- expect(plugin[:cpu]["bogomips_per_cpu"]).to eql("9328.00")
399
- end
400
-
401
- it "has features" do
402
- plugin.run
403
- expect(plugin[:cpu]).to have_key("features")
404
- expect(plugin[:cpu]["features"]).to eq(%w{esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs})
405
- end
406
-
407
- it_behaves_like "S390 processor info", 0, "EE", "06E276", "2717"
408
- it_behaves_like "S390 processor info", 1, "FF", "06E278", "2818"
409
- end
410
-
411
- describe Ohai::System, "arm64 linux cpu plugin" do
412
- let(:plugin) { get_plugin("cpu") }
413
-
414
- before do
415
- allow(plugin).to receive(:collect_os).and_return(:linux)
416
- allow(plugin).to receive(:shell_out).with("lscpu").and_return(mock_shell_out(1, "", ""))
417
-
418
- @double_file = double("/proc/cpuinfo")
419
- allow(@double_file).to receive(:each)
420
- .and_yield("processor : 0")
421
- .and_yield("BogoMIPS : 40.00")
422
- .and_yield("Features : fp asimd evtstrm aes pmull sha1 sha2 crc32")
423
- .and_yield("")
424
- .and_yield("processor : 1")
425
- .and_yield("BogoMIPS : 40.00")
426
- .and_yield("Features : fp asimd evtstrm aes pmull sha1 sha2 crc32")
427
- .and_yield("")
428
- allow(File).to receive(:open).with("/proc/cpuinfo").and_return(@double_file)
429
- end
430
-
431
- it_behaves_like "Common cpu info", 2, nil
432
-
433
- it "has a cpu 1" do
434
- plugin.run
435
- expect(plugin[:cpu]).to have_key("1")
436
- end
437
-
438
- features = %w{fp asimd evtstrm aes pmull sha1 sha2 crc32}
439
- it_behaves_like "arm64 processor info", 0, "40.00", features
440
- it_behaves_like "arm64 processor info", 1, "40.00", features
441
- end