serverspec 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,10 @@ module Serverspec
23
23
  def check_kernel_module_loaded(name)
24
24
  "lsmod | grep ^#{name}"
25
25
  end
26
+
27
+ def get_interface_speed_of(name)
28
+ "ethtool #{name} | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\\/s/,\"\\\\1\",\"\")}'"
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -3,7 +3,7 @@ module Serverspec
3
3
  module Type
4
4
  types = %w(
5
5
  base yumrepo service package port file cron command linux_kernel_parameter iptables host
6
- routing_table default_gateway selinux user group zfs ipnat ipfilter kernel_module
6
+ routing_table default_gateway selinux user group zfs ipnat ipfilter kernel_module interface
7
7
  )
8
8
 
9
9
  types.each {|type| require "serverspec/type/#{type}" }
@@ -0,0 +1,12 @@
1
+ module Serverspec
2
+ module Type
3
+ class Interface < Base
4
+ def speed
5
+ ret = backend.run_command(commands.get_interface_speed_of(@name))
6
+ val = ret[:stdout].strip
7
+ val = val.to_i if val.match(/^\d+$/)
8
+ val
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Serverspec
2
- VERSION = "0.6.11"
2
+ VERSION = "0.6.12"
3
3
  end
@@ -61,6 +61,8 @@ describe 'Serverspec commands of Debian family' do
61
61
  it_behaves_like 'support command check_access_by_user'
62
62
 
63
63
  it_behaves_like 'support command check_kernel_module_loaded', 'lp'
64
+
65
+ it_behaves_like 'support command get_interface_speed_of', 'eth0'
64
66
  end
65
67
 
66
68
  describe 'check_enabled' do
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Debian
4
+
5
+ describe 'Serverspec interface matchers of Debian family' do
6
+ it_behaves_like 'support interface matcher', 'eth0'
7
+ end
@@ -61,6 +61,8 @@ describe 'Serverspec commands of Gentoo family' do
61
61
  it_behaves_like 'support command check_access_by_user'
62
62
 
63
63
  it_behaves_like 'support command check_kernel_module_loaded', 'lp'
64
+
65
+ it_behaves_like 'support command get_interface_speed_of', 'eth0'
64
66
  end
65
67
 
66
68
  describe 'check_enabled' do
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::Gentoo
4
+
5
+ describe 'Serverspec interface matchers of Gentoo family' do
6
+ it_behaves_like 'support interface matcher', 'eth0'
7
+ end
@@ -59,6 +59,8 @@ describe 'Serverspec commands of Red Hat' do
59
59
  it_behaves_like 'support command get_mode'
60
60
 
61
61
  it_behaves_like 'support command check_kernel_module_loaded', 'lp'
62
+
63
+ it_behaves_like 'support command get_interface_speed_of', 'eth0'
62
64
  end
63
65
 
64
66
  describe 'check_enabled' do
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ include Serverspec::Helper::RedHat
4
+
5
+ describe 'Serverspec interface matchers of Red Hat family' do
6
+ it_behaves_like 'support interface matcher', 'eth0'
7
+ end
@@ -270,3 +270,8 @@ shared_examples_for 'support command check_kernel_module_loaded' do |name|
270
270
  subject { commands.check_kernel_module_loaded(name) }
271
271
  it { should eq "lsmod | grep ^#{name}" }
272
272
  end
273
+
274
+ shared_examples_for 'support command get_interface_speed_of' do |name|
275
+ subject { commands.get_interface_speed_of(name) }
276
+ it { should eq "ethtool eth0 | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\/s/,\"\\\\1\",\"\")}'" }
277
+ end
@@ -0,0 +1,17 @@
1
+ shared_examples_for 'support interface matcher' do |name|
2
+ describe 'interface' do
3
+ before :all do
4
+ RSpec.configure do |c|
5
+ c.stdout = "1000"
6
+ end
7
+ end
8
+
9
+ describe interface(name) do
10
+ its(:speed) { should eq 1000 }
11
+ end
12
+
13
+ describe interface('invalid-interface') do
14
+ its(:speed) { should_not eq 100 }
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serverspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-26 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: net-ssh
@@ -192,6 +192,7 @@ files:
192
192
  - lib/serverspec/type/file.rb
193
193
  - lib/serverspec/type/group.rb
194
194
  - lib/serverspec/type/host.rb
195
+ - lib/serverspec/type/interface.rb
195
196
  - lib/serverspec/type/ipfilter.rb
196
197
  - lib/serverspec/type/ipnat.rb
197
198
  - lib/serverspec/type/iptables.rb
@@ -228,6 +229,7 @@ files:
228
229
  - spec/debian/file_spec.rb
229
230
  - spec/debian/group_spec.rb
230
231
  - spec/debian/host_spec.rb
232
+ - spec/debian/interface_spec.rb
231
233
  - spec/debian/iptables_spec.rb
232
234
  - spec/debian/kernel_module_spec.rb
233
235
  - spec/debian/linux_kernel_parameter_spec.rb
@@ -244,6 +246,7 @@ files:
244
246
  - spec/gentoo/file_spec.rb
245
247
  - spec/gentoo/group_spec.rb
246
248
  - spec/gentoo/host_spec.rb
249
+ - spec/gentoo/interface_spec.rb
247
250
  - spec/gentoo/iptables_spec.rb
248
251
  - spec/gentoo/kernel_module_spec.rb
249
252
  - spec/gentoo/linux_kernel_parameter_spec.rb
@@ -260,6 +263,7 @@ files:
260
263
  - spec/redhat/file_spec.rb
261
264
  - spec/redhat/group_spec.rb
262
265
  - spec/redhat/host_spec.rb
266
+ - spec/redhat/interface_spec.rb
263
267
  - spec/redhat/iptables_spec.rb
264
268
  - spec/redhat/kernel_module_spec.rb
265
269
  - spec/redhat/linux_kernel_parameter_spec.rb
@@ -294,6 +298,7 @@ files:
294
298
  - spec/support/shared_file_examples.rb
295
299
  - spec/support/shared_group_examples.rb
296
300
  - spec/support/shared_host_examples.rb
301
+ - spec/support/shared_interface_examples.rb
297
302
  - spec/support/shared_iptables_examples.rb
298
303
  - spec/support/shared_kernel_module_examples.rb
299
304
  - spec/support/shared_linux_kernel_parameter_examples.rb
@@ -324,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
324
329
  version: '0'
325
330
  requirements: []
326
331
  rubyforge_project:
327
- rubygems_version: 1.8.25
332
+ rubygems_version: 1.8.23
328
333
  signing_key:
329
334
  specification_version: 3
330
335
  summary: RSpec tests for your servers configured by Puppet, Chef or anything else
@@ -350,6 +355,7 @@ test_files:
350
355
  - spec/debian/file_spec.rb
351
356
  - spec/debian/group_spec.rb
352
357
  - spec/debian/host_spec.rb
358
+ - spec/debian/interface_spec.rb
353
359
  - spec/debian/iptables_spec.rb
354
360
  - spec/debian/kernel_module_spec.rb
355
361
  - spec/debian/linux_kernel_parameter_spec.rb
@@ -366,6 +372,7 @@ test_files:
366
372
  - spec/gentoo/file_spec.rb
367
373
  - spec/gentoo/group_spec.rb
368
374
  - spec/gentoo/host_spec.rb
375
+ - spec/gentoo/interface_spec.rb
369
376
  - spec/gentoo/iptables_spec.rb
370
377
  - spec/gentoo/kernel_module_spec.rb
371
378
  - spec/gentoo/linux_kernel_parameter_spec.rb
@@ -382,6 +389,7 @@ test_files:
382
389
  - spec/redhat/file_spec.rb
383
390
  - spec/redhat/group_spec.rb
384
391
  - spec/redhat/host_spec.rb
392
+ - spec/redhat/interface_spec.rb
385
393
  - spec/redhat/iptables_spec.rb
386
394
  - spec/redhat/kernel_module_spec.rb
387
395
  - spec/redhat/linux_kernel_parameter_spec.rb
@@ -416,6 +424,7 @@ test_files:
416
424
  - spec/support/shared_file_examples.rb
417
425
  - spec/support/shared_group_examples.rb
418
426
  - spec/support/shared_host_examples.rb
427
+ - spec/support/shared_interface_examples.rb
419
428
  - spec/support/shared_iptables_examples.rb
420
429
  - spec/support/shared_kernel_module_examples.rb
421
430
  - spec/support/shared_linux_kernel_parameter_examples.rb