omf_ec 6.0.0.pre.4 → 6.0.0.pre.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/omf_ec +75 -57
- data/example/engine_oedl.rb +20 -20
- data/example/engine_test.rb +51 -73
- data/example/test_exp/test00.rb +25 -5
- data/example/test_exp/test01.rb +4 -5
- data/example/test_exp/test02.rb +2 -5
- data/example/test_exp/test03.rb +15 -28
- data/lib/omf_ec/app_definition.rb +3 -3
- data/lib/omf_ec/backward/default_events.rb +13 -8
- data/lib/omf_ec/backward/dsl.rb +4 -36
- data/lib/omf_ec/backward/exp/testbed.rb +7 -7
- data/lib/omf_ec/backward/group.rb +23 -9
- data/lib/omf_ec/context/app_context.rb +40 -9
- data/lib/omf_ec/context/group_context.rb +18 -47
- data/lib/omf_ec/context/net_context.rb +3 -3
- data/lib/omf_ec/dsl.rb +55 -40
- data/lib/omf_ec/experiment.rb +112 -20
- data/lib/omf_ec/experiment_property.rb +222 -0
- data/lib/omf_ec/group.rb +54 -104
- data/lib/omf_ec/version.rb +1 -1
- data/lib/omf_ec.rb +59 -7
- data/omf_ec.gemspec +4 -2
- data/test/omf_ec/dsl_spec.rb +53 -0
- data/test/omf_ec/experiment_property_spec.rb +81 -0
- data/test/omf_ec/experiment_spec.rb +41 -0
- data/test/omf_ec/group_spec.rb +45 -2
- metadata +35 -19
- data/example/test_exp/test04.rb +0 -105
- data/example/test_exp/test05.rb +0 -87
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'omf_ec/experiment'
|
3
|
+
|
4
|
+
describe OmfEc::Experiment do
|
5
|
+
before do
|
6
|
+
@experiment = OmfEc::Experiment.instance
|
7
|
+
end
|
8
|
+
|
9
|
+
it "must return id" do
|
10
|
+
@experiment.id.wont_be_nil
|
11
|
+
|
12
|
+
@experiment.name = 'bob'
|
13
|
+
@experiment.id.must_match /bob-/
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must be able to add event" do
|
17
|
+
trigger = proc { 1 }
|
18
|
+
@experiment.add_event('bob', trigger)
|
19
|
+
@experiment.event('bob')[:name].must_equal "bob"
|
20
|
+
@experiment.event('bob')[:trigger].call.must_equal 1
|
21
|
+
end
|
22
|
+
|
23
|
+
it "must be able to add sub group" do
|
24
|
+
@experiment.add_sub_group('bob')
|
25
|
+
@experiment.sub_group('bob').must_equal "bob"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "must be able to add group" do
|
29
|
+
proc { @experiment.add_group('bob') }.must_raise ArgumentError
|
30
|
+
OmfEc.stub :subscribe_and_monitor, true do
|
31
|
+
@experiment.add_group(OmfEc::Group.new('bob'))
|
32
|
+
@experiment.group('bob').must_be_kind_of OmfEc::Group
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "must be able to add resource to state" do
|
37
|
+
@experiment.add_or_update_resource_state('bob', type: :test)
|
38
|
+
@experiment.resource_state('bob')[:uid].must_equal 'bob'
|
39
|
+
@experiment.resource_state('bob')[:type].must_equal :test
|
40
|
+
end
|
41
|
+
end
|
data/test/omf_ec/group_spec.rb
CHANGED
@@ -4,11 +4,54 @@ require 'omf_ec/group'
|
|
4
4
|
describe OmfEc::Group do
|
5
5
|
describe "when initialised" do
|
6
6
|
it "must be generate unique id if :unique option is on" do
|
7
|
-
OmfEc
|
7
|
+
OmfEc.stub :subscribe_and_monitor, true do
|
8
|
+
OmfEc::Group.new('bob').id.wont_equal 'bob'
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
it "must use name as id if :unique option is off" do
|
11
|
-
OmfEc
|
13
|
+
OmfEc.stub :subscribe_and_monitor, true do
|
14
|
+
OmfEc::Group.new('bob', unique: false).id.must_equal 'bob'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "when used to represent group resource" do
|
20
|
+
before do
|
21
|
+
@comm = MiniTest::Mock.new
|
22
|
+
OmfEc.stub :subscribe_and_monitor, true do
|
23
|
+
@group = OmfEc::Group.new('bob', unique: false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "must init default context related arrasy" do
|
28
|
+
@group.net_ifs.must_equal []
|
29
|
+
@group.members.must_equal []
|
30
|
+
@group.app_contexts.must_equal []
|
31
|
+
end
|
32
|
+
|
33
|
+
it "must be capable of adding existing resources to group" do
|
34
|
+
skip
|
35
|
+
OmfCommon.stub :comm, @comm do
|
36
|
+
@comm.expect(:subscribe, true, [Array])
|
37
|
+
@group.add_resource(['r1', 'r2'])
|
38
|
+
@comm.verify
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must be capable of creating new resources and add them to group" do
|
43
|
+
skip
|
44
|
+
OmfCommon.stub :comm, @comm do
|
45
|
+
@comm.expect(:subscribe, true, [String])
|
46
|
+
@comm.expect(:create_topic, true, [String])
|
47
|
+
@group.create_resource('r1', { type: :test, p1: 'bob' })
|
48
|
+
@comm.verify
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must create new group context when calling resources" do
|
53
|
+
@group.resources.must_be_kind_of OmfEc::Context::GroupContext
|
12
54
|
end
|
13
55
|
end
|
14
56
|
end
|
57
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_ec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.0.pre.
|
4
|
+
version: 6.0.0.pre.5
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: omf_common
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,18 +37,28 @@ dependencies:
|
|
32
37
|
version: 6.0.0.pre
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 6.0.0.pre
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: gli
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
42
52
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
53
|
+
version: 2.5.3
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.5.3
|
47
62
|
description: Experiment controller of OMF, a generic framework for controlling and
|
48
63
|
managing networking testbeds.
|
49
64
|
email:
|
@@ -64,8 +79,6 @@ files:
|
|
64
79
|
- example/test_exp/test01.rb
|
65
80
|
- example/test_exp/test02.rb
|
66
81
|
- example/test_exp/test03.rb
|
67
|
-
- example/test_exp/test04.rb
|
68
|
-
- example/test_exp/test05.rb
|
69
82
|
- example/test_exp/test06.rb
|
70
83
|
- example/test_exp/test07.rb
|
71
84
|
- lib/omf_ec.rb
|
@@ -83,14 +96,19 @@ files:
|
|
83
96
|
- lib/omf_ec/context/net_context.rb
|
84
97
|
- lib/omf_ec/dsl.rb
|
85
98
|
- lib/omf_ec/experiment.rb
|
99
|
+
- lib/omf_ec/experiment_property.rb
|
86
100
|
- lib/omf_ec/group.rb
|
87
101
|
- lib/omf_ec/version.rb
|
88
102
|
- omf_ec.gemspec
|
89
103
|
- test/omf_ec/context_spec.rb
|
104
|
+
- test/omf_ec/dsl_spec.rb
|
105
|
+
- test/omf_ec/experiment_property_spec.rb
|
106
|
+
- test/omf_ec/experiment_spec.rb
|
90
107
|
- test/omf_ec/group_spec.rb
|
91
108
|
- test/test_helper.rb
|
92
|
-
homepage:
|
93
|
-
licenses:
|
109
|
+
homepage: http://omf.mytestbed.net
|
110
|
+
licenses:
|
111
|
+
- MIT
|
94
112
|
post_install_message:
|
95
113
|
rdoc_options: []
|
96
114
|
require_paths:
|
@@ -100,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
118
|
requirements:
|
101
119
|
- - ! '>='
|
102
120
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
121
|
+
version: 1.9.3
|
104
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
123
|
none: false
|
106
124
|
requirements:
|
@@ -109,11 +127,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
127
|
version: 1.3.1
|
110
128
|
requirements: []
|
111
129
|
rubyforge_project: omf_ec
|
112
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.25
|
113
131
|
signing_key:
|
114
132
|
specification_version: 3
|
115
133
|
summary: OMF experiment controller
|
116
|
-
test_files:
|
117
|
-
|
118
|
-
- test/omf_ec/group_spec.rb
|
119
|
-
- test/test_helper.rb
|
134
|
+
test_files: []
|
135
|
+
has_rdoc:
|
data/example/test_exp/test04.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Test 4
|
3
|
-
#
|
4
|
-
# Testing 2 nodes in 2 groups running already installed OTG/OTR
|
5
|
-
# Also testing dynamic experiment properties
|
6
|
-
#
|
7
|
-
|
8
|
-
PKTSIZE = 256
|
9
|
-
|
10
|
-
defProperty('res1', "unconfigured-node-1", "ID of a node")
|
11
|
-
defProperty('res2', "unconfigured-node-2", "ID of a node")
|
12
|
-
defProperty('bitrate', 2048, "Bitrate (bit/s) from the sender node")
|
13
|
-
defProperty('packetsize', PKTSIZE, "Packet size (byte) from the sender node")
|
14
|
-
|
15
|
-
defGroup('Sender', property.res1) {|node|
|
16
|
-
node.addApplication("test:app:otg2") {|app|
|
17
|
-
app.setProperty('udp:local_host', '192.168.0.2')
|
18
|
-
app.setProperty('udp:dst_host', '192.168.0.3')
|
19
|
-
app.setProperty('udp:dst_port', 3000)
|
20
|
-
app.setProperty('cbr:rate', property.bitrate * 2)
|
21
|
-
app.setProperty('cbr:size', property.packetsize)
|
22
|
-
app.measure('udp_out', :interval => 3)
|
23
|
-
}
|
24
|
-
node.net.w0.mode = "adhoc"
|
25
|
-
node.net.w0.type = 'g'
|
26
|
-
node.net.w0.channel = '6'
|
27
|
-
node.net.w0.essid = "testing"
|
28
|
-
node.net.w0.ip = "192.168.0.2"
|
29
|
-
}
|
30
|
-
|
31
|
-
defGroup('Receiver', property.res2) {|node|
|
32
|
-
node.addApplication("test:app:otr2") {|app|
|
33
|
-
app.setProperty('udp:local_host', '192.168.0.3')
|
34
|
-
app.setProperty('udp:local_port', 3000)
|
35
|
-
app.measure('udp_in', :samples => 3)
|
36
|
-
}
|
37
|
-
node.net.w0.mode = "adhoc"
|
38
|
-
node.net.w0.type = 'g'
|
39
|
-
node.net.w0.channel = '6'
|
40
|
-
node.net.w0.essid = "testing"
|
41
|
-
node.net.w0.ip = "192.168.0.3"
|
42
|
-
}
|
43
|
-
|
44
|
-
onEvent(:ALL_UP_AND_INSTALLED) do |event|
|
45
|
-
wait 10
|
46
|
-
allGroups.startApplications
|
47
|
-
wait 15
|
48
|
-
info "------------------------------"
|
49
|
-
info "TEST - Dynamic property change"
|
50
|
-
info "TEST - Value before: #{property.packetsize}"
|
51
|
-
property.packetsize = 512
|
52
|
-
info "TEST - Value after: #{property.packetsize}"
|
53
|
-
wait 15
|
54
|
-
allGroups.stopApplications
|
55
|
-
Experiment.done
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
#
|
61
|
-
# Checking the Execution
|
62
|
-
# Here you do whatever is required to check that the above experiment went well
|
63
|
-
# Then return true if you decided that it did, or false otherwise
|
64
|
-
#
|
65
|
-
# Experiment log file is at: property.logpath
|
66
|
-
# Also you may want to look at system:exp:testlib
|
67
|
-
#
|
68
|
-
|
69
|
-
def check_outcome
|
70
|
-
|
71
|
-
# Test 04 is successfull if all of the following are true:
|
72
|
-
# 1) each resource reports that all its wireless property were configured OK
|
73
|
-
# 2) the applications (OTG,OTR,execs) started and finished properly
|
74
|
-
# file has a message from the AgentCommands module containing "DONE.OK"
|
75
|
-
# 3) a SQ3 database is produced with some entries in the OTG and OTR tables
|
76
|
-
# 4) the receiver table of the database has the packetsize value increasing
|
77
|
-
logfile = "#{property.logpath}/#{Experiment.ID}.log"
|
78
|
-
lines = IO.readlines("#{logfile}")
|
79
|
-
# 1)
|
80
|
-
match1 = lines.grep(/CONFIGURED\.OK/)
|
81
|
-
r1 = (match1.length >= 10) ? true : false
|
82
|
-
# 2)
|
83
|
-
match1 = lines.grep(/APP_EVENT\ STARTED/)
|
84
|
-
r2 = (match1.length == 2) ? true : false
|
85
|
-
match1 = lines.grep(/APP_EVENT DONE\.OK/)
|
86
|
-
match2 = match1.grep(/AgentCommands/)
|
87
|
-
r3 = (match2.length == 2) ? true : false
|
88
|
-
# 3)
|
89
|
-
cnt1 = cnt2 = 0
|
90
|
-
ms('udp_out').project(:oml_ts_server).each { |r| cnt1 =+1 }
|
91
|
-
ms('udp_in').project(:oml_ts_server).each { |r| cnt2 =+1 }
|
92
|
-
r4 = (cnt1 >= 1) ? true : false
|
93
|
-
r5 = (cnt2 >= 1) ? true : false
|
94
|
-
# 4)
|
95
|
-
max = PKTSIZE
|
96
|
-
ms('udp_in').project(:pkt_length_max).each do |r|
|
97
|
-
value = r.tuple
|
98
|
-
max = value[0]
|
99
|
-
end
|
100
|
-
r6 = (max > PKTSIZE) ? true : false
|
101
|
-
|
102
|
-
puts "Check Outcome [r1:#{r1} - r2:#{r2} - r3:#{r3} - r4:#{r4} - r5:#{r5} - r6:#{r6}]"
|
103
|
-
return true if r1 && r2 && r3 && r4 && r5 && r6
|
104
|
-
return false
|
105
|
-
end
|
data/example/test_exp/test05.rb
DELETED
@@ -1,87 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Test 5
|
3
|
-
#
|
4
|
-
# Testing one nodes in one group running a custom app
|
5
|
-
# Also testing all the possible bindings between app arguments and OMF
|
6
|
-
# Also testing app installation via TAR archive (containing the app and a payload data)
|
7
|
-
#
|
8
|
-
|
9
|
-
defProperty('res1', "unconfigured-node-1", "ID of a node")
|
10
|
-
defProperty('res2', "unconfigured-node-2", "ID of a node")
|
11
|
-
defProperty('pstring', "ABC", "1st string argument")
|
12
|
-
defProperty('pboolean', true, "1st boolean argument")
|
13
|
-
defProperty('pinteger', 123, "1st integer argument")
|
14
|
-
|
15
|
-
defApplication('myAppURI', 'myAppName') { |app|
|
16
|
-
app.path = "/usr/bin/myApp"
|
17
|
-
app.appPackage = "http://omf.mytestbed.net/myApp.tar"
|
18
|
-
|
19
|
-
app.defProperty('arg1','Argument 1', '-s', {:order => 1, :type => :string, :dynamic => true})
|
20
|
-
app.defProperty('arg2','Argument 2', '--arg2', {:type => :string, :dynamic => false})
|
21
|
-
app.defProperty('arg3','Argument 3', '-b', {:type => :boolean, :dynamic => false})
|
22
|
-
app.defProperty('arg4','Argument 4', '--arg4', {:type => :boolean, :dynamic => true})
|
23
|
-
app.defProperty('arg5','Argument 5', '--arg5', {:type => :boolean, :dynamic => false})
|
24
|
-
app.defProperty('arg6','Argument 6', '-i', {:order => 2, :type => :integer, :dynamic => false})
|
25
|
-
app.defProperty('arg7','Argument 7', '--arg7', {:type => :integer, :dynamic => true})
|
26
|
-
app.defProperty('arg8','Argument 8', nil, {:type => :string, :dynamic => true})
|
27
|
-
app.defProperty('arg9','Argument 9', nil, {:type => :integer, :dynamic => false})
|
28
|
-
}
|
29
|
-
|
30
|
-
defGroup('Actor', property.res1) {|n|
|
31
|
-
n.addApplication("myAppURI") {|app|
|
32
|
-
app.setProperty('arg1', property.pstring) # Displays "-s ABC" in first position!
|
33
|
-
app.setProperty('arg2', 'DEF') # Displays "--arg2 DEF"
|
34
|
-
app.setProperty('arg3', property.pboolean) # Displays "-b"
|
35
|
-
app.setProperty('arg4', true) # Displays "--arg4"
|
36
|
-
app.setProperty('arg5', false) # Displays nothing
|
37
|
-
app.setProperty('arg6', property.pinteger) # Displays "-i 123" in second position!
|
38
|
-
app.setProperty('arg7', 456) # Displays "--arg7 456"
|
39
|
-
app.setProperty('arg8', "ZZZ") # Displays "ZZZ"
|
40
|
-
app.setProperty('arg9', 000) # Displays "0"
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
onEvent(:ALL_UP_AND_INSTALLED) do |event|
|
45
|
-
wait 5
|
46
|
-
allGroups.startApplications
|
47
|
-
wait 5
|
48
|
-
Experiment.done
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
#
|
53
|
-
# Checking the Execution
|
54
|
-
# Here you do whatever is required to check that the above experiment went well
|
55
|
-
# Then return true if you decided that it did, or false otherwise
|
56
|
-
#
|
57
|
-
# Experiment log file is at: property.logpath
|
58
|
-
# Also you may want to look at system:exp:testlib
|
59
|
-
#
|
60
|
-
|
61
|
-
def check_outcome
|
62
|
-
|
63
|
-
# Test 03 is successfull if all of the following are true:
|
64
|
-
# 1) the tarball is installed OK AND the application runs OK
|
65
|
-
# 2) the application outputs the correct payload from the tarball
|
66
|
-
# 3) the application accepts and outputs the correct arguments
|
67
|
-
logfile = "#{property.logpath}/#{Experiment.ID}.log"
|
68
|
-
lines = IO.readlines("#{logfile}")
|
69
|
-
# 1)
|
70
|
-
match1 = lines.grep(/APP_EVENT\ STARTED/)
|
71
|
-
r1 = (match1.length == 2) ? true : false
|
72
|
-
match1 = lines.grep(/APP_EVENT DONE\.OK/)
|
73
|
-
match2 = match1.grep(/AgentCommands/)
|
74
|
-
r2 = (match2.length == 2) ? true : false
|
75
|
-
# 2)
|
76
|
-
match1 = lines.grep(/PAYLOAD\-1234567890\-PAYLOAD/)
|
77
|
-
match2 = match1.grep(/AgentCommands/)
|
78
|
-
r3 = (match2.length == 1) ? true : false
|
79
|
-
match1 = lines.grep(/\-s\ ABC\ \-i\ 123\ \-\-arg7\ 456\ \-b\ ZZZ\ 0\ \-\-arg4\ \-\-arg2\ DEF/)
|
80
|
-
match2 = match1.grep(/AgentCommands/)
|
81
|
-
r4 = (match2.length == 1) ? true : false
|
82
|
-
|
83
|
-
puts "Check Outcome [r1:#{r1} - r2:#{r2} - r3:#{r3} - r4:#{r4}]"
|
84
|
-
return true if r1 && r2 && r3 && r4
|
85
|
-
return false
|
86
|
-
|
87
|
-
end
|