omf_rc 6.0.0.pre.5 → 6.0.0.pre.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +0 -6
- data/bin/omf_rc +2 -2
- data/lib/omf_rc/resource_factory.rb +10 -4
- data/lib/omf_rc/resource_proxy/abstract_resource.rb +120 -79
- data/lib/omf_rc/resource_proxy/generic_application.rb +471 -0
- data/lib/omf_rc/resource_proxy/net.rb +7 -0
- data/lib/omf_rc/resource_proxy/node.rb +33 -7
- data/lib/omf_rc/resource_proxy/openflow_slice.rb +79 -0
- data/lib/omf_rc/resource_proxy/openflow_slice_factory.rb +71 -0
- data/lib/omf_rc/resource_proxy/wlan.rb +20 -0
- data/lib/omf_rc/resource_proxy_dsl.rb +142 -8
- data/lib/omf_rc/util/common_tools.rb +61 -0
- data/lib/omf_rc/util/hostapd.rb +52 -0
- data/lib/omf_rc/util/ip.rb +28 -0
- data/lib/omf_rc/util/iw.rb +119 -6
- data/lib/omf_rc/util/mock.rb +2 -1
- data/lib/omf_rc/util/openflow_tools.rb +103 -0
- data/lib/omf_rc/util/platform_tools.rb +164 -0
- data/lib/omf_rc/util/wpa.rb +42 -0
- data/lib/omf_rc/version.rb +1 -1
- data/omf_rc.gemspec +3 -1
- data/test/fixture/ip/addr_show +5 -0
- data/test/fixture/iw/info +4 -0
- data/test/fixture/sys/class/ieee80211/phy0/device/uevent +6 -0
- data/test/fixture/sys/class/ieee80211/phy0/uevent +0 -0
- data/test/fixture/sys/class/net/eth0/device/uevent +6 -0
- data/test/fixture/sys/class/net/eth0/uevent +2 -0
- data/test/fixture/sys/class/net/wlan0/device/uevent +6 -0
- data/test/fixture/sys/class/net/wlan0/uevent +3 -0
- data/test/omf_rc/message_process_error_spec.rb +11 -0
- data/test/omf_rc/resource_factory_spec.rb +8 -1
- data/test/omf_rc/resource_proxy/abstract_resource_spec.rb +57 -1
- data/test/omf_rc/resource_proxy/generic_application_spec.rb +347 -0
- data/test/omf_rc/resource_proxy/mock_spec.rb +15 -0
- data/test/omf_rc/resource_proxy/node_spec.rb +32 -1
- data/test/omf_rc/resource_proxy_dsl_spec.rb +81 -10
- data/test/omf_rc/util/common_tools_spec.rb +30 -0
- data/test/omf_rc/util/ip_spec.rb +51 -0
- data/test/omf_rc/util/iw_spec.rb +136 -25
- data/test/omf_rc/util/mock_spec.rb +26 -0
- data/test/omf_rc/util/mod_spec.rb +8 -11
- data/test/test_helper.rb +11 -0
- metadata +62 -6
- data/lib/omf_rc/resource_proxy/wifi.rb +0 -8
- data/test/mock_helper.rb +0 -15
data/test/omf_rc/util/iw_spec.rb
CHANGED
@@ -1,38 +1,149 @@
|
|
1
|
+
require 'minitest/mock'
|
1
2
|
require 'test_helper'
|
2
|
-
require '
|
3
|
+
require 'cocaine'
|
3
4
|
|
4
|
-
|
5
|
+
@command = MiniTest::Mock.new
|
5
6
|
|
6
|
-
|
7
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
8
|
+
@command.expect(:run, fixture("iw/help"))
|
9
|
+
require 'omf_rc/util/iw'
|
7
10
|
|
8
|
-
describe OmfRc::Util::Iw do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
describe OmfRc::Util::Iw do
|
12
|
+
describe "when included in the resource instance" do
|
13
|
+
before do
|
14
|
+
@command = MiniTest::Mock.new
|
15
|
+
|
16
|
+
module OmfRc::ResourceProxy::IwTest
|
17
|
+
include OmfRc::ResourceProxyDSL
|
18
|
+
register_proxy :iw_test
|
19
|
+
utility :iw
|
20
|
+
end
|
21
|
+
|
22
|
+
@wlan00 = OmfRc::ResourceFactory.new(:iw_test, hrn: 'wlan00', property: { phy: 'phy00' })
|
15
23
|
end
|
16
|
-
end
|
17
24
|
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
it "must provide features defined in proxy" do
|
26
|
+
%w(request_link configure_name configure_channel configure_bitrates).each do |m|
|
27
|
+
OmfRc::Util::Iw.method_defined?(m).must_equal true
|
28
|
+
end
|
29
|
+
end
|
21
30
|
|
22
|
-
|
23
|
-
|
24
|
-
|
31
|
+
it "could request properties of the wifi interface" do
|
32
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
33
|
+
@command.expect(:run, fixture("iw/link"))
|
34
|
+
@wlan00.request_link.keys.must_include "ssid"
|
35
|
+
@command.verify
|
36
|
+
end
|
25
37
|
end
|
26
|
-
end
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
39
|
+
it "could request info of the wifi interface" do
|
40
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
41
|
+
@command.expect(:run, fixture("iw/info"))
|
42
|
+
@wlan00.request_info.keys.must_equal ["ifindex", "type", "wiphy"]
|
43
|
+
@command.verify
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "could configure the device's prorperty" do
|
48
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
49
|
+
@command.expect(:run, true)
|
50
|
+
@wlan00.configure_power_save(true)
|
51
|
+
@command.verify
|
52
|
+
end
|
53
|
+
end
|
32
54
|
|
33
|
-
|
34
|
-
|
35
|
-
|
55
|
+
it "must could initialise wpa config/pid file path" do
|
56
|
+
@wlan00.init_ap_conf_pid
|
57
|
+
@wlan00.request_ap_conf.must_equal "/tmp/hostapd.wlan00.conf"
|
58
|
+
@wlan00.request_ap_pid.must_equal "/tmp/hostapd.wlan00.pid"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "must could initialise wpa config/pid file path" do
|
62
|
+
@wlan00.init_wpa_conf_pid
|
63
|
+
@wlan00.request_wpa_conf.must_equal "/tmp/wpa.wlan00.conf"
|
64
|
+
@wlan00.request_wpa_pid.must_equal "/tmp/wpa.wlan00.pid"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "could delete current interface" do
|
68
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
69
|
+
@command.expect(:run, true)
|
70
|
+
@wlan00.delele_interface
|
71
|
+
@command.verify
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it "could add a new interface" do
|
76
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
77
|
+
@command.expect(:run, true)
|
78
|
+
@wlan00.add_interface(:managed)
|
79
|
+
@command.verify
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it "must be able to validate iw parameters when setting up mode" do
|
84
|
+
lambda { @wlan00.configure_mode(mode: 'master') }.must_raise ArgumentError
|
85
|
+
lambda { @wlan00.configure_mode(mode: 'bob') }.must_raise ArgumentError
|
86
|
+
lambda { @wlan00.configure_mode(mode: 'master', hw_mode: 'x') }.must_raise ArgumentError
|
87
|
+
lambda { @wlan00.configure_mode(hw_mode: 'x') }.must_raise ArgumentError
|
88
|
+
end
|
89
|
+
|
90
|
+
it "must be able to configure as master mode" do
|
91
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
92
|
+
3.times { @command.expect(:run, true) }
|
93
|
+
|
94
|
+
@wlan00.configure_mode(mode: 'master', channel: 1, essid: 'bob', hw_mode: 'b')
|
95
|
+
File.open("/tmp/hostapd.wlan00.conf") do |f|
|
96
|
+
f.read.must_match "driver=nl80211\ninterface=wlan00\nssid=bob\nchannel=1\nhw_mode=b\n"
|
97
|
+
end
|
98
|
+
|
99
|
+
3.times { @command.expect(:run, true) }
|
100
|
+
|
101
|
+
@wlan00.configure_mode(mode: 'master', channel: 1, essid: 'bob', hw_mode: 'n')
|
102
|
+
File.open("/tmp/hostapd.wlan00.conf") do |f|
|
103
|
+
f.read.must_match "driver=nl80211\ninterface=wlan00\nssid=bob\nchannel=1\nhw_mode=g\nwmm_enabled=1\nieee80211n=1\nht_capab=\[HT20\-\]\n"
|
104
|
+
end
|
105
|
+
|
106
|
+
3.times { @command.expect(:run, true) }
|
107
|
+
|
108
|
+
@wlan00.configure_mode(mode: 'master', channel: 16, essid: 'bob', hw_mode: 'n')
|
109
|
+
File.open("/tmp/hostapd.wlan00.conf") do |f|
|
110
|
+
f.read.must_match "driver=nl80211\ninterface=wlan00\nssid=bob\nchannel=16\nhw_mode=a\nwmm_enabled=1\nieee80211n=1\nht_capab=\[HT20\-\]\n"
|
111
|
+
end
|
112
|
+
|
113
|
+
@command.verify
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
it "must be able to configure as managed mode" do
|
118
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
119
|
+
3.times { @command.expect(:run, true) }
|
120
|
+
|
121
|
+
@wlan00.configure_mode(mode: 'managed', essid: 'bob')
|
122
|
+
File.open("/tmp/wpa.wlan00.conf") do |f|
|
123
|
+
f.read.must_match "network={\n ssid=\"bob\"\n scan_ssid=1\n key_mgmt=NONE\n}"
|
124
|
+
end
|
125
|
+
|
126
|
+
@command.verify
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
it "must be able to configure as adhoc/ibss mode" do
|
131
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
132
|
+
4.times { @command.expect(:run, true) }
|
133
|
+
|
134
|
+
@wlan00.configure_mode(mode: 'adhoc', essid: 'bob', frequency: 2412)
|
135
|
+
@command.verify
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
it "must be able to configure as monitor mode" do
|
140
|
+
Cocaine::CommandLine.stub(:new, @command) do
|
141
|
+
3.times { @command.expect(:run, true) }
|
142
|
+
|
143
|
+
@wlan00.configure_mode(mode: 'monitor')
|
144
|
+
@command.verify
|
145
|
+
end
|
146
|
+
end
|
36
147
|
end
|
37
148
|
end
|
38
149
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'omf_rc/util/mock'
|
3
|
+
|
4
|
+
describe OmfRc::Util::Mock do
|
5
|
+
describe "when included in the resource proxy" do
|
6
|
+
before do
|
7
|
+
module OmfRc::ResourceProxy::MockTest
|
8
|
+
include OmfRc::ResourceProxyDSL
|
9
|
+
register_proxy :mock_test
|
10
|
+
utility :mock
|
11
|
+
end
|
12
|
+
@mock = OmfRc::ResourceFactory.new(:mock_test)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "must have these demo methods available" do
|
16
|
+
@mock.request_nothing.must_equal @mock.uid
|
17
|
+
@mock.configure_nothing
|
18
|
+
@mock.configure_hrn "bob"
|
19
|
+
@mock.request_hrn.must_equal "bob"
|
20
|
+
@mock.request_resource_proxy_list.must_equal OmfRc::ResourceFactory.proxy_list
|
21
|
+
OmfCommon::Command.stub :execute, "bob_os" do
|
22
|
+
@mock.request_kernel_version.must_equal "bob_os"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'mock_helper'
|
3
2
|
require 'omf_rc/util/mod'
|
4
3
|
|
5
4
|
describe OmfRc::Util::Mod do
|
6
|
-
describe "when included in the resource
|
5
|
+
describe "when included in the resource proxy" do
|
7
6
|
before do
|
8
7
|
module OmfRc::ResourceProxy::ModTest
|
9
8
|
include OmfRc::ResourceProxyDSL
|
@@ -12,19 +11,17 @@ describe OmfRc::Util::Mod do
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
after do
|
16
|
-
mock_verify_execute
|
17
|
-
end
|
18
|
-
|
19
14
|
it "will find out a list of modules" do
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
OmfCommon::Command.stub :execute, fixture("lsmod") do
|
16
|
+
OmfRc::ResourceFactory.new(:mod_test).request_modules.must_include "kvm"
|
17
|
+
OmfRc::ResourceFactory.new(:mod_test).request_modules.wont_include "Module"
|
18
|
+
end
|
23
19
|
end
|
24
20
|
|
25
21
|
it "could load a module" do
|
26
|
-
|
27
|
-
|
22
|
+
OmfCommon::Command.stub :execute, true do
|
23
|
+
OmfRc::ResourceFactory.new(:mod_test).configure_load_module('magic_module').must_equal true
|
24
|
+
end
|
28
25
|
end
|
29
26
|
end
|
30
27
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start { add_filter "/test" }
|
3
|
+
|
1
4
|
gem 'minitest'
|
2
5
|
require 'minitest/autorun'
|
3
6
|
require 'minitest/pride'
|
@@ -5,5 +8,13 @@ require 'minitest/pride'
|
|
5
8
|
require 'omf_rc'
|
6
9
|
require 'omf_rc/resource_factory'
|
7
10
|
|
11
|
+
# Default fixture directory
|
12
|
+
FIXTURE_DIR = "#{File.dirname(__FILE__)}/fixture"
|
13
|
+
|
8
14
|
# Shut up all the loggers
|
9
15
|
Logging.logger.root.clear_appenders
|
16
|
+
|
17
|
+
# Reading fixture file
|
18
|
+
def fixture(name)
|
19
|
+
File.read("#{FIXTURE_DIR}/#{name.to_s}")
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_rc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.pre.
|
4
|
+
version: 6.0.0.pre.6
|
5
5
|
prerelease: 6
|
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: 2012-
|
12
|
+
date: 2012-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2
|
21
|
+
version: '3.2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2
|
29
|
+
version: '3.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: em-minitest-spec
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.1.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: simplecov
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: omf_common
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +75,22 @@ dependencies:
|
|
59
75
|
- - ~>
|
60
76
|
- !ruby/object:Gem::Version
|
61
77
|
version: 6.0.0.pre
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: cocaine
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.3.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.3.0
|
62
94
|
description: Resource controller of OMF, a generic framework for controlling and managing
|
63
95
|
networking testbeds.
|
64
96
|
email:
|
@@ -78,26 +110,49 @@ files:
|
|
78
110
|
- lib/omf_rc/message_process_error.rb
|
79
111
|
- lib/omf_rc/resource_factory.rb
|
80
112
|
- lib/omf_rc/resource_proxy/abstract_resource.rb
|
113
|
+
- lib/omf_rc/resource_proxy/generic_application.rb
|
81
114
|
- lib/omf_rc/resource_proxy/mock.rb
|
115
|
+
- lib/omf_rc/resource_proxy/net.rb
|
82
116
|
- lib/omf_rc/resource_proxy/node.rb
|
83
|
-
- lib/omf_rc/resource_proxy/
|
117
|
+
- lib/omf_rc/resource_proxy/openflow_slice.rb
|
118
|
+
- lib/omf_rc/resource_proxy/openflow_slice_factory.rb
|
119
|
+
- lib/omf_rc/resource_proxy/wlan.rb
|
84
120
|
- lib/omf_rc/resource_proxy_dsl.rb
|
121
|
+
- lib/omf_rc/util/common_tools.rb
|
122
|
+
- lib/omf_rc/util/hostapd.rb
|
123
|
+
- lib/omf_rc/util/ip.rb
|
85
124
|
- lib/omf_rc/util/iw.rb
|
86
125
|
- lib/omf_rc/util/mock.rb
|
87
126
|
- lib/omf_rc/util/mod.rb
|
127
|
+
- lib/omf_rc/util/openflow_tools.rb
|
88
128
|
- lib/omf_rc/util/package.rb
|
129
|
+
- lib/omf_rc/util/platform_tools.rb
|
130
|
+
- lib/omf_rc/util/wpa.rb
|
89
131
|
- lib/omf_rc/version.rb
|
90
132
|
- omf_rc.gemspec
|
133
|
+
- test/fixture/ip/addr_show
|
91
134
|
- test/fixture/iw/help
|
135
|
+
- test/fixture/iw/info
|
92
136
|
- test/fixture/iw/link
|
93
137
|
- test/fixture/lsmod
|
94
|
-
- test/
|
138
|
+
- test/fixture/sys/class/ieee80211/phy0/device/uevent
|
139
|
+
- test/fixture/sys/class/ieee80211/phy0/uevent
|
140
|
+
- test/fixture/sys/class/net/eth0/device/uevent
|
141
|
+
- test/fixture/sys/class/net/eth0/uevent
|
142
|
+
- test/fixture/sys/class/net/wlan0/device/uevent
|
143
|
+
- test/fixture/sys/class/net/wlan0/uevent
|
95
144
|
- test/omf_rc/deferred_process_spec.rb
|
145
|
+
- test/omf_rc/message_process_error_spec.rb
|
96
146
|
- test/omf_rc/resource_factory_spec.rb
|
97
147
|
- test/omf_rc/resource_proxy/abstract_resource_spec.rb
|
148
|
+
- test/omf_rc/resource_proxy/generic_application_spec.rb
|
149
|
+
- test/omf_rc/resource_proxy/mock_spec.rb
|
98
150
|
- test/omf_rc/resource_proxy/node_spec.rb
|
99
151
|
- test/omf_rc/resource_proxy_dsl_spec.rb
|
152
|
+
- test/omf_rc/util/common_tools_spec.rb
|
153
|
+
- test/omf_rc/util/ip_spec.rb
|
100
154
|
- test/omf_rc/util/iw_spec.rb
|
155
|
+
- test/omf_rc/util/mock_spec.rb
|
101
156
|
- test/omf_rc/util/mod_spec.rb
|
102
157
|
- test/test_helper.rb
|
103
158
|
homepage: https://www.mytestbed.net
|
@@ -125,3 +180,4 @@ signing_key:
|
|
125
180
|
specification_version: 3
|
126
181
|
summary: OMF resource controller
|
127
182
|
test_files: []
|
183
|
+
has_rdoc:
|
data/test/mock_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
FIXTURE_DIR = "#{File.dirname(__FILE__)}/fixture"
|
2
|
-
|
3
|
-
OmfCommon::Command = MiniTest::Mock.new
|
4
|
-
|
5
|
-
def mock_execute(result, command_pattern)
|
6
|
-
OmfCommon::Command.expect :execute, result, [command_pattern]
|
7
|
-
end
|
8
|
-
|
9
|
-
def mock_verify_execute
|
10
|
-
OmfCommon::Command.verify
|
11
|
-
end
|
12
|
-
|
13
|
-
def fixture(name)
|
14
|
-
File.read("#{FIXTURE_DIR}/#{name.to_s}")
|
15
|
-
end
|