omf_ec 6.0.2.pre.2 → 6.0.2
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/bin/omf_ec +10 -15
- data/example/engine_oedl.rb +21 -18
- data/example/engine_test.rb +15 -11
- data/example/test_exp/test00.rb +5 -0
- data/example/test_exp/test01.rb +5 -0
- data/example/test_exp/test02.rb +5 -0
- data/example/test_exp/test03.rb +5 -0
- data/example/test_exp/test06.rb +6 -1
- data/example/test_exp/test07.rb +5 -0
- data/lib/omf_ec/app_definition.rb +5 -0
- data/lib/omf_ec/backward/app_definition.rb +25 -3
- data/lib/omf_ec/backward/core_ext/array.rb +5 -0
- data/lib/omf_ec/backward/default_events.rb +16 -10
- data/lib/omf_ec/backward/dsl.rb +5 -0
- data/lib/omf_ec/backward/exp/testbed.rb +7 -2
- data/lib/omf_ec/backward/group.rb +8 -1
- data/lib/omf_ec/context/app_context.rb +13 -7
- data/lib/omf_ec/context/def_app_context.rb +5 -0
- data/lib/omf_ec/context/group_context.rb +31 -0
- data/lib/omf_ec/context/net_context.rb +12 -0
- data/lib/omf_ec/context.rb +5 -0
- data/lib/omf_ec/core_ext/hash.rb +11 -0
- data/lib/omf_ec/dsl.rb +6 -1
- data/lib/omf_ec/experiment.rb +7 -2
- data/lib/omf_ec/experiment_property.rb +16 -11
- data/lib/omf_ec/group.rb +8 -2
- data/lib/omf_ec/version.rb +6 -1
- data/lib/omf_ec.rb +6 -0
- data/omf_ec.gemspec +3 -1
- data/test/omf_ec/context_spec.rb +5 -0
- data/test/omf_ec/dsl_spec.rb +87 -24
- data/test/omf_ec/experiment_property_spec.rb +18 -6
- data/test/omf_ec/experiment_spec.rb +6 -0
- data/test/omf_ec/group_spec.rb +32 -23
- data/test/test_helper.rb +33 -0
- metadata +27 -8
- data/config/ec.yml +0 -164
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'hashie'
|
2
7
|
require 'singleton'
|
3
8
|
|
@@ -11,7 +16,7 @@ module OmfEc
|
|
11
16
|
|
12
17
|
# Contains all the experiment properties
|
13
18
|
@@properties = Hashie::Mash.new
|
14
|
-
|
19
|
+
|
15
20
|
# Holds all observers on any Experiment Property creation
|
16
21
|
@@creation_observers = []
|
17
22
|
|
@@ -24,10 +29,10 @@ module OmfEc
|
|
24
29
|
def self.[](name)
|
25
30
|
p = @@properties[name.to_s.to_sym]
|
26
31
|
if p.nil?
|
27
|
-
raise OEDLCommandException.new(name,
|
32
|
+
raise OEDLCommandException.new(name,
|
28
33
|
"Unknown experiment property '#{name}'\n\tKnown properties are "+
|
29
34
|
"'#{ExperimentProperty.names.join(', ')}'")
|
30
|
-
end
|
35
|
+
end
|
31
36
|
return p
|
32
37
|
end
|
33
38
|
|
@@ -60,7 +65,7 @@ module OmfEc
|
|
60
65
|
return p
|
61
66
|
end
|
62
67
|
end
|
63
|
-
|
68
|
+
|
64
69
|
# Iterate over all Experiment Properties. The block
|
65
70
|
# will be called with the respective property as single
|
66
71
|
# argument
|
@@ -86,7 +91,7 @@ module OmfEc
|
|
86
91
|
name = name.to_s
|
87
92
|
# http://stackoverflow.com/questions/4378670/what-is-a-ruby-regex-to-match-a-function-name
|
88
93
|
if /[@$"]/ =~ name.to_sym.inspect
|
89
|
-
raise OEDLCommandException.new("ExperimentProperty.create",
|
94
|
+
raise OEDLCommandException.new("ExperimentProperty.create",
|
90
95
|
"Cannot create property '#{name}', its name is not a valid Ruby name")
|
91
96
|
end
|
92
97
|
p = nil
|
@@ -135,14 +140,14 @@ module OmfEc
|
|
135
140
|
set(value)
|
136
141
|
end
|
137
142
|
|
138
|
-
#
|
139
|
-
# Add a block of command to the list of actions to do
|
143
|
+
#
|
144
|
+
# Add a block of command to the list of actions to do
|
140
145
|
# when this property is being changed
|
141
146
|
#
|
142
147
|
# - &block = the block of command to add
|
143
148
|
#
|
144
149
|
def on_change (&block)
|
145
|
-
debug "Somebody bound to me"
|
150
|
+
debug "Somebody bound to me"
|
146
151
|
@change_observers << block
|
147
152
|
end
|
148
153
|
|
@@ -198,7 +203,7 @@ module OmfEc
|
|
198
203
|
|
199
204
|
# Addition operator for Integer, Float, and String properties
|
200
205
|
def +(right)
|
201
|
-
if @value.kind_of?(Integer) || @value.kind_of?(Float) || @value.kind_of?(String)
|
206
|
+
if @value.kind_of?(Integer) || @value.kind_of?(Float) || @value.kind_of?(String)
|
202
207
|
return (@value + right)
|
203
208
|
else
|
204
209
|
raise OEDLCommandException.new("+", "Illegal operation, "+
|
@@ -210,13 +215,13 @@ module OmfEc
|
|
210
215
|
# Explicit Coercion for Integer, Float, and String properties
|
211
216
|
# (allow property to be on the right-hand of an operator such as +)
|
212
217
|
def coerce(other)
|
213
|
-
if @value.kind_of?(Integer) || @value.kind_of?(Float) || @value.kind_of?(String)
|
218
|
+
if @value.kind_of?(Integer) || @value.kind_of?(Float) || @value.kind_of?(String)
|
214
219
|
return other, @value
|
215
220
|
else
|
216
221
|
raise OEDLCommandException.new("coercion", "Illegal operation, "+
|
217
222
|
"The value of Experiment Property '#{@name}' cannot be coerced to allow "+
|
218
223
|
" the requested operation (current value is of type #{value.class})")
|
219
224
|
end
|
220
|
-
end
|
225
|
+
end
|
221
226
|
end
|
222
227
|
end
|
data/lib/omf_ec/group.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'securerandom'
|
2
7
|
require 'monitor'
|
3
8
|
|
@@ -12,13 +17,14 @@ module OmfEc
|
|
12
17
|
class Group
|
13
18
|
include MonitorMixin
|
14
19
|
|
15
|
-
attr_accessor :name, :id, :net_ifs, :members, :app_contexts
|
20
|
+
attr_accessor :name, :id, :net_ifs, :members, :app_contexts, :execs
|
16
21
|
attr_reader :topic
|
17
22
|
|
18
23
|
# @param [String] name name of the group
|
19
24
|
# @param [Hash] opts
|
20
25
|
# @option opts [Boolean] :unique Should the group be unique or not, default is true
|
21
26
|
def initialize(name, opts = {}, &block)
|
27
|
+
super()
|
22
28
|
@opts = {unique: true}.merge!(opts)
|
23
29
|
self.name = name
|
24
30
|
self.id = @opts[:unique] ? SecureRandom.uuid : self.name
|
@@ -26,11 +32,11 @@ module OmfEc
|
|
26
32
|
self.net_ifs = []
|
27
33
|
self.members = []
|
28
34
|
self.app_contexts = []
|
35
|
+
self.execs = []
|
29
36
|
|
30
37
|
@resource_topics = {}
|
31
38
|
|
32
39
|
OmfEc.subscribe_and_monitor(id, self, &block)
|
33
|
-
super()
|
34
40
|
end
|
35
41
|
|
36
42
|
def associate_topic(topic)
|
data/lib/omf_ec/version.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
module OmfEc
|
2
|
-
VERSION = "6.0.2
|
7
|
+
VERSION = "6.0.2"
|
3
8
|
end
|
data/lib/omf_ec.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require "omf_common"
|
7
|
+
require 'omf_ec/core_ext/hash'
|
2
8
|
require 'omf_ec/backward/dsl'
|
3
9
|
require 'omf_ec/backward/group'
|
4
10
|
require 'omf_ec/backward/app_definition'
|
data/omf_ec.gemspec
CHANGED
@@ -25,6 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency "em-minitest-spec", "~> 1.1.1"
|
26
26
|
s.add_development_dependency "simplecov"
|
27
27
|
s.add_development_dependency "pry"
|
28
|
-
s.
|
28
|
+
s.add_development_dependency "mocha"
|
29
|
+
|
30
|
+
s.add_runtime_dependency "omf_common", "~> 6.0.2"
|
29
31
|
s.add_runtime_dependency "gli", "~> 2.5.3"
|
30
32
|
end
|
data/test/omf_ec/context_spec.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_ec/context'
|
3
8
|
|
data/test/omf_ec/dsl_spec.rb
CHANGED
@@ -1,53 +1,116 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_ec/dsl'
|
3
8
|
|
4
9
|
describe OmfEc::DSL do
|
5
|
-
|
10
|
+
before do
|
11
|
+
OmfCommon::Eventloop.init(type: :em)
|
12
|
+
@dsl = Class.new { include OmfEc::DSL }.new
|
13
|
+
OmfEc.stubs(:subscribe_and_monitor)
|
14
|
+
end
|
15
|
+
|
16
|
+
after do
|
17
|
+
OmfCommon::Eventloop.reset
|
18
|
+
OmfEc::Experiment.reset
|
19
|
+
OmfEc::ExperimentProperty.reset
|
20
|
+
OmfEc.unstub(:subscribe_and_monitor)
|
21
|
+
end
|
6
22
|
|
7
|
-
include OmfEc::DSL
|
8
23
|
|
24
|
+
describe "when included" do
|
9
25
|
it "must respond to after and every" do
|
10
|
-
|
11
|
-
|
26
|
+
EM.run { @dsl.after(0.01) { EM.stop } }
|
27
|
+
EM.run { @dsl.every(0.01) { EM.stop } }
|
12
28
|
end
|
13
29
|
|
14
|
-
it "must
|
15
|
-
@
|
16
|
-
@
|
17
|
-
|
18
|
-
OmfEc.stub :experiment, @exp do
|
19
|
-
def_property('name', 'default', 'testing')
|
20
|
-
end
|
30
|
+
it "must define property correctly" do
|
31
|
+
@dsl.def_property('name', 'default', 'testing')
|
32
|
+
@dsl.property.must_equal OmfEc::ExperimentProperty
|
33
|
+
OmfEc::ExperimentProperty.reset
|
21
34
|
end
|
22
35
|
|
23
36
|
it "must respond to def_application" do
|
24
37
|
block = proc { 1 }
|
25
|
-
def_application('bob', &block).must_equal 1
|
38
|
+
@dsl.def_application('bob', &block).must_equal 1
|
26
39
|
OmfEc.experiment.app_definitions.key?('bob').must_equal true
|
27
40
|
end
|
28
41
|
|
42
|
+
it "must respond to group" do
|
43
|
+
lambda { @dsl.group('bob') }.must_raise RuntimeError
|
44
|
+
g = mock
|
45
|
+
OmfEc.experiment.stubs(:group).returns(g)
|
46
|
+
@dsl.group('bob').must_equal g
|
47
|
+
end
|
48
|
+
|
29
49
|
it "must respond to def_group" do
|
30
50
|
block = proc { 1 }
|
31
|
-
|
32
|
-
def_group('bob', &block).must_be_kind_of OmfEc::Group
|
33
|
-
end
|
51
|
+
@dsl.def_group('bob', &block).must_be_kind_of OmfEc::Group
|
34
52
|
end
|
35
53
|
|
36
54
|
it "must respond to all_groups iterator" do
|
37
55
|
block = proc { 1 }
|
38
|
-
all_groups(&block)
|
56
|
+
@dsl.all_groups(&block)
|
39
57
|
end
|
40
58
|
|
41
59
|
it "must respond to all_groups?" do
|
42
|
-
OmfEc.stub :
|
43
|
-
|
44
|
-
all_groups? { true }.must_equal false
|
45
|
-
end
|
46
|
-
def_group('bob')
|
47
|
-
all_groups? { |g| g.name == 'bob' }.must_equal true
|
60
|
+
OmfEc.experiment.stub :groups, [] do
|
61
|
+
@dsl.all_groups? { true }.must_equal false
|
48
62
|
end
|
63
|
+
@dsl.def_group('bob')
|
64
|
+
@dsl.all_groups? { |g| g.name == 'bob' }.must_equal true
|
49
65
|
end
|
50
|
-
end
|
51
66
|
|
52
|
-
|
67
|
+
it "must respond to all_equal" do
|
68
|
+
@dsl.all_equal([]).must_equal false
|
69
|
+
@dsl.all_equal([1, 1], 1).must_equal true
|
70
|
+
@dsl.all_equal([1, 1]) do |v|
|
71
|
+
v == 1
|
72
|
+
end.must_equal true
|
73
|
+
end
|
74
|
+
|
75
|
+
it "must respond to one_equal" do
|
76
|
+
@dsl.one_equal([1, 0], 1).must_equal true
|
77
|
+
@dsl.one_equal([0, 0], 1).must_equal false
|
78
|
+
end
|
53
79
|
|
80
|
+
it "must init OEDL exceptions" do
|
81
|
+
lambda { raise OEDLArgumentException.new("ls", "bob") }.must_raise OEDLArgumentException
|
82
|
+
lambda { raise OEDLCommandException.new("bob") }.must_raise OEDLCommandException
|
83
|
+
lambda { raise OEDLUnknownProperty.new("bob") }.must_raise OEDLUnknownProperty
|
84
|
+
end
|
85
|
+
|
86
|
+
it "must respond to done!" do
|
87
|
+
done!
|
88
|
+
end
|
89
|
+
|
90
|
+
it "must respond to define an event" do
|
91
|
+
lambda { def_event :bob }.must_raise ArgumentError
|
92
|
+
|
93
|
+
def_event(:bob) { nil }
|
94
|
+
end
|
95
|
+
|
96
|
+
it "must respond to event callback" do
|
97
|
+
lambda { on_event(:bob) }.must_raise RuntimeError
|
98
|
+
def_event(:bob) { nil }
|
99
|
+
on_event(:bob) { nil }
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "when using OEDL 5 syntax" do
|
103
|
+
it "must respond to wait" do
|
104
|
+
@dsl.wait(0.01)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "must respond to defApplication" do
|
108
|
+
@dsl.defApplication('some_uri')
|
109
|
+
end
|
110
|
+
|
111
|
+
it "must respond to defGroup" do
|
112
|
+
@dsl.defGroup('bob', 'a', 'b') { nil }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -1,10 +1,14 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_ec/experiment_property'
|
3
8
|
require 'omf_ec/dsl'
|
4
9
|
include OmfEc::DSL
|
5
10
|
|
6
11
|
describe OmfEc::ExperimentProperty do
|
7
|
-
|
8
12
|
describe "when a new ExperimentProperty is created" do
|
9
13
|
it "must raise an error if it is given an invalid name" do
|
10
14
|
created_properties = 0
|
@@ -41,7 +45,7 @@ describe OmfEc::ExperimentProperty do
|
|
41
45
|
it "must inform all of its observers when its value changes" do
|
42
46
|
value = 2
|
43
47
|
foobar = OmfEc::ExperimentProperty.create('foobar',1)
|
44
|
-
foobar.on_change { |v| v.must_equal value }
|
48
|
+
foobar.on_change { |v| v.must_equal value }
|
45
49
|
foobar.on_change { |v| (v*2).must_equal value*2 }
|
46
50
|
OmfEc::ExperimentProperty[:foobar] = value
|
47
51
|
OmfEc::ExperimentProperty[:foobar].value.must_equal value
|
@@ -50,8 +54,11 @@ describe OmfEc::ExperimentProperty do
|
|
50
54
|
|
51
55
|
describe "when a the Class ExperimentProperty is creating a new property" do
|
52
56
|
it "must inform all of its observers" do
|
57
|
+
OmfEc::ExperimentProperty.reset
|
58
|
+
|
53
59
|
size_before = OmfEc::ExperimentProperty.length
|
54
60
|
OmfEc::ExperimentProperty.add_observer do |c,p|
|
61
|
+
c.must_equal :create
|
55
62
|
p.name.must_equal 'barfoo'
|
56
63
|
p.value.must_equal 123
|
57
64
|
p.description.must_equal 'abc'
|
@@ -63,18 +70,23 @@ describe OmfEc::ExperimentProperty do
|
|
63
70
|
|
64
71
|
describe "when an operation involves an ExperimentProperty" do
|
65
72
|
it "must return the expected result" do
|
73
|
+
OmfEc::ExperimentProperty.reset
|
74
|
+
|
75
|
+
OmfEc::ExperimentProperty.create('foo', 1, 'abc')
|
76
|
+
OmfEc::ExperimentProperty.create('bar','b')
|
77
|
+
|
66
78
|
OmfEc::ExperimentProperty[:foo] = 2
|
67
79
|
(OmfEc::ExperimentProperty[:foo] + 1).must_equal 3
|
68
80
|
(1 + OmfEc::ExperimentProperty[:foo]).must_equal 3
|
69
81
|
(OmfEc::ExperimentProperty[:foo] - 1).must_equal 1
|
70
82
|
(1 - OmfEc::ExperimentProperty[:foo]).must_equal -1
|
71
|
-
(OmfEc::ExperimentProperty[:foo] * 2).must_equal 4
|
83
|
+
(OmfEc::ExperimentProperty[:foo] * 2).must_equal 4
|
72
84
|
(2 * OmfEc::ExperimentProperty[:foo]).must_equal 4
|
73
|
-
(OmfEc::ExperimentProperty[:foo] / 1).must_equal 2
|
85
|
+
(OmfEc::ExperimentProperty[:foo] / 1).must_equal 2
|
74
86
|
(2 / OmfEc::ExperimentProperty[:foo]).must_equal 1
|
75
87
|
OmfEc::ExperimentProperty[:bar] = 'a'
|
76
|
-
(OmfEc::ExperimentProperty[:bar] + "b").must_equal 'ab'
|
77
|
-
('b' + OmfEc::ExperimentProperty[:bar]).must_equal 'ba'
|
88
|
+
(OmfEc::ExperimentProperty[:bar] + "b").must_equal 'ab'
|
89
|
+
('b' + OmfEc::ExperimentProperty[:bar]).must_equal 'ba'
|
78
90
|
end
|
79
91
|
end
|
80
92
|
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_ec/experiment'
|
3
8
|
|
@@ -21,6 +26,7 @@ describe OmfEc::Experiment do
|
|
21
26
|
end
|
22
27
|
|
23
28
|
it "must be able to add sub group" do
|
29
|
+
skip
|
24
30
|
@experiment.add_sub_group('bob')
|
25
31
|
@experiment.sub_group('bob').must_equal "bob"
|
26
32
|
end
|
data/test/omf_ec/group_spec.rb
CHANGED
@@ -1,27 +1,34 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
require 'omf_ec/group'
|
3
8
|
|
4
9
|
describe OmfEc::Group do
|
10
|
+
before do
|
11
|
+
OmfEc.stubs(:subscribe_and_monitor)
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
OmfEc.unstub(:subscribe_and_monitor)
|
16
|
+
end
|
17
|
+
|
5
18
|
describe "when initialised" do
|
6
19
|
it "must be generate unique id if :unique option is on" do
|
7
|
-
OmfEc.
|
8
|
-
OmfEc::Group.new('bob').id.wont_equal 'bob'
|
9
|
-
end
|
20
|
+
OmfEc::Group.new('bob').id.wont_equal 'bob'
|
10
21
|
end
|
11
22
|
|
12
23
|
it "must use name as id if :unique option is off" do
|
13
|
-
OmfEc.
|
14
|
-
OmfEc::Group.new('bob', unique: false).id.must_equal 'bob'
|
15
|
-
end
|
24
|
+
OmfEc::Group.new('bob', unique: false).id.must_equal 'bob'
|
16
25
|
end
|
17
26
|
end
|
18
27
|
|
19
28
|
describe "when used to represent group resource" do
|
20
29
|
before do
|
21
|
-
@
|
22
|
-
OmfEc.
|
23
|
-
@group = OmfEc::Group.new('bob', unique: false)
|
24
|
-
end
|
30
|
+
@group = OmfEc::Group.new('bob', unique: false)
|
31
|
+
@g_b = OmfEc::Group.new('g_b', unique: false)
|
25
32
|
end
|
26
33
|
|
27
34
|
it "must init default context related arrasy" do
|
@@ -31,27 +38,29 @@ describe OmfEc::Group do
|
|
31
38
|
end
|
32
39
|
|
33
40
|
it "must be capable of adding existing resources to group" do
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
41
|
+
@group.add_resource(['r1', 'r2'])
|
42
|
+
|
43
|
+
OmfEc.experiment.stubs(:groups).returns([@g_b])
|
44
|
+
|
45
|
+
@group.add_resource('g_b')
|
40
46
|
end
|
41
47
|
|
42
48
|
it "must be capable of creating new resources and add them to group" do
|
43
|
-
|
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
|
49
|
+
@group.create_resource('r1', { type: :test, p1: 'bob' })
|
50
50
|
end
|
51
51
|
|
52
52
|
it "must create new group context when calling resources" do
|
53
53
|
@group.resources.must_be_kind_of OmfEc::Context::GroupContext
|
54
54
|
end
|
55
|
+
|
56
|
+
it "must be capable of associating pubsub topic instances" do
|
57
|
+
t = mock
|
58
|
+
@group.associate_topic(t)
|
59
|
+
@group.topic.must_equal t
|
60
|
+
|
61
|
+
@group.associate_resource_topic('bob', t)
|
62
|
+
@group.resource_topic('bob').must_equal t
|
63
|
+
end
|
55
64
|
end
|
56
65
|
end
|
57
66
|
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'simplecov'
|
2
7
|
SimpleCov.start { add_filter "/test" }
|
3
8
|
|
4
9
|
gem 'minitest'
|
5
10
|
require 'minitest/autorun'
|
6
11
|
require 'minitest/pride'
|
12
|
+
require 'mocha/setup'
|
7
13
|
|
8
14
|
require 'omf_ec'
|
9
15
|
|
@@ -17,3 +23,30 @@ Logging.logger.root.clear_appenders
|
|
17
23
|
def fixture(name)
|
18
24
|
File.read("#{FIXTURE_DIR}/#{name.to_s}")
|
19
25
|
end
|
26
|
+
|
27
|
+
class OmfCommon::Eventloop
|
28
|
+
def self.reset
|
29
|
+
@@instance = nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class OmfEc::Experiment
|
34
|
+
def self.reset
|
35
|
+
instance.instance_eval do
|
36
|
+
@groups = []
|
37
|
+
@events = []
|
38
|
+
@app_definitions = Hashie::Mash.new
|
39
|
+
@sub_groups = Hashie::Mash.new
|
40
|
+
@cmdline_properties = Hashie::Mash.new
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class OmfEc::ExperimentProperty
|
46
|
+
def self.reset
|
47
|
+
@@properties = Hashie::Mash.new
|
48
|
+
@@creation_observers = []
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omf_ec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.2
|
5
|
-
prerelease:
|
4
|
+
version: 6.0.2
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- NICTA
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -75,6 +75,22 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: mocha
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
78
94
|
- !ruby/object:Gem::Dependency
|
79
95
|
name: omf_common
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +98,7 @@ dependencies:
|
|
82
98
|
requirements:
|
83
99
|
- - ~>
|
84
100
|
- !ruby/object:Gem::Version
|
85
|
-
version: 6.0.2
|
101
|
+
version: 6.0.2
|
86
102
|
type: :runtime
|
87
103
|
prerelease: false
|
88
104
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +106,7 @@ dependencies:
|
|
90
106
|
requirements:
|
91
107
|
- - ~>
|
92
108
|
- !ruby/object:Gem::Version
|
93
|
-
version: 6.0.2
|
109
|
+
version: 6.0.2
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: gli
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,7 +136,6 @@ files:
|
|
120
136
|
- Gemfile
|
121
137
|
- Rakefile
|
122
138
|
- bin/omf_ec
|
123
|
-
- config/ec.yml
|
124
139
|
- example/engine_oedl.rb
|
125
140
|
- example/engine_test.rb
|
126
141
|
- example/test_exp/test00.rb
|
@@ -142,6 +157,7 @@ files:
|
|
142
157
|
- lib/omf_ec/context/def_app_context.rb
|
143
158
|
- lib/omf_ec/context/group_context.rb
|
144
159
|
- lib/omf_ec/context/net_context.rb
|
160
|
+
- lib/omf_ec/core_ext/hash.rb
|
145
161
|
- lib/omf_ec/dsl.rb
|
146
162
|
- lib/omf_ec/experiment.rb
|
147
163
|
- lib/omf_ec/experiment_property.rb
|
@@ -170,9 +186,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
187
|
none: false
|
172
188
|
requirements:
|
173
|
-
- - ! '
|
189
|
+
- - ! '>='
|
174
190
|
- !ruby/object:Gem::Version
|
175
|
-
version:
|
191
|
+
version: '0'
|
192
|
+
segments:
|
193
|
+
- 0
|
194
|
+
hash: 1252066370023531099
|
176
195
|
requirements: []
|
177
196
|
rubyforge_project: omf_ec
|
178
197
|
rubygems_version: 1.8.25
|