kanrisuru 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +9 -9
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +7 -8
  4. data/.gitignore +3 -1
  5. data/CHANGELOG.md +147 -125
  6. data/CODE_OF_CONDUCT.md +10 -10
  7. data/README.md +2 -0
  8. data/kanrisuru.gemspec +2 -1
  9. data/lib/kanrisuru/core/archive.rb +6 -5
  10. data/lib/kanrisuru/core/disk.rb +0 -3
  11. data/lib/kanrisuru/core/find.rb +4 -5
  12. data/lib/kanrisuru/core/socket.rb +2 -1
  13. data/lib/kanrisuru/remote/cpu.rb +6 -2
  14. data/lib/kanrisuru/remote/env.rb +8 -0
  15. data/lib/kanrisuru/remote/fstab.rb +4 -4
  16. data/lib/kanrisuru/util.rb +1 -1
  17. data/lib/kanrisuru/version.rb +1 -1
  18. data/spec/functional/core/apt_spec.rb +22 -30
  19. data/spec/functional/core/archive_spec.rb +169 -0
  20. data/spec/functional/core/find_spec.rb +94 -113
  21. data/spec/functional/core/socket_spec.rb +23 -28
  22. data/spec/functional/core/stream_spec.rb +12 -12
  23. data/spec/functional/core/transfer_spec.rb +108 -131
  24. data/spec/functional/core/yum_spec.rb +58 -83
  25. data/spec/functional/remote/cluster_spec.rb +12 -3
  26. data/spec/functional/remote/cpu_spec.rb +104 -0
  27. data/spec/functional/remote/env_spec.rb +48 -0
  28. data/spec/helper/stub_network.rb +52 -9
  29. data/spec/integration/core/file_spec.rb +0 -1
  30. data/spec/integration/core/find_spec.rb +1 -0
  31. data/spec/integration/core/system_spec.rb +0 -1
  32. data/spec/integration/core/zypper_spec.rb +3 -3
  33. data/spec/{functional → integration}/os_package_spec.rb +0 -0
  34. data/spec/spec_helper.rb +3 -0
  35. data/spec/unit/command_spec.rb +31 -0
  36. data/spec/unit/core/apt_spec.rb +20 -0
  37. data/spec/unit/core/archive_spec.rb +20 -0
  38. data/spec/unit/core/disk_spec.rb +23 -0
  39. data/spec/unit/core/dmi_spec.rb +20 -0
  40. data/spec/unit/core/file_spec.rb +35 -0
  41. data/spec/unit/core/find_spec.rb +21 -1
  42. data/spec/unit/core/group_spec.rb +24 -0
  43. data/spec/unit/core/ip_spec.rb +20 -0
  44. data/spec/unit/core/path_spec.rb +25 -0
  45. data/spec/unit/core/socket_spec.rb +20 -0
  46. data/spec/unit/core/stat_spec.rb +27 -0
  47. data/spec/unit/core/system_spec.rb +35 -0
  48. data/spec/unit/core/transfer_spec.rb +22 -0
  49. data/spec/unit/core/user_spec.rb +25 -0
  50. data/spec/unit/core/yum_spec.rb +20 -0
  51. data/spec/unit/core/zypper_spec.rb +20 -0
  52. data/spec/unit/mode_spec.rb +33 -2
  53. data/spec/unit/remote/cluster_spec.rb +36 -0
  54. data/spec/unit/remote/cpu_spec.rb +49 -0
  55. data/spec/unit/remote/env_spec.rb +17 -0
  56. data/spec/unit/{fstab_spec.rb → remote/fstab_spec.rb} +0 -0
  57. data/spec/unit/util_spec.rb +13 -0
  58. metadata +27 -5
@@ -3,6 +3,26 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Kanrisuru::Core::Yum do
6
+ before(:all) do
7
+ StubNetwork.stub!('centos')
8
+ end
9
+
10
+ after(:all) do
11
+ StubNetwork.unstub!
12
+ end
13
+
14
+ let(:host) do
15
+ Kanrisuru::Remote::Host.new(
16
+ host: 'centos-host',
17
+ username: 'centos',
18
+ keys: ['id_rsa']
19
+ )
20
+ end
21
+
22
+ it 'responds to methods' do
23
+ expect(host).to respond_to(:yum)
24
+ end
25
+
6
26
  it 'responds to yum fields' do
7
27
  expect(Kanrisuru::Core::Yum::PackageOverview.new).to respond_to(
8
28
  :package, :architecture, :version, :installed
@@ -3,6 +3,26 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Kanrisuru::Core::Zypper do
6
+ before(:all) do
7
+ StubNetwork.stub!('opensuse')
8
+ end
9
+
10
+ after(:all) do
11
+ StubNetwork.unstub!
12
+ end
13
+
14
+ let(:host) do
15
+ Kanrisuru::Remote::Host.new(
16
+ host: 'opensuse-host',
17
+ username: 'opensuse',
18
+ keys: ['id_rsa']
19
+ )
20
+ end
21
+
22
+ it 'responds to methods' do
23
+ expect(host).to respond_to(:zypper)
24
+ end
25
+
6
26
  it 'responds to zypper fields' do
7
27
  expect(Kanrisuru::Core::Zypper::PACKAGE_TYPES).to(
8
28
  eq(%w[package patch pattern product srcpackage application])
@@ -3,6 +3,18 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Kanrisuru::Mode do
6
+ it 'responds to methods' do
7
+ mode = described_class.new('644')
8
+ expect(mode).to respond_to(:directory?)
9
+ expect(mode).to respond_to(:symbolic)
10
+ expect(mode).to respond_to(:symbolic=)
11
+ expect(mode).to respond_to(:numeric)
12
+ expect(mode).to respond_to(:numeric=)
13
+ expect(mode).to respond_to(:inspect)
14
+ expect(mode).to respond_to(:to_s)
15
+ expect(mode).to respond_to(:to_i)
16
+ end
17
+
6
18
  it 'parses int mode' do
7
19
  mode = described_class.new('644')
8
20
  expect(mode.directory?).to eq(false)
@@ -80,9 +92,9 @@ RSpec.describe Kanrisuru::Mode do
80
92
  expect(mode.other.to_i).to eq(7)
81
93
  expect(mode.other.symbolic).to eq('rwx')
82
94
 
83
- mode = described_class.new("---x--x--x")
95
+ mode = described_class.new('---x--x--x')
84
96
  expect(mode.directory?).to eq(false)
85
- expect(mode.numeric).to eq("111")
97
+ expect(mode.numeric).to eq('111')
86
98
 
87
99
  expect(mode.owner.read?).to eq(false)
88
100
  expect(mode.owner.write?).to eq(false)
@@ -205,4 +217,23 @@ RSpec.describe Kanrisuru::Mode do
205
217
  mode.symbolic = '-w'
206
218
  expect(mode.symbolic).to eq('---xr-xr--')
207
219
  end
220
+
221
+ context Kanrisuru::Mode::Permission do
222
+ it 'responds to methods' do
223
+ mode = Kanrisuru::Mode::Permission.new('644', 'rw-rw-r--')
224
+ expect(mode).to respond_to(:to_i)
225
+ expect(mode).to respond_to(:to_s)
226
+ expect(mode).to respond_to(:all?)
227
+ expect(mode).to respond_to(:numeric)
228
+ expect(mode).to respond_to(:numeric=)
229
+ expect(mode).to respond_to(:symbolic=)
230
+ expect(mode).to respond_to(:symbolic)
231
+ expect(mode).to respond_to(:read=)
232
+ expect(mode).to respond_to(:read?)
233
+ expect(mode).to respond_to(:write=)
234
+ expect(mode).to respond_to(:write?)
235
+ expect(mode).to respond_to(:execute=)
236
+ expect(mode).to respond_to(:execute?)
237
+ end
238
+ end
208
239
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.describe Kanrisuru::Remote::Cluster do
4
+ before(:all) do
5
+ StubNetwork.stub!
6
+ end
7
+
8
+ after(:all) do
9
+ StubNetwork.unstub!
10
+ end
11
+
12
+ let(:host1) do
13
+ Kanrisuru::Remote::Host.new(
14
+ host: 'localhost',
15
+ username: 'ubuntu',
16
+ keys: ['id_rsa']
17
+ )
18
+ end
19
+
20
+ it 'responds to methods' do
21
+ cluster = described_class.new(host1)
22
+ expect(cluster).to respond_to(:hosts)
23
+ expect(cluster).to respond_to(:[])
24
+ expect(cluster).to respond_to(:<<)
25
+ expect(cluster).to respond_to(:delete)
26
+ expect(cluster).to respond_to(:execute)
27
+ expect(cluster).to respond_to(:execute_shell)
28
+ expect(cluster).to respond_to(:each)
29
+ expect(cluster).to respond_to(:hostname)
30
+ expect(cluster).to respond_to(:ping?)
31
+ expect(cluster).to respond_to(:su)
32
+ expect(cluster).to respond_to(:chdir)
33
+ expect(cluster).to respond_to(:cd)
34
+ expect(cluster).to respond_to(:disconnect)
35
+ end
36
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Remote::Cpu do
6
+ before(:all) do
7
+ StubNetwork.stub!
8
+ end
9
+
10
+ after(:all) do
11
+ StubNetwork.unstub!
12
+ end
13
+
14
+ let(:host) do
15
+ Kanrisuru::Remote::Host.new(
16
+ host: 'localhost',
17
+ username: 'ubuntu',
18
+ keys: ['id_rsa']
19
+ )
20
+ end
21
+
22
+ it 'responds to methods' do
23
+ cpu = described_class.new(host)
24
+ expect(cpu).to respond_to(:load_average)
25
+ expect(cpu).to respond_to(:load_average1)
26
+ expect(cpu).to respond_to(:load_average5)
27
+ expect(cpu).to respond_to(:load_average15)
28
+ expect(cpu).to respond_to(:sockets)
29
+ expect(cpu).to respond_to(:cores)
30
+ expect(cpu).to respond_to(:total)
31
+ expect(cpu).to respond_to(:count)
32
+ expect(cpu).to respond_to(:threads_per_core)
33
+ expect(cpu).to respond_to(:cores_per_socket)
34
+ expect(cpu).to respond_to(:numa_nodes)
35
+ expect(cpu).to respond_to(:vendor_id)
36
+ expect(cpu).to respond_to(:cpu_family)
37
+ expect(cpu).to respond_to(:model)
38
+ expect(cpu).to respond_to(:model_name)
39
+ expect(cpu).to respond_to(:byte_order)
40
+ expect(cpu).to respond_to(:address_sizes)
41
+ expect(cpu).to respond_to(:cpu_mhz)
42
+ expect(cpu).to respond_to(:cpu_max_mhz)
43
+ expect(cpu).to respond_to(:cpu_min_mhz)
44
+ expect(cpu).to respond_to(:hypervisor)
45
+ expect(cpu).to respond_to(:virtualization_type)
46
+ expect(cpu).to respond_to(:flags)
47
+ expect(cpu).to respond_to(:hyperthreading?)
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Kanrisuru::Remote::Env do
6
+ it 'responds to methods' do
7
+ env = described_class.new
8
+ expect(env).to respond_to(:to_h)
9
+ expect(env).to respond_to(:to_s)
10
+ expect(env).to respond_to(:clear)
11
+ expect(env).to respond_to(:count)
12
+ expect(env).to respond_to(:count)
13
+ expect(env).to respond_to(:delete)
14
+ expect(env).to respond_to(:[])
15
+ expect(env).to respond_to(:[]=)
16
+ end
17
+ end
File without changes
@@ -84,6 +84,10 @@ RSpec.describe Kanrisuru::Util do
84
84
  expect { Kanrisuru::Util::Bits.convert_bytes(100, :kilobytee, :kilobit) }.to raise_error(ArgumentError)
85
85
  end
86
86
 
87
+ it 'gets invalid signal type' do
88
+ expect { Kanrisuru::Util::Signal[{ 'Hello' => 'World' }] }.to raise_error(ArgumentError)
89
+ end
90
+
87
91
  it 'translates signal from string to numeric' do
88
92
  expect(Kanrisuru::Util::Signal['HUP']).to eq(1)
89
93
  expect(Kanrisuru::Util::Signal['INT']).to eq(2)
@@ -214,6 +218,10 @@ RSpec.describe Kanrisuru::Util do
214
218
  expect(Kanrisuru::Util::Signal[64]).to eq('RTMAX')
215
219
  end
216
220
 
221
+ it 'gets invalid dmi type' do
222
+ expect { Kanrisuru::Util::DmiType[{ 'Hello' => 'World' }] }.to raise_error(ArgumentError)
223
+ end
224
+
217
225
  it 'translates dmi types from string to integer' do
218
226
  expect(Kanrisuru::Util::DmiType['BIOS']).to eq(0)
219
227
  expect(Kanrisuru::Util::DmiType['System']).to eq(1)
@@ -308,6 +316,11 @@ RSpec.describe Kanrisuru::Util do
308
316
  expect(Kanrisuru::Util::DmiType[43]).to eq('TPM Device')
309
317
  end
310
318
 
319
+ it 'gets fs_mount options' do
320
+ expect(Kanrisuru::Util::FsMountOpts.get_device('common')[:async]).to eq('boolean')
321
+ expect(Kanrisuru::Util::FsMountOpts.get_device_opt(:ext4, :acl)).to eq('boolean')
322
+ end
323
+
311
324
  it 'converts power' do
312
325
  expect(Kanrisuru::Util::Bits.convert_power(:deca, :deca)).to eq(0)
313
326
  expect(Kanrisuru::Util::Bits.convert_power(:deca, :kilo)).to eq(-1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanrisuru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mammina
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-23 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.21'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov-cobertura
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: net-ping
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -108,7 +122,8 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '6.1'
111
- description: Manage remote servers over ssh with ruby.
125
+ description: Kanrisuru helps manage remote servers with objected oriented ruby. Results
126
+ come back as structured data, parsed, prepared and ready.
112
127
  email: ryan@avamia.com
113
128
  executables: []
114
129
  extensions: []
@@ -174,6 +189,7 @@ files:
174
189
  - lib/kanrisuru/util/signal.rb
175
190
  - lib/kanrisuru/version.rb
176
191
  - spec/functional/core/apt_spec.rb
192
+ - spec/functional/core/archive_spec.rb
177
193
  - spec/functional/core/find_spec.rb
178
194
  - spec/functional/core/path_spec.rb
179
195
  - spec/functional/core/socket_spec.rb
@@ -181,8 +197,9 @@ files:
181
197
  - spec/functional/core/stream_spec.rb
182
198
  - spec/functional/core/transfer_spec.rb
183
199
  - spec/functional/core/yum_spec.rb
184
- - spec/functional/os_package_spec.rb
185
200
  - spec/functional/remote/cluster_spec.rb
201
+ - spec/functional/remote/cpu_spec.rb
202
+ - spec/functional/remote/env_spec.rb
186
203
  - spec/helper/expect_helpers.rb
187
204
  - spec/helper/stub_network.rb
188
205
  - spec/helper/test_hosts.rb
@@ -204,6 +221,7 @@ files:
204
221
  - spec/integration/core/user_spec.rb
205
222
  - spec/integration/core/yum_spec.rb
206
223
  - spec/integration/core/zypper_spec.rb
224
+ - spec/integration/os_package_spec.rb
207
225
  - spec/integration/remote/cluster_spec.rb
208
226
  - spec/integration/remote/cpu_spec.rb
209
227
  - spec/integration/remote/env_spec.rb
@@ -213,6 +231,7 @@ files:
213
231
  - spec/integration/remote/os_spec.rb
214
232
  - spec/integration/remote/remote_file_spec.rb
215
233
  - spec/spec_helper.rb
234
+ - spec/unit/command_spec.rb
216
235
  - spec/unit/core/apt_spec.rb
217
236
  - spec/unit/core/archive_spec.rb
218
237
  - spec/unit/core/disk_spec.rb
@@ -229,9 +248,12 @@ files:
229
248
  - spec/unit/core/user_spec.rb
230
249
  - spec/unit/core/yum_spec.rb
231
250
  - spec/unit/core/zypper_spec.rb
232
- - spec/unit/fstab_spec.rb
233
251
  - spec/unit/kanrisuru_spec.rb
234
252
  - spec/unit/mode_spec.rb
253
+ - spec/unit/remote/cluster_spec.rb
254
+ - spec/unit/remote/cpu_spec.rb
255
+ - spec/unit/remote/env_spec.rb
256
+ - spec/unit/remote/fstab_spec.rb
235
257
  - spec/unit/template_spec.rb
236
258
  - spec/unit/util_spec.rb
237
259
  - spec/zz_reboot_spec.rb