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,129 +0,0 @@
1
- #
2
- # Author:: Tim Smith <tsmith@limelight.com>
3
- # Copyright:: Copyright (c) 2014 Limelight Networks, 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, "FreeBSD cpu plugin on FreeBSD >=10.2" do
22
- before do
23
- @plugin = get_plugin("cpu")
24
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
- @double_file = double("/var/run/dmesg.boot")
26
- allow(@double_file).to receive(:each)
27
- .and_yield("CPU: Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz (2793.59-MHz K8-class CPU)")
28
- .and_yield(' Origin="GenuineIntel" Id=0x40661 Family=0x6 Model=0x46 Stepping=1')
29
- .and_yield(" Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>")
30
- .and_yield(" Features2=0x5ed8220b<SSE3,PCLMULQDQ,MON,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AESNI,XSAVE,OSXSAVE,AVX,RDRAND>")
31
- .and_yield(" AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>")
32
- .and_yield(" AMD Features2=0x21<LAHF,ABM>")
33
- .and_yield(" Structured Extended Features=0x2000<NFPUSG>")
34
- .and_yield(" TSC: P-state invariant")
35
- .and_yield("real memory = 1073676288 (1023 MB)")
36
- .and_yield("avail memory = 1010253824 (963 MB)")
37
- .and_yield('Event timer "LAPIC" quality 400')
38
- .and_yield("ACPI APIC Table: <VBOX VBOXAPIC>")
39
- .and_yield("FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs")
40
- .and_yield("FreeBSD/SMP: 2 package(s) x 4 core(s) x 2 SMT threads")
41
- allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
42
- end
43
-
44
- it "detects all CPU flags" do
45
- @plugin.run
46
- expect(@plugin[:cpu][:flags]).to eq(%w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 pclmulqdq mon ssse3 cx16 sse4.1 sse4.2 movbe popcnt aesni xsave osxsave avx rdrand syscall nx rdtscp lm lahf abm nfpusg})
47
- end
48
-
49
- it "detects CPU model_name" do
50
- @plugin.run
51
- expect(@plugin[:cpu][:model_name]).to eq("Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz")
52
- end
53
-
54
- it "detects CPU mhz" do
55
- @plugin.run
56
- expect(@plugin[:cpu][:mhz]).to eq("2793.59")
57
- end
58
-
59
- it "detects CPU vendor_id" do
60
- @plugin.run
61
- expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
62
- end
63
-
64
- it "detects CPU family" do
65
- @plugin.run
66
- expect(@plugin[:cpu][:family]).to eq("6")
67
- end
68
-
69
- it "detects CPU model" do
70
- @plugin.run
71
- expect(@plugin[:cpu][:model]).to eq("70")
72
- end
73
-
74
- it "detects CPU stepping" do
75
- @plugin.run
76
- expect(@plugin[:cpu][:stepping]).to eq("1")
77
- end
78
-
79
- it "detects real CPUs" do
80
- @plugin.run
81
- expect(@plugin[:cpu][:real]).to eq(2)
82
- end
83
-
84
- it "detects total real CPU cores" do
85
- @plugin.run
86
- expect(@plugin[:cpu][:cores]).to eq(8)
87
- end
88
-
89
- it "detects total HT CPU cores" do
90
- @plugin.run
91
- expect(@plugin[:cpu][:total]).to eq(16)
92
- end
93
-
94
- end
95
-
96
- describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do
97
- before do
98
- @plugin = get_plugin("cpu")
99
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
100
- allow(@plugin).to receive(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
101
- @double_file = double("/var/run/dmesg.boot")
102
- allow(@double_file).to receive(:each)
103
- .and_yield("CPU: Intel(R) Atom(TM) CPU N270 @ 1.60GHz (1596.03-MHz 686-class CPU)")
104
- .and_yield(' Origin = "GenuineIntel" Id = 0x106c2 Family = 0x6 Model = 0x1c Stepping = 2')
105
- allow(File).to receive(:open).with("/var/run/dmesg.boot").and_return(@double_file)
106
- end
107
-
108
- it "detects CPU vendor_id" do
109
- @plugin.run
110
- expect(@plugin[:cpu][:vendor_id]).to eq("GenuineIntel")
111
- end
112
-
113
- it "detects CPU family" do
114
- @plugin.run
115
- expect(@plugin[:cpu][:family]).to eq("6")
116
- end
117
-
118
- it "detects CPU model" do
119
- @plugin.run
120
-
121
- expect(@plugin[:cpu][:model]).to eq("28")
122
- end
123
-
124
- it "detects CPU stepping" do
125
- @plugin.run
126
- expect(@plugin[:cpu][:stepping]).to eq("2")
127
- end
128
-
129
- end
@@ -1,35 +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, "FreeBSD hostname plugin" do
22
- before do
23
- @plugin = get_plugin("hostname")
24
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
26
- allow(@plugin).to receive(:shell_out).with("hostname -f").and_return(mock_shell_out(0, "katie.bethell", ""))
27
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
28
- end
29
-
30
- it_should_check_from("freebsd::hostname", "hostname", "hostname -s", "katie")
31
-
32
- it_should_check_from("freebsd::hostname", "fqdn", "hostname -f", "katie.bethell")
33
-
34
- it_should_check_from("freebsd::hostname", "machinename", "hostname", "katie.local")
35
- end
@@ -1,36 +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, "FreeBSD kernel plugin" do
22
- before do
23
- @plugin = get_plugin("kernel")
24
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
25
- allow(@plugin).to receive(:init_kernel).and_return({ name: "freebsd" })
26
- allow(@plugin).to receive(:shell_out).with("uname -i").and_return(mock_shell_out(0, "foo\n", ""))
27
- allow(@plugin).to receive(:shell_out).with("sysctl kern.securelevel").and_return(mock_shell_out(0, "kern.securelevel: 1", ""))
28
- allow(@plugin).to receive(:shell_out).with( Ohai.abs_path( "/sbin/kldstat" )).and_return(mock_shell_out(0, " 1 7 0xc0400000 97f830 kernel", ""))
29
- end
30
-
31
- it "sets the kernel_os to the kernel_name value" do
32
- @plugin.run
33
- expect(@plugin[:kernel][:os]).to eq(@plugin[:kernel][:name])
34
- end
35
-
36
- 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, "FreeBSD plugin platform" do
22
- before do
23
- @plugin = get_plugin("freebsd/platform")
24
- allow(@plugin).to receive(:shell_out).with("uname -s").and_return(mock_shell_out(0, "FreeBSD\n", ""))
25
- allow(@plugin).to receive(:shell_out).with("uname -r").and_return(mock_shell_out(0, "7.1\n", ""))
26
- allow(@plugin).to receive(:collect_os).and_return(:freebsd)
27
- end
28
-
29
- it "sets platform to lowercased lsb[:id]" do
30
- @plugin.run
31
- expect(@plugin[:platform]).to eq("freebsd")
32
- end
33
-
34
- it "sets platform_version to lsb[:release]" do
35
- @plugin.run
36
- expect(@plugin[:platform_version]).to eq("7.1")
37
- end
38
- end
@@ -1,81 +0,0 @@
1
- #
2
- # Author:: Ranjib Dey (dey.ranjib@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 CONDIT"Net::HTTP Response"NS 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
- require "open-uri"
20
-
21
- describe Ohai::System, "plugin gce" do
22
- let(:plugin) { get_plugin("gce") }
23
-
24
- shared_examples_for "!gce" do
25
- it "does NOT attempt to fetch the gce metadata" do
26
- expect(plugin).not_to receive(:http_get)
27
- plugin.run
28
- end
29
-
30
- it "does NOT set gce attributes" do
31
- expect(plugin[:gce]).to be_nil
32
- plugin.run
33
- end
34
- end
35
-
36
- shared_examples_for "gce" do
37
- before do
38
- @http_get = double("Net::HTTP client")
39
- allow(plugin).to receive(:http_get).and_return(double("Net::HTTP Response", body: '{"instance":{"hostname":"test-host"}}', code: "200"))
40
- allow(IO).to receive(:select).and_return([[], [1], []])
41
- t = double("connection")
42
- allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
43
- allow(Socket).to receive(:new).and_return(t)
44
- allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
45
- end
46
-
47
- it "recursively fetches and properly parses json metadata" do
48
- plugin.run
49
-
50
- expect(plugin[:gce]).not_to be_nil
51
- expect(plugin[:gce]["instance"]).to eq("hostname" => "test-host")
52
- end
53
-
54
- end
55
-
56
- describe "with hint file and with metadata connection" do
57
- before do
58
- allow(plugin).to receive(:hint?).with("gce").and_return({})
59
- end
60
-
61
- it_behaves_like "gce"
62
-
63
- end
64
-
65
- describe "without hint file and without metadata connection" do
66
- before do
67
- allow(plugin).to receive(:hint?).with("gce").and_return(false)
68
-
69
- # Raise Errno::ENOENT to simulate the scenario in which metadata server
70
- # can not be connected
71
- t = double("connection")
72
- allow(t).to receive(:connect_nonblock).and_raise(Errno::ENOENT)
73
- allow(Socket).to receive(:new).and_return(t)
74
- allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
75
- end
76
-
77
- it_behaves_like "!gce"
78
-
79
- end
80
-
81
- end
@@ -1,48 +0,0 @@
1
- # Author:: Christian Vozar (<christian@rogueethic.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 governing permissions and
14
- # limitations under the License.
15
-
16
- require "spec_helper"
17
-
18
- describe Ohai::System, "plugin go" do
19
- let(:plugin) { get_plugin("go") }
20
-
21
- before do
22
- plugin[:languages] = Mash.new
23
- stdout = "go version go1.6.1 darwin/amd64\n"
24
- allow(plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(0, stdout, ""))
25
- end
26
-
27
- it "shells out to get the go version" do
28
- expect(plugin).to receive(:shell_out).with("go version")
29
- plugin.run
30
- end
31
-
32
- it "sets languages[:go][:version]" do
33
- plugin.run
34
- expect(plugin.languages[:go][:version]).to eql("1.6.1")
35
- end
36
-
37
- it "does not set languages[:go] if go command fails" do
38
- allow(plugin).to receive(:shell_out).with("go version").and_return(mock_shell_out(1, "", ""))
39
- plugin.run
40
- expect(plugin.languages).not_to have_key(:go)
41
- end
42
-
43
- it "does not set languages[:go] if go command doesn't exist" do
44
- allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
45
- plugin.run
46
- expect(plugin.languages).not_to have_key(:go)
47
- end
48
- end
@@ -1,66 +0,0 @@
1
- #
2
- # Author:: Doug MacEachern <dougm@vmware.com>
3
- # Copyright:: Copyright (c) 2009 VMware, 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 groovy" do
22
- let(:plugin) { get_plugin("groovy") }
23
-
24
- before do
25
- plugin[:languages] = Mash.new
26
- end
27
-
28
- it "shells out to groovy -v" do
29
- allow(plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, "", ""))
30
- expect(plugin).to receive(:shell_out).with("groovy -v")
31
- plugin.run
32
- end
33
-
34
- it "sets languages[:groovy][:version] on newer groovy versions" do
35
- new_stdout = "Groovy Version: 2.4.6 JVM: 1.8.0_60 Vendor: Oracle Corporation OS: Mac OS X\n"
36
- allow(plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, new_stdout, ""))
37
- plugin.run
38
- expect(plugin.languages[:groovy][:version]).to eql("2.4.6")
39
- end
40
-
41
- it "sets languages[:groovy][:version] on older groovy versions" do
42
- old_stdout = "Groovy Version: 1.6.3 JVM: 1.6.0_0\n"
43
- allow(plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, old_stdout, ""))
44
- plugin.run
45
- expect(plugin.languages[:groovy][:version]).to eql("1.6.3")
46
- end
47
-
48
- it "sets languages[:groovy][:jvm]" do
49
- new_stdout = "Groovy Version: 2.4.6 JVM: 1.8.0_60 Vendor: Oracle Corporation OS: Mac OS X\n"
50
- allow(plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(0, new_stdout, ""))
51
- plugin.run
52
- expect(plugin.languages[:groovy][:jvm]).to eql("1.8.0_60")
53
- end
54
-
55
- it "does not set languages[:groovy] if groovy command fails" do
56
- allow(plugin).to receive(:shell_out).with("groovy -v").and_return(mock_shell_out(1, "", ""))
57
- plugin.run
58
- expect(plugin.languages).not_to have_key(:groovy)
59
- end
60
-
61
- it "does not set languages[:groovy] if groovy command doesn't exist" do
62
- allow(plugin).to receive(:shell_out).and_raise(Ohai::Exceptions::Exec)
63
- plugin.run
64
- expect(plugin.languages).not_to have_key(:groovy)
65
- end
66
- end
@@ -1,231 +0,0 @@
1
- # Author:: Chris Dituri (<csdituri@gmail.com>)
2
- # Copyright:: Copyright (c) 2016 Chris Dituri
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
- require "spec_helper"
18
-
19
- describe Ohai::System, "plugin haskell" do
20
-
21
- let(:plugin) do
22
- get_plugin("haskell").tap do |plugin|
23
- plugin[:languages] = Mash.new
24
- end
25
- end
26
-
27
- let(:ghc_out) { "The Glorious Glasgow Haskell Compilation System, version 7.6.3" }
28
- let(:ghci_out) { "The Glorious Glasgow Haskell Compilation System, version 7.6.3" }
29
- let(:cabal_out) { "cabal-install version 1.16.0.2\nusing version 1.16.0 of the Cabal library" }
30
- let(:stack_out) { "Version 1.2.0 x86_64 hpack-0.14.0" }
31
- let(:stack_out_git) { "Version 1.1.0, Git revision 0e9430aad55841b5ff2c6c2851f0548c16bce7cf (3540 commits) x86_64 hpack-0.13.0" }
32
-
33
- def setup_plugin
34
- allow(plugin).to receive(:shell_out)
35
- .with("ghc --version")
36
- .and_return(mock_shell_out(0, ghc_out, ""))
37
- allow(plugin).to receive(:shell_out)
38
- .with("ghci --version")
39
- .and_return(mock_shell_out(0, ghci_out, ""))
40
- allow(plugin).to receive(:shell_out)
41
- .with("cabal --version")
42
- .and_return(mock_shell_out(0, cabal_out, ""))
43
- allow(plugin).to receive(:shell_out)
44
- .with("stack --version")
45
- .and_return(mock_shell_out(0, stack_out, ""))
46
- end
47
-
48
- context "if haskell/ghc is installed" do
49
-
50
- before do
51
- setup_plugin
52
- plugin.run
53
- end
54
-
55
- it "set languages[:haskell][:ghc][:version]" do
56
- expect(plugin[:languages][:haskell][:ghc][:version]).to eql("7.6.3")
57
- end
58
-
59
- it "set languages[:haskell][:ghc][:description]" do
60
- expect(plugin[:languages][:haskell][:ghc][:description]).to eql(ghc_out)
61
- end
62
- end
63
-
64
- context "if haskell/ghci is installed" do
65
-
66
- before do
67
- setup_plugin
68
- plugin.run
69
- end
70
-
71
- it "set languages[:haskell][:ghci][:version]" do
72
- expect(plugin[:languages][:haskell][:ghci][:version]).to eql("7.6.3")
73
- end
74
-
75
- it "set languages[:haskell][:ghci][:description]" do
76
- expect(plugin[:languages][:haskell][:ghci][:description]).to eql(ghci_out)
77
- end
78
- end
79
-
80
- context "if haskell/cabal is installed" do
81
-
82
- before do
83
- setup_plugin
84
- plugin.run
85
- end
86
-
87
- it "set languages[:haskell][:cabal][:version]" do
88
- expect(plugin[:languages][:haskell][:cabal][:version]).to eql("1.16.0.2")
89
- end
90
-
91
- it "set languages[:haskell][:cabal][:description]" do
92
- expect(plugin[:languages][:haskell][:cabal][:description]).to eql(cabal_out.split("\n")[0].chomp)
93
- end
94
- end
95
-
96
- context "if haskell/stack is installed" do
97
-
98
- before do
99
- setup_plugin
100
- plugin.run
101
- end
102
-
103
- it "set languages[:haskell][:stack][:version]" do
104
- expect(plugin[:languages][:haskell][:stack][:version]).to eql("1.2.0")
105
- end
106
-
107
- it "set languages[:haskell][:stack][:description]" do
108
- expect(plugin[:languages][:haskell][:stack][:description]).to eql(stack_out)
109
- end
110
- end
111
-
112
- context "if haskell/stack prerelease is installed" do
113
-
114
- before do
115
- setup_plugin
116
- allow(plugin).to receive(:shell_out)
117
- .with("stack --version")
118
- .and_return(mock_shell_out(0, stack_out_git, ""))
119
- plugin.run
120
- end
121
-
122
- it "set languages[:haskell][:stack][:version]" do
123
- expect(plugin[:languages][:haskell][:stack][:version]).to eql("1.1.0")
124
- end
125
-
126
- it "set languages[:haskell][:stack][:description]" do
127
- expect(plugin[:languages][:haskell][:stack][:description]).to eql(stack_out_git)
128
- end
129
- end
130
-
131
- context "if haskell is NOT installed" do
132
-
133
- before do
134
- allow(plugin).to receive(:shell_out)
135
- .and_raise( Ohai::Exceptions::Exec )
136
- plugin.run
137
- end
138
-
139
- it "do NOT set languages[:haskell]" do
140
- expect(plugin[:languages]).not_to have_key(:haskell)
141
- end
142
- end
143
-
144
- context "if haskell/ghc is NOT installed" do
145
- before do
146
- allow(plugin).to receive(:shell_out)
147
- .with("ghc --version")
148
- .and_raise( Ohai::Exceptions::Exec )
149
- allow(plugin).to receive(:shell_out)
150
- .with("ghci --version")
151
- .and_return(mock_shell_out(0, ghci_out, ""))
152
- allow(plugin).to receive(:shell_out)
153
- .with("cabal --version")
154
- .and_return(mock_shell_out(0, cabal_out, ""))
155
- allow(plugin).to receive(:shell_out)
156
- .with("stack --version")
157
- .and_return(mock_shell_out(0, stack_out, ""))
158
- plugin.run
159
- end
160
-
161
- it "do NOT set languages[:haskell][:ghc]" do
162
- expect(plugin[:languages][:haskell]).not_to have_key(:ghc)
163
- end
164
- end
165
-
166
- context "if haskell/ghci is NOT installed" do
167
- before do
168
- allow(plugin).to receive(:shell_out)
169
- .with("ghc --version")
170
- .and_return(mock_shell_out(0, ghc_out, ""))
171
- allow(plugin).to receive(:shell_out)
172
- .with("ghci --version")
173
- .and_raise( Ohai::Exceptions::Exec )
174
- allow(plugin).to receive(:shell_out)
175
- .with("cabal --version")
176
- .and_return(mock_shell_out(0, cabal_out, ""))
177
- allow(plugin).to receive(:shell_out)
178
- .with("stack --version")
179
- .and_return(mock_shell_out(0, stack_out, ""))
180
- plugin.run
181
- end
182
-
183
- it "do NOT set languages[:haskell][:ghci]" do
184
- expect(plugin[:languages][:haskell]).not_to have_key(:ghci)
185
- end
186
- end
187
-
188
- context "if haskell/cabal is NOT installed" do
189
- before do
190
- allow(plugin).to receive(:shell_out)
191
- .with("ghc --version")
192
- .and_return(mock_shell_out(0, ghc_out, ""))
193
- allow(plugin).to receive(:shell_out)
194
- .with("ghci --version")
195
- .and_return(mock_shell_out(0, ghci_out, ""))
196
- allow(plugin).to receive(:shell_out)
197
- .with("cabal --version")
198
- .and_raise( Ohai::Exceptions::Exec )
199
- allow(plugin).to receive(:shell_out)
200
- .with("stack --version")
201
- .and_return(mock_shell_out(0, stack_out, ""))
202
- plugin.run
203
- end
204
-
205
- it "do NOT set languages[:haskell][:cabal]" do
206
- expect(plugin[:languages][:haskell]).not_to have_key(:cabal)
207
- end
208
- end
209
-
210
- context "if haskell/stack is NOT installed" do
211
- before do
212
- allow(plugin).to receive(:shell_out)
213
- .with("ghc --version")
214
- .and_return(mock_shell_out(0, ghc_out, ""))
215
- allow(plugin).to receive(:shell_out)
216
- .with("ghci --version")
217
- .and_return(mock_shell_out(0, ghci_out, ""))
218
- allow(plugin).to receive(:shell_out)
219
- .with("cabal --version")
220
- .and_return(mock_shell_out(0, cabal_out, ""))
221
- allow(plugin).to receive(:shell_out)
222
- .with("stack --version")
223
- .and_raise( Ohai::Exceptions::Exec )
224
- plugin.run
225
- end
226
-
227
- it "do NOT set languages[:haskell][:stack]" do
228
- expect(plugin[:languages][:haskell]).not_to have_key(:stack)
229
- end
230
- end
231
- end