omf_ec 6.1.2.pre.4 → 6.1.2.pre.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,23 +22,20 @@ defEvent :rpm_reached_4000 do |state|
22
22
  end
23
23
 
24
24
  # Define a group and add garages to it.
25
- defGroup('garages', prop.garage, include_childern: true)
25
+ defGroup('garages', prop.garage)
26
26
 
27
27
  # :ALL_UP is a pre-defined event,
28
28
  # triggered when all resources set to be part of groups are available and configured as members of the associated groups.
29
29
  onEvent :ALL_UP do
30
30
  group('garages') do |g|
31
- #g.request("child_resources")
32
- g.engines.request(:rpm)
33
-
34
- g.create_engine('my_engine') do #, type: 'engine')
31
+ g.create_resource('my_engine', type: 'engine')
35
32
 
36
33
  onEvent :engine_created do
37
34
  info ">>> Accelerating all engines"
38
35
  g.resources[type: 'engine'].throttle = 50
36
+
39
37
  # We periodically check engine RPM
40
38
  every 2.second do
41
- g.engines.request(:rpm)
42
39
  g.resources[type: 'engine'].rpm
43
40
  end
44
41
  end
data/lib/omf_ec/runner.rb CHANGED
@@ -176,7 +176,9 @@ module OmfEc
176
176
 
177
177
  remove_cmd_opts_from_argv("exec")
178
178
 
179
- @argv.in_groups_of(2) do |arg_g|
179
+ index_of_dividing_hyphen = @argv.index("--")
180
+
181
+ @argv[0..index_of_dividing_hyphen || -1].in_groups_of(2) do |arg_g|
180
182
  if arg_g[0] =~ /^--(.+)/ && !arg_g[1].nil?
181
183
  remove_cmd_opts_from_argv(*arg_g)
182
184
  end
@@ -189,19 +191,23 @@ module OmfEc
189
191
  exit(1)
190
192
  end
191
193
 
194
+ @argv.slice!(0)
195
+
192
196
  # User-provided command line values for Experiment Properties cannot be
193
197
  # set here as the properties have not been defined yet by the experiment.
194
198
  # Thus just pass them to the experiment, which will be responsible
195
199
  # for setting them later
196
200
  properties = {}
197
- if @argv.size > 1 && @argv[1] == "--"
198
- exp_properties = @argv[2..-1]
201
+ if index_of_dividing_hyphen
202
+ remove_cmd_opts_from_argv("--")
203
+ exp_properties = @argv
199
204
  exp_properties.in_groups_of(2) do |p|
200
205
  unless p[0] =~ /^--(.+)/ && !p[1].nil?
201
206
  puts "Malformatted properties '#{exp_properties.join(' ')}'"
202
207
  exit(1)
203
208
  else
204
209
  properties[$1.to_sym] = p[1].ducktype
210
+ remove_cmd_opts_from_argv(*p)
205
211
  end
206
212
  end
207
213
  OmfEc.experiment.cmdline_properties = properties
@@ -9,6 +9,14 @@ require 'omf_ec/dsl'
9
9
  include OmfEc::DSL
10
10
 
11
11
  describe OmfEc::ExperimentProperty do
12
+ before do
13
+ OmfEc::ExperimentProperty.reset
14
+ end
15
+
16
+ after do
17
+ OmfEc::ExperimentProperty.reset
18
+ end
19
+
12
20
  describe "when a new ExperimentProperty is created" do
13
21
  it "must raise an error if it is given an invalid name" do
14
22
  created_properties = 0
@@ -54,8 +62,6 @@ describe OmfEc::ExperimentProperty do
54
62
 
55
63
  describe "when a the Class ExperimentProperty is creating a new property" do
56
64
  it "must inform all of its observers" do
57
- OmfEc::ExperimentProperty.reset
58
-
59
65
  size_before = OmfEc::ExperimentProperty.length
60
66
  OmfEc::ExperimentProperty.add_observer do |c,p|
61
67
  c.must_equal :create
@@ -70,8 +76,6 @@ describe OmfEc::ExperimentProperty do
70
76
 
71
77
  describe "when an operation involves an ExperimentProperty" do
72
78
  it "must return the expected result" do
73
- OmfEc::ExperimentProperty.reset
74
-
75
79
  OmfEc::ExperimentProperty.create('foo', 1, 'abc')
76
80
  OmfEc::ExperimentProperty.create('bar','b')
77
81
 
data/test/test_helper.rb CHANGED
@@ -33,11 +33,13 @@ end
33
33
  class OmfEc::Experiment
34
34
  def self.reset
35
35
  Singleton.__init__(self)
36
+ self
36
37
  end
37
38
  end
38
39
 
39
40
  class OmfEc::ExperimentProperty
40
41
  def self.reset
41
- Singleton.__init__(self)
42
+ @@properties = Hashie::Mash.new
43
+ @@creation_observers = []
42
44
  end
43
45
  end
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.1.2.pre.4
4
+ version: 6.1.2.pre.5
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: 2014-05-15 00:00:00.000000000 Z
12
+ date: 2014-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 6.1.2.pre.4
101
+ version: 6.1.2.pre.5
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 6.1.2.pre.4
109
+ version: 6.1.2.pre.5
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: sequel
112
112
  requirement: !ruby/object:Gem::Requirement