omf_ec 6.0.0.pre.3 → 6.0.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. data/Rakefile +1 -0
  2. data/bin/omf_ec +264 -0
  3. data/example/engine_oedl.rb +52 -0
  4. data/example/engine_test.rb +90 -0
  5. data/example/test_exp/test00.rb +12 -0
  6. data/example/test_exp/test01.rb +22 -0
  7. data/example/test_exp/test02.rb +30 -0
  8. data/{exp_repo/test/exp → example/test_exp}/test03.rb +2 -42
  9. data/{exp_repo/test/exp → example/test_exp}/test04.rb +2 -2
  10. data/{exp_repo/test/exp → example/test_exp}/test05.rb +4 -4
  11. data/{exp_repo/test/exp → example/test_exp}/test06.rb +6 -6
  12. data/example/test_exp/test07.rb +65 -0
  13. data/lib/omf_ec/app_definition.rb +57 -0
  14. data/lib/omf_ec/backward/app_definition.rb +35 -0
  15. data/lib/omf_ec/backward/core_ext/array.rb +19 -0
  16. data/lib/omf_ec/backward/default_events.rb +71 -0
  17. data/lib/omf_ec/backward/dsl.rb +83 -0
  18. data/lib/omf_ec/backward/exp/testbed.rb +47 -0
  19. data/lib/omf_ec/backward/group.rb +72 -0
  20. data/lib/omf_ec/context/app_context.rb +54 -0
  21. data/lib/omf_ec/context/def_app_context.rb +6 -0
  22. data/lib/omf_ec/context/group_context.rb +88 -0
  23. data/lib/omf_ec/context/net_context.rb +46 -0
  24. data/lib/omf_ec/context.rb +10 -0
  25. data/lib/omf_ec/dsl.rb +159 -0
  26. data/lib/omf_ec/experiment.rb +71 -0
  27. data/lib/omf_ec/group.rb +158 -0
  28. data/lib/omf_ec/version.rb +1 -1
  29. data/lib/omf_ec.rb +34 -1
  30. data/omf_ec.gemspec +2 -3
  31. data/test/omf_ec/context_spec.rb +19 -0
  32. data/test/omf_ec/group_spec.rb +14 -0
  33. data/test/test_helper.rb +19 -0
  34. metadata +44 -89
  35. data/bin/omf +0 -147
  36. data/bin/omf_pre +0 -76
  37. data/bin/omf_test +0 -161
  38. data/example/net_devices.rb +0 -75
  39. data/exp_repo/system/exp/eventlib.rb +0 -96
  40. data/exp_repo/system/exp/imageNode.rb +0 -283
  41. data/exp_repo/system/exp/reset.rb +0 -21
  42. data/exp_repo/system/exp/saveNode.rb +0 -99
  43. data/exp_repo/system/exp/stat.rb +0 -49
  44. data/exp_repo/system/exp/stdlib.rb +0 -122
  45. data/exp_repo/system/exp/tell.rb +0 -53
  46. data/exp_repo/system/exp/testlib.rb +0 -12
  47. data/exp_repo/system/exp/winlib.rb +0 -154
  48. data/exp_repo/system/topo/active.rb +0 -9
  49. data/exp_repo/system/topo/all.rb +0 -10
  50. data/exp_repo/system/topo/circle.rb +0 -23
  51. data/exp_repo/test/app/aodvd.rb +0 -73
  52. data/exp_repo/test/app/appDef1.rb +0 -102
  53. data/exp_repo/test/app/athstats.rb +0 -76
  54. data/exp_repo/test/app/echo.rb +0 -36
  55. data/exp_repo/test/app/gennyReceiverAppDef.rb +0 -100
  56. data/exp_repo/test/app/gennySenderAppDef.rb +0 -106
  57. data/exp_repo/test/app/itgdec.rb +0 -79
  58. data/exp_repo/test/app/itgr.rb +0 -77
  59. data/exp_repo/test/app/itgs.rb +0 -105
  60. data/exp_repo/test/app/nop.rb +0 -36
  61. data/exp_repo/test/app/otg2.rb +0 -68
  62. data/exp_repo/test/app/otg2_mp.rb +0 -56
  63. data/exp_repo/test/app/otr2.rb +0 -56
  64. data/exp_repo/test/app/otr2_mp.rb +0 -51
  65. data/exp_repo/test/app/trace_oml2.rb +0 -62
  66. data/exp_repo/test/app/wlanconfig_oml2.rb +0 -42
  67. data/exp_repo/test/exp/conf-room-demo.rb +0 -118
  68. data/exp_repo/test/exp/planetlab.rb +0 -82
  69. data/exp_repo/test/exp/test01.rb +0 -42
  70. data/exp_repo/test/exp/test02.rb +0 -60
  71. data/exp_repo/test/exp/tutorial/hello-world-wired.rb +0 -79
  72. data/exp_repo/test/exp/tutorial/hello-world-wireless.rb +0 -87
  73. data/exp_repo/test/exp/tutorial/using-filters.rb +0 -69
  74. data/exp_repo/test/exp/tutorial/using-groups.rb +0 -64
  75. data/exp_repo/test/exp/tutorial/using-properties.rb +0 -93
  76. data/exp_repo/test/exp/tutorial/using-prototypes.rb +0 -111
  77. data/exp_repo/test/proto/aodvrouter.rb +0 -55
  78. data/exp_repo/test/proto/driverqueryapp.rb +0 -59
  79. data/exp_repo/test/proto/forwarder.rb +0 -73
  80. data/exp_repo/test/proto/itgcbrsender.rb +0 -70
  81. data/exp_repo/test/proto/itgdecoder.rb +0 -64
  82. data/exp_repo/test/proto/itgreceiver.rb +0 -55
  83. data/exp_repo/test/proto/itgvoipsender.rb +0 -64
  84. data/exp_repo/test/proto/listener2.rb +0 -62
  85. data/exp_repo/test/proto/nop.rb +0 -47
  86. data/exp_repo/test/proto/probelink.rb +0 -48
  87. data/exp_repo/test/proto/raw_receiver.rb +0 -64
  88. data/exp_repo/test/proto/receiver2_mp.rb +0 -48
  89. data/exp_repo/test/proto/sender2_mp.rb +0 -54
  90. data/exp_repo/test/proto/udp_receiver.rb +0 -55
  91. data/exp_repo/test/proto/udp_sender.rb +0 -61
data/Rakefile CHANGED
@@ -4,6 +4,7 @@ require "bundler/gem_tasks"
4
4
  task :default => :test
5
5
 
6
6
  Rake::TestTask.new do |t|
7
+ t.libs << 'test'
7
8
  t.pattern = "test/**/*_spec.rb"
8
9
  t.verbose = true
9
10
  end
data/bin/omf_ec ADDED
@@ -0,0 +1,264 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ require 'gli'
4
+ require 'omf_ec'
5
+ $stdout.sync = true
6
+
7
+ include GLI::App
8
+ include OmfEc
9
+
10
+ program_desc "Run a command on the testbed(s)"
11
+ version OmfEc::VERSION
12
+
13
+ desc "Debug mode (printing debug logging messages)"
14
+ switch [:d, :debug]
15
+
16
+ desc "Debug XMPP traffic mode (include XMPP debug logging messages under debug mode)."
17
+ switch [:x, :xmpp]
18
+
19
+ desc "XMPP user name"
20
+ arg_name "user"
21
+ flag [:u, :user]
22
+
23
+ desc "XMPP user password"
24
+ arg_name "password"
25
+ flag [:p, :password]
26
+
27
+ desc "XMPP server domain"
28
+ arg_name "domain"
29
+ default_value "localhost"
30
+ flag [:s, :server]
31
+
32
+ desc "Private key file"
33
+ arg_name "key", :optional
34
+ flag [:private_key]
35
+
36
+ desc "Log file directory"
37
+ arg_name "directory"
38
+ default_value "/tmp"
39
+ flag [:log_file_dir]
40
+
41
+ config_file(".config/omf_ec.yml")
42
+
43
+ desc "Execute an experiment script"
44
+ arg_name "path_to_script_file [-- --experiment_property value]"
45
+ command :exec do |c|
46
+ c.desc "Experiment name"
47
+ c.arg_name "experiment_name"
48
+ c.flag [:e, :experiment]
49
+
50
+ c.desc "Default OML URI to use for collecting measurements"
51
+ c.arg_name "uri"
52
+ c.flag [:oml_uri]
53
+
54
+ c.desc "Check script version (you need to define OMF_VERSIONS in your script"
55
+ c.switch "version_check"
56
+
57
+ c.action do |global_options, options, args|
58
+ help_now! "Missing experiment script" if args[0].nil?
59
+ help_now! "Experiment script not found" unless File.exist?(args[0])
60
+
61
+ # User provided exp properties
62
+ if args.size > 1
63
+ exp_properties = args[1..-1]
64
+
65
+ exp_properties.in_groups_of(2) do |p|
66
+ unless p[0] =~ /^--(.+)/ && !p[1].nil?
67
+ help_now! "Malformatted properties '#{exp_properties.join(' ')}'"
68
+ else
69
+ OmfEc.exp.property[$1.to_sym] = p[1].ducktype
70
+ end
71
+ end
72
+ end
73
+
74
+ # FIXME this loading script is way too simple
75
+ load_exp(args[0], global_options, options)
76
+ end
77
+ end
78
+
79
+ desc "Load an image onto the nodes"
80
+ command :load do |c|
81
+ #c.desc "use this testbed configuration in OMF 5 EC config file"
82
+ #c.arg_name "AGGREGATE"
83
+ #c.flag [:c, :config], :default_value => "default"
84
+
85
+ c.desc "comma-separated list of nodes to image"
86
+ c.arg_name "TOPOLOGY"
87
+ c.flag [:t, :topology], :default_value => "system:topo:all"
88
+
89
+ c.desc "disk image to load"
90
+ c.arg_name "IMAGE"
91
+ c.flag [:i, :image], :default_value => "baseline.ndz"
92
+
93
+ c.desc "seconds to wait for the imaging process to complete"
94
+ c.arg_name "TIMEOUT"
95
+ c.flag [:o, :timeout], :default_value => "800"
96
+
97
+ c.desc "resize the first partition to SIZE GB or to maximum size if SIZE=0 "+
98
+ "or leave x percent of free space if SIZE=x%"
99
+ c.arg_name "SIZE"
100
+ c.flag [:r, :resize]
101
+
102
+ c.desc "Path where the resulting Topologies should be saved"
103
+ c.arg_name "PATH"
104
+ c.flag [:outpath], :default_value => "/tmp"
105
+
106
+ c.desc "Prefix to use for naming the resulting Topologies (default is your experiment ID)"
107
+ c.arg_name "PREFIX"
108
+ c.flag [:outprefix]
109
+
110
+ c.action do |global_options, options, args|
111
+ @cmd = "omf-5.4 load -t #{options[:t]} -i #{options[:i]} "
112
+ @cmd += "-o #{options[:o]} --outpath #{options[:outpath]} "
113
+ @cmd += "-r #{options[:r]} " if options[:r]
114
+ @cmd += "--outprefix #{options[:outprefix]} " if options[:outprefix]
115
+ load_exp(@testbed_exp_path, global_options, options)
116
+ end
117
+ end
118
+
119
+ desc "Save an image of a node"
120
+ command :save do |c|
121
+ #c.desc "use this testbed configuration in OMF 5 EC config file"
122
+ #c.arg_name "AGGREGATE"
123
+ #c.flag [:c, :config], :default_value => "default"
124
+
125
+ c.desc "node to save from"
126
+ c.arg_name "NODE"
127
+ c.flag [:n, :node]
128
+
129
+ c.desc "resize the first partition to SIZE GB or to maximum size if SIZE=0 "+
130
+ "or leave x percent of free space if SIZE=x%"
131
+ c.arg_name "SIZE"
132
+ c.flag [:r, :resize]
133
+
134
+ c.action do |global_options, options, args|
135
+ @cmd = "omf-5.4 save "
136
+ @cmd += "-n #{options[:n]} " if options[:n]
137
+ @cmd += "-r #{options[:r]} " if options[:r]
138
+ load_exp(@testbed_exp_path, global_options, options)
139
+ end
140
+ end
141
+
142
+ desc "Return the status of the nodes"
143
+ command :stat do |c|
144
+ c.desc "use this testbed configuration in OMF 5 EC config file"
145
+ c.arg_name "AGGREGATE"
146
+ c.flag [:c, :config], :default_value => "default"
147
+
148
+ c.desc "comma-separated list of nodes to image"
149
+ c.arg_name "TOPOLOGY"
150
+ c.flag [:t, :topology], :default_value => "system:topo:all"
151
+
152
+ c.desc "print a summary of the node status for the testbed"
153
+ c.switch [:s, :summary]
154
+
155
+ c.action do |global_options, options, args|
156
+ @cmd = "omf-5.4 stat -c #{options[:c]} -t #{options[:t]} "
157
+ @cmd += "-s" if options[:s]
158
+ load_exp(@testbed_exp_path, global_options, options)
159
+ end
160
+ end
161
+
162
+ desc "Power on/off, reset or reboot the nodes"
163
+ command :tell do |c|
164
+ c.desc "use this testbed configuration in OMF 5 EC config file"
165
+ c.arg_name "AGGREGATE"
166
+ c.flag [:c, :config], :default_value => "default"
167
+
168
+ c.desc "comma-separated list of nodes to image"
169
+ c.arg_name "TOPOLOGY"
170
+ c.flag [:t, :topology], :default_value => "system:topo:all"
171
+
172
+ c.desc "
173
+ 'on' turn node(s) ON -
174
+ 'offs' turn node(s) OFF (soft) -
175
+ 'offh' turn node(s) OFF (hard) -
176
+ 'reboot' reboots node(s) (soft) -
177
+ 'reset' resets node(s) (hard)"
178
+ c.arg_name "ACTION"
179
+ c.flag [:a, :action]
180
+
181
+ c.action do |global_options, options, args|
182
+ @cmd = "omf-5.4 tell -c #{options[:c]} -t #{options[:t]} "
183
+ @cmd += "-a #{options[:a]} " if options[:a]
184
+ load_exp(@testbed_exp_path, global_options, options)
185
+ end
186
+ end
187
+
188
+ on_error do |exception|
189
+ true
190
+ end
191
+
192
+ pre do |global_options, command, options, args|
193
+ unless global_options[:user] && global_options[:password] && global_options[:server]
194
+ help_now! "Incomplete options"
195
+ end
196
+
197
+ if global_options[:xmpp]
198
+ Blather.logger = logger
199
+ end
200
+
201
+ if global_options[:debug]
202
+ Logging.logger.root.level = :debug
203
+ else
204
+ Logging.consolidate 'OmfCommon', 'OmfEc', 'OmfRc'
205
+ end
206
+
207
+ # Import private key
208
+ if global_options[:private_key]
209
+ OmfCommon::Key.instance.import(global_options[:private_key])
210
+ end
211
+
212
+ # Check version
213
+ if options[:check]
214
+ File.open(args[0], 'r') do |f|
215
+ f.read.chomp.match(/OMF_VERSIONS\W*=\W*(.*)/)
216
+ versions = $1
217
+ unless versions && versions.split(',').include?(OmfCommon::PROTOCOL_VERSION)
218
+ raise StandardError, "Could not find compatibile protocol version number in your script"
219
+ end
220
+ end
221
+ end
222
+
223
+ include OmfEc::DSL
224
+
225
+ OmfEc.exp.name = options[:experiment] if options[:experiment]
226
+ OmfEc.exp.oml_uri = options[:oml_uri] if options[:oml_uri]
227
+
228
+ if global_options[:log_file_dir] && File.exist?(global_options[:log_file_dir])
229
+ Logging.logger.root.add_appenders(
230
+ Logging.appenders.file(
231
+ "#{global_options[:log_file_dir]}/#{OmfEc.exp.id}.log",
232
+ :layout => Logging.layouts.pattern(:date_pattern => '%F %T %z',
233
+ :pattern => '[%d] %-5l %c: %m\n')))
234
+ end
235
+
236
+ @testbed_exp_path = File.join(OmfEc.lib_root, "omf_ec/backward/exp/testbed.rb")
237
+ end
238
+
239
+ def load_exp(exp_path, global_options = {} , options = {})
240
+ begin
241
+ OmfEc.comm.when_ready do
242
+ logger.info "Connected: #{OmfEc.comm.jid.inspect}"
243
+ logger.info "Start experiment: #{OmfEc.exp.id}"
244
+ begin
245
+ include OmfEc::Backward::DefaultEvents
246
+ load exp_path
247
+ rescue => e
248
+ logger.error e.message
249
+ logger.error e.backtrace.join("\n")
250
+ end
251
+ end
252
+
253
+ EM.run do
254
+ OmfEc.comm.connect(global_options[:user], global_options[:password], global_options[:server])
255
+ trap(:INT) { Experiment.done }
256
+ trap(:TERM) { Experiment.done }
257
+ end
258
+ rescue => e
259
+ logger.fatal e.message
260
+ logger.fatal e.backtrace.join("\n")
261
+ end
262
+ end
263
+
264
+ exit run(ARGV)
@@ -0,0 +1,52 @@
1
+ # OMF_VERSIONS = 6.0
2
+ #
3
+ # :num_of_garage can be passed in from EC command line
4
+ defProperty('num_of_garage', 1, 'Number of garage to start')
5
+
6
+ garages = (1..prop.num_of_garage).map { |i| "garage_#{i}" }
7
+
8
+ defEvent :all_engines_up do |state|
9
+ # state holds list of resources, and automatically updated once OMF inform messages received.
10
+ state.find_all do |v|
11
+ v[:type] == 'engine'
12
+ end.size >= prop.num_of_garage
13
+ end
14
+
15
+ defEvent :rpm_reached do |state|
16
+ state.find_all do |v|
17
+ v[:type] == 'engine' && v[:rpm] && v[:rpm] >= 4000
18
+ end.size >= prop.num_of_garage
19
+ end
20
+
21
+ # Define a group and add garages to it.
22
+ defGroup('many_garages', *garages)
23
+
24
+ # :ALL_UP is a pre-defined event,
25
+ # triggered when all resources set to be part of groups are available and configured as members of the associated groups.
26
+ onEvent :ALL_UP do
27
+ group('many_garages') do |g|
28
+ g.create_resource('primary_engine', type: 'engine', sn: "<%= rand(1000) %>")
29
+
30
+ onEvent :all_engines_up do
31
+ info "Accelerating all engines"
32
+ g.resources[type: 'engine'][name: 'primary_engine'].throttle = 40
33
+
34
+ g.resources[type: 'engine'][name: 'primary_engine'].sn
35
+
36
+ g.resources[type: 'engine'][name: 'primary_engine'].failure
37
+ end
38
+
39
+ onEvent :rpm_reached do
40
+ info "All engines RPM reached 4000"
41
+ info "Release All engines throttle"
42
+ g.resources[type: 'engine'].throttle = 0
43
+
44
+ after 7.seconds do
45
+ info "Shutting ALL engines off"
46
+ g.resources[type: 'engine'].release
47
+
48
+ Experiment.done
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,90 @@
1
+ # OMF_VERSIONS = 6.0
2
+
3
+ @comm = OmfEc.comm
4
+
5
+ # @comm is default communicator defined in script runner
6
+ #
7
+ garage_id = "garage_1"
8
+ garage_topic = @comm.get_topic(garage_id)
9
+
10
+ garage_topic.on_message lambda {|m| m.operation == :inform && m.read_content('inform_type') == 'FAILED' } do |message|
11
+ logger.error message
12
+ end
13
+
14
+ msgs = {
15
+ create: @comm.create_message([type: 'mp4']),
16
+ request: @comm.request_message([:max_rpm, {:provider => {country: 'japan'}}, :max_power]),
17
+ request_rpm: @comm.request_message([:rpm]),
18
+ increase_throttle: @comm.configure_message([throttle: 50]),
19
+ reduce_throttle: @comm.configure_message([throttle: 0]),
20
+ test_error_handling: @comm.request_message([:error]),
21
+ }
22
+
23
+ msgs[:test_error_handling].on_inform_failed do |message|
24
+ logger.error message.read_content("reason")
25
+ end
26
+
27
+ msgs[:create].on_inform_failed do |message|
28
+ logger.error "Resource creation failed ---"
29
+ logger.error message.read_content("reason")
30
+ end
31
+
32
+ msgs[:request].on_inform_status do |message|
33
+ message.each_property do |p|
34
+ logger.info "#{p.attr('key')} => #{p.content.strip}"
35
+ end
36
+ end
37
+
38
+ msgs[:request].on_inform_failed do |message|
39
+ logger.error message.read_content("reason")
40
+ end
41
+
42
+ msgs[:request_rpm].on_inform_status do |message|
43
+ message.each_property do |p|
44
+ logger.info "#{p.attr('key')} => #{p.content.strip}"
45
+ end
46
+ end
47
+
48
+ # Triggered when new messages published to the topics I subscribed to
49
+ msgs[:create].on_inform_created do |message|
50
+ engine_topic = @comm.get_topic(message.resource_id)
51
+ engine_id = engine_topic.id
52
+
53
+ msgs[:release] ||= @comm.release_message { |m| m.element('resource_id', engine_id) }
54
+
55
+ msgs[:release].on_inform_released do |message|
56
+ logger.info "Engine (#{message.resource_id}) turned off (resource released)"
57
+ done!
58
+ end
59
+
60
+ logger.info "Engine #{engine_id} ready for testing"
61
+
62
+ engine_topic.subscribe do
63
+ # Now subscribed to engine topic, we can ask for some information about the engine
64
+ msgs[:request].publish engine_id
65
+
66
+ # We will check engine's RPM
67
+ msgs[:request_rpm].publish engine_id
68
+
69
+ # Now we will apply 50% throttle to the engine
70
+ msgs[:increase_throttle].publish engine_id
71
+
72
+ @comm.add_timer(5) do
73
+ # Some time later, we want to reduce the throttle to 0, to avoid blowing up the engine
74
+ msgs[:reduce_throttle].publish engine_id
75
+
76
+ # Testing error handling
77
+ msgs[:test_error_handling].publish engine_id
78
+ end
79
+
80
+ # 10 seconds later, we will 'release' this engine, i.e. shut it down
81
+ @comm.add_timer(10) do
82
+ msgs[:release].publish garage_id
83
+ end
84
+ end
85
+ end
86
+
87
+ garage_topic.subscribe do
88
+ # If subscribed, we publish a 'create' message, 'create' a new engine for testing
89
+ msgs[:create].publish garage_topic.id
90
+ end
@@ -0,0 +1,12 @@
1
+ # We can use communicator to interact with XMPP server
2
+ #
3
+ # Find all top level pubsub nodes
4
+ host = "pubsub.#{OmfEc.comm.jid.domain}"
5
+
6
+ OmfEc.comm.discover('items', host, '') do |m|
7
+ m.items.each { |i| info i.node }
8
+ info "Found #{m.items.size} items"
9
+ end
10
+
11
+ done!
12
+
@@ -0,0 +1,22 @@
1
+ #
2
+ # Test 1
3
+ #
4
+ # Testing one node in one group running one exec command for an already installed app
5
+ #
6
+ defProperty('res1', "unconfigured-node-1", "ID of a node")
7
+ defProperty('res2', "unconfigured-node-2", "ID of a node")
8
+
9
+ defGroup('Actor', property.res1, property.res2)
10
+ defGroup('Bob', property.res1, property.res2)
11
+
12
+ onEvent(:ALL_UP) do
13
+ wait 3
14
+ info "TEST - allGroups"
15
+ allGroups.exec("/bin/date")
16
+
17
+ wait 3
18
+ info "TEST - group"
19
+ group("Actor").exec("/bin/hostname -f")
20
+
21
+ Experiment.done
22
+ end
@@ -0,0 +1,30 @@
1
+ #
2
+ # Test 2
3
+ #
4
+ # Testing 2 nodes in multiple groups running exec commandis for already installed apps
5
+ #
6
+
7
+ defProperty('res1', "node1", "ID of a node")
8
+ defProperty('res2', "node2", "ID of a node")
9
+
10
+ defGroup('Alice', property.res1)
11
+ defGroup('Bob', property.res2)
12
+ defGroup('Couple', property.res1, property.res2)
13
+ defGroup('GroupOfGroup', "Alice", "Bob")
14
+
15
+ onEvent(:ALL_UP) do
16
+ wait 5
17
+ info "-------------"
18
+ info "TEST - Group of 2 (res1,res2)"
19
+ group("Couple").exec("/bin/hostname")
20
+ wait 5
21
+ info "---------------------"
22
+ info "TEST - Group of Group ( (res1) and (res2) )"
23
+ group("GroupOfGroup").exec("/bin/hostname")
24
+ wait 5
25
+ info "---------------"
26
+ info "TEST - allGroup"
27
+ allGroups.exec("/bin/hostname")
28
+ wait 5
29
+ Experiment.done
30
+ end
@@ -45,51 +45,11 @@ onEvent(:ALL_UP_AND_INSTALLED) do |event|
45
45
  allGroups.startApplications
46
46
  wait 10
47
47
  info "TEST - Running ifconfig on Sender"
48
- group('Sender').exec("ifconfig")
48
+ group('Sender').exec("/sbin/ifconfig")
49
49
  wait 15
50
50
  info "TEST - Running ifconfig on Receiver"
51
- group('Receiver').exec("ifconfig")
51
+ group('Receiver').exec("/sbin/ifconfig")
52
52
  wait 15
53
53
  allGroups.stopApplications
54
54
  Experiment.done
55
55
  end
56
-
57
-
58
- #
59
- # Checking the Execution
60
- # Here you do whatever is required to check that the above experiment went well
61
- # Then return true if you decided that it did, or false otherwise
62
- #
63
- # Experiment log file is at: property.logpath
64
- # Also you may want to look at system:exp:testlib
65
- #
66
-
67
- def check_outcome
68
-
69
- # Test 03 is successfull if all of the following are true:
70
- # 1) each resource reports that all its wireless property were configured OK
71
- # 2) the applications (OTG,OTR,execs) started and finished properly
72
- # file has a message from the AgentCommands module containing "DONE.OK"
73
- # 3) a SQ3 database is produced with some entries in the OTG and OTR tables
74
- logfile = "#{property.logpath}/#{Experiment.ID}.log"
75
- lines = IO.readlines("#{logfile}")
76
- # 1)
77
- match1 = lines.grep(/CONFIGURED\.OK/)
78
- r1 = (match1.length >= 10) ? true : false
79
- # 2)
80
- match1 = lines.grep(/APP_EVENT\ STARTED/)
81
- r2 = (match1.length == 4) ? true : false
82
- match1 = lines.grep(/APP_EVENT DONE\.OK/)
83
- match2 = match1.grep(/AgentCommands/)
84
- r3 = (match2.length == 4) ? true : false
85
- # 3)
86
- cnt1 = cnt2 = 0
87
- ms('udp_out').project(:oml_ts_server).each { |x| cnt1 =+1 }
88
- ms('udp_in').project(:oml_ts_server).each { |x| cnt2 =+1 }
89
- r4 = (cnt1 >= 1) ? true : false
90
- r5 = (cnt2 >= 1) ? true : false
91
-
92
- puts "Check Outcome [r1:#{r1} - r2:#{r2} - r3:#{r3} - r4:#{r4} - r5:#{r5}]"
93
- return true if r1 && r2 && r3 && r4 && r5
94
- return false
95
- end
@@ -79,7 +79,7 @@ def check_outcome
79
79
  # 1)
80
80
  match1 = lines.grep(/CONFIGURED\.OK/)
81
81
  r1 = (match1.length >= 10) ? true : false
82
- # 2)
82
+ # 2)
83
83
  match1 = lines.grep(/APP_EVENT\ STARTED/)
84
84
  r2 = (match1.length == 2) ? true : false
85
85
  match1 = lines.grep(/APP_EVENT DONE\.OK/)
@@ -93,7 +93,7 @@ def check_outcome
93
93
  r5 = (cnt2 >= 1) ? true : false
94
94
  # 4)
95
95
  max = PKTSIZE
96
- ms('udp_in').project(:pkt_length_max).each do |r|
96
+ ms('udp_in').project(:pkt_length_max).each do |r|
97
97
  value = r.tuple
98
98
  max = value[0]
99
99
  end
@@ -33,7 +33,7 @@ defGroup('Actor', property.res1) {|n|
33
33
  app.setProperty('arg2', 'DEF') # Displays "--arg2 DEF"
34
34
  app.setProperty('arg3', property.pboolean) # Displays "-b"
35
35
  app.setProperty('arg4', true) # Displays "--arg4"
36
- app.setProperty('arg5', false) # Displays nothing
36
+ app.setProperty('arg5', false) # Displays nothing
37
37
  app.setProperty('arg6', property.pinteger) # Displays "-i 123" in second position!
38
38
  app.setProperty('arg7', 456) # Displays "--arg7 456"
39
39
  app.setProperty('arg8', "ZZZ") # Displays "ZZZ"
@@ -61,8 +61,8 @@ end
61
61
  def check_outcome
62
62
 
63
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
64
+ # 1) the tarball is installed OK AND the application runs OK
65
+ # 2) the application outputs the correct payload from the tarball
66
66
  # 3) the application accepts and outputs the correct arguments
67
67
  logfile = "#{property.logpath}/#{Experiment.ID}.log"
68
68
  lines = IO.readlines("#{logfile}")
@@ -80,7 +80,7 @@ def check_outcome
80
80
  match2 = match1.grep(/AgentCommands/)
81
81
  r4 = (match2.length == 1) ? true : false
82
82
 
83
- puts "Check Outcome [r1:#{r1} - r2:#{r2} - r3:#{r3} - r4:#{r4}]"
83
+ puts "Check Outcome [r1:#{r1} - r2:#{r2} - r3:#{r3} - r4:#{r4}]"
84
84
  return true if r1 && r2 && r3 && r4
85
85
  return false
86
86
 
@@ -18,8 +18,8 @@ defApplication('nmapURI', 'nmap') { |app|
18
18
 
19
19
  defGroup('Actor', property.res1) {|n|
20
20
  n.addApplication("nmapURI") {|app|
21
- app.setProperty('target', "127.0.0.1")
22
- app.setProperty('port', '101-200')
21
+ app.setProperty('target', "127.0.0.1")
22
+ app.setProperty('port', '101-200')
23
23
  }
24
24
  }
25
25
 
@@ -49,19 +49,19 @@ def check_outcome
49
49
  # Test 06 is successfull if:
50
50
  # 1) the application nmap has been unpacked on the resource
51
51
  # AND
52
- # 2) for the Actor group, the log file has a message from the AgentCommands
52
+ # 2) for the Actor group, the log file has a message from the AgentCommands
53
53
  # module containing "DONE.OK" for the install of the app, and for the app
54
54
  # execution
55
55
 
56
- # Test 06 is successfull if for each of the 2 exec commands above, the log
56
+ # Test 06 is successfull if for each of the 2 exec commands above, the log
57
57
  # file has a message from the AgentCommands module containing "DONE.OK"
58
58
  logfile = "#{property.logpath}/#{Experiment.ID}.log"
59
59
  lines = IO.readlines("#{logfile}")
60
- # 1)
60
+ # 1)
61
61
  match1 = lines.grep(/Unpacking\ nmap/)
62
62
  match2 = match1.grep(/AgentCommands/)
63
63
  result1 = (match2.length == 1) ? true : false
64
- # 2)
64
+ # 2)
65
65
  match1 = lines.grep(/DONE\.OK/)
66
66
  match2 = match1.grep(/AgentCommands/)
67
67
  result2 = (match2.length >= 2) ? true : false
@@ -0,0 +1,65 @@
1
+ #
2
+ # Test 7
3
+ #
4
+ # Testing one node in one group running two instance of the same app,
5
+ # previously defined with defApplication
6
+ #
7
+ # NOTE: in this example, while the defApp contains measurement point (MP)
8
+ # definitions, these are not collected/enabled in the addApp using this
9
+ # defined app. This is because here we simply use ping, which does not
10
+ # have OML MPs... thus enabling these MPs will result in a command line
11
+ # error when trying to run ping.
12
+ #
13
+
14
+ defProperty('res1', "unconfigured-node-1", "ID of a node")
15
+
16
+ defApplication('ping','ping') do |app|
17
+ app.description = 'Simple App Def for Ping'
18
+ app.binary_path = '/bin/ping'
19
+
20
+ # OMF 5.4 SYNTAX
21
+ #
22
+ app.defProperty('target', "my target", nil, {:type => :string, :default => 'localhost'})
23
+ app.defProperty('count', "my count", "-c", {:type => :integer, :default => 2, :order => 1})
24
+
25
+ app.defMeasurement('ping_delay') do |m|
26
+ m.defMetric('sequence', 'Fixnum')
27
+ m.defMetric('destination', 'String')
28
+ m.defMetric('rtt', 'Fixnum')
29
+ end
30
+
31
+ app.defMeasurement('ping_loss') do |m|
32
+ m.defMetric('destination', 'String')
33
+ m.defMetric('probe_count', 'Fixnum')
34
+ m.defMetric('loss', 'Fixnum')
35
+ end
36
+
37
+ # OMF 6 SYNTAX
38
+ #
39
+ # app.define_parameter(
40
+ # :target => {:type => 'String', :default => 'localhost'},
41
+ # :count => {:type => 'Numeric', :cmd => '-c', :default => 2, :order => 1}
42
+ # )
43
+ end
44
+
45
+ defGroup('Actor', property.res1) do |g|
46
+ g.addApplication("ping") do |app|
47
+ app.setProperty('target', 'www.google.com')
48
+ app.setProperty('count', 1)
49
+ #app.measure('ping_delay', :interval => 3)
50
+ end
51
+ g.addApplication("ping") do |app|
52
+ app.setProperty('target', 'www.nicta.com.au')
53
+ app.setProperty('count', 2)
54
+ #app.measure('ping_loss', :samples => 10)
55
+ end
56
+
57
+ end
58
+
59
+ onEvent(:ALL_UP_AND_INSTALLED) do |event|
60
+ info "TEST - group"
61
+ group("Actor").startApplications
62
+ after 1.seconds do
63
+ Experiment.done
64
+ end
65
+ end