mu 5.7.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Mu_Gem.html +1591 -0
- data/bin/mu +11 -0
- data/lib/mu.rb +65 -0
- data/lib/mu/api/ddt.rb +233 -0
- data/lib/mu/api/homepage.rb +54 -0
- data/lib/mu/api/muapi.rb +231 -0
- data/lib/mu/api/netconfig.rb +233 -0
- data/lib/mu/api/scale.rb +199 -0
- data/lib/mu/api/system.rb +40 -0
- data/lib/mu/client.rb +31 -0
- data/lib/mu/command.rb +28 -0
- data/lib/mu/command/api.rb +95 -0
- data/lib/mu/command/cmd_appid.rb +486 -0
- data/lib/mu/command/cmd_cli.rb +151 -0
- data/lib/mu/command/cmd_ddt.rb +449 -0
- data/lib/mu/command/cmd_homepage.rb +146 -0
- data/lib/mu/command/cmd_muapi.rb +361 -0
- data/lib/mu/command/cmd_netconfig.rb +262 -0
- data/lib/mu/command/cmd_runscale.rb +533 -0
- data/lib/mu/command/cmd_runscenario.rb +258 -0
- data/lib/mu/command/cmd_runverify.rb +336 -0
- data/lib/mu/command/cmd_scale.rb +333 -0
- data/lib/mu/command/cmd_system.rb +127 -0
- data/lib/mu/command/curl.rb +246 -0
- data/lib/mu/command/help.rb +29 -0
- data/lib/mu/curl/error.rb +54 -0
- data/lib/mu/curl/verify.rb +137 -0
- data/lib/mu/helper.rb +55 -0
- data/lib/mu/http_helper.rb +232 -0
- data/rdoc/classes/Mu.html +305 -0
- data/rdoc/classes/Mu/Client.html +265 -0
- data/rdoc/classes/Mu/Command.html +208 -0
- data/rdoc/classes/Mu/Command/API.html +524 -0
- data/rdoc/classes/Mu/Command/Cmd_appid.html +934 -0
- data/rdoc/classes/Mu/Command/Cmd_cli.html +515 -0
- data/rdoc/classes/Mu/Command/Cmd_ddt.html +1169 -0
- data/rdoc/classes/Mu/Command/Cmd_homepage.html +489 -0
- data/rdoc/classes/Mu/Command/Cmd_muapi.html +968 -0
- data/rdoc/classes/Mu/Command/Cmd_netconfig.html +743 -0
- data/rdoc/classes/Mu/Command/Cmd_runscale.html +970 -0
- data/rdoc/classes/Mu/Command/Cmd_runscenario.html +530 -0
- data/rdoc/classes/Mu/Command/Cmd_runverify.html +621 -0
- data/rdoc/classes/Mu/Command/Cmd_scale.html +939 -0
- data/rdoc/classes/Mu/Command/Cmd_system.html +426 -0
- data/rdoc/classes/Mu/Command/Curl.html +524 -0
- data/rdoc/classes/Mu/Command/Help.html +166 -0
- data/rdoc/classes/Mu/Curl.html +116 -0
- data/rdoc/classes/Mu/Curl/Error.html +157 -0
- data/rdoc/classes/Mu/Curl/Error/Authorize.html +178 -0
- data/rdoc/classes/Mu/Curl/Error/Connect.html +149 -0
- data/rdoc/classes/Mu/Curl/Error/DNS.html +113 -0
- data/rdoc/classes/Mu/Curl/Error/Region.html +160 -0
- data/rdoc/classes/Mu/Curl/Error/Status.html +149 -0
- data/rdoc/classes/Mu/Curl/Error/Timeout.html +149 -0
- data/rdoc/classes/Mu/Curl/Verify.html +282 -0
- data/rdoc/classes/Mu/Curl/Verify/Request.html +227 -0
- data/rdoc/classes/Mu/Curl/Verify/Response.html +187 -0
- data/rdoc/classes/Mu/Curl/Verify/Result.html +188 -0
- data/rdoc/classes/Mu/Ddt.html +914 -0
- data/rdoc/classes/Mu/Helper.html +308 -0
- data/rdoc/classes/Mu/Homepage.html +377 -0
- data/rdoc/classes/Mu/HttpHelper.html +639 -0
- data/rdoc/classes/Mu/Muapi.html +816 -0
- data/rdoc/classes/Mu/Netconfig.html +781 -0
- data/rdoc/classes/Mu/Scale.html +832 -0
- data/rdoc/classes/Mu/System.html +281 -0
- data/rdoc/classes/Object.html +148 -0
- data/rdoc/classes/TCTestMu.html +1793 -0
- data/rdoc/classes/Test.html +107 -0
- data/rdoc/classes/Test/Unit.html +107 -0
- data/rdoc/classes/Test/Unit/TestCase.html +113 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/lib/mu/api/ddt_rb.html +101 -0
- data/rdoc/files/lib/mu/api/homepage_rb.html +101 -0
- data/rdoc/files/lib/mu/api/muapi_rb.html +101 -0
- data/rdoc/files/lib/mu/api/netconfig_rb.html +101 -0
- data/rdoc/files/lib/mu/api/scale_rb.html +101 -0
- data/rdoc/files/lib/mu/api/system_rb.html +101 -0
- data/rdoc/files/lib/mu/client_rb.html +101 -0
- data/rdoc/files/lib/mu/command/api_rb.html +101 -0
- data/rdoc/files/lib/mu/command/cmd_appid_rb.html +119 -0
- data/rdoc/files/lib/mu/command/cmd_cli_rb.html +108 -0
- data/rdoc/files/lib/mu/command/cmd_ddt_rb.html +117 -0
- data/rdoc/files/lib/mu/command/cmd_homepage_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_muapi_rb.html +116 -0
- data/rdoc/files/lib/mu/command/cmd_netconfig_rb.html +116 -0
- data/rdoc/files/lib/mu/command/cmd_runscale_rb.html +119 -0
- data/rdoc/files/lib/mu/command/cmd_runscenario_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_runverify_rb.html +117 -0
- data/rdoc/files/lib/mu/command/cmd_scale_rb.html +115 -0
- data/rdoc/files/lib/mu/command/cmd_system_rb.html +116 -0
- data/rdoc/files/lib/mu/command/curl_rb.html +101 -0
- data/rdoc/files/lib/mu/command/help_rb.html +101 -0
- data/rdoc/files/lib/mu/command_rb.html +107 -0
- data/rdoc/files/lib/mu/curl/error_rb.html +101 -0
- data/rdoc/files/lib/mu/curl/verify_rb.html +101 -0
- data/rdoc/files/lib/mu/helper_rb.html +101 -0
- data/rdoc/files/lib/mu/http_helper_rb.html +101 -0
- data/rdoc/files/lib/mu_rb.html +121 -0
- data/rdoc/files/test/helper_rb.html +112 -0
- data/rdoc/files/test/tc_test_mu_rb.html +111 -0
- data/rdoc/fr_class_index.html +68 -0
- data/rdoc/fr_file_index.html +55 -0
- data/rdoc/fr_method_index.html +374 -0
- data/rdoc/index.html +24 -0
- data/rdoc/rdoc-style.css +208 -0
- data/test/data/app_id_stats.csv +1 -0
- data/test/data/data_cgi.msl +94 -0
- data/test/data/data_cgi.xml +322 -0
- data/test/data/default_test.csv +3 -0
- data/test/data/ftp_with_channel.xml +1643 -0
- data/test/data/irc.xml +3837 -0
- data/test/data/scale_configuration.json +25 -0
- data/test/data/test_data_cgi_error.xml +35 -0
- data/test/helper.rb +18 -0
- data/test/tc_test_mu.rb +716 -0
- metadata +322 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
# Api methods to access the Mu CLI calls
|
2
|
+
class Mu
|
3
|
+
class Command
|
4
|
+
class Cmd_cli < Command
|
5
|
+
|
6
|
+
attr_accessor :host, :username, :password, :api
|
7
|
+
|
8
|
+
# displays command-line help
|
9
|
+
def cmd_help argv
|
10
|
+
help
|
11
|
+
end
|
12
|
+
|
13
|
+
# runs the cli help command
|
14
|
+
# * argv = command-line arguments
|
15
|
+
def cmd_cli_help argv
|
16
|
+
setup argv
|
17
|
+
msg run_cmd("help")
|
18
|
+
end
|
19
|
+
|
20
|
+
# runs the cli command '?"
|
21
|
+
# * argv = command-line arguments
|
22
|
+
def cmd_question argv
|
23
|
+
setup argv
|
24
|
+
msg run_cmd("?")
|
25
|
+
end
|
26
|
+
|
27
|
+
# displays the command line history for the current session
|
28
|
+
# * argv = command-line arguments
|
29
|
+
def cmd_history argv
|
30
|
+
setup argv
|
31
|
+
msg run_cmd("history")
|
32
|
+
end
|
33
|
+
|
34
|
+
# pings an ip address
|
35
|
+
# * argv = command-line arguments, requires an ip address (-a) argument
|
36
|
+
def cmd_ping argv
|
37
|
+
setup argv
|
38
|
+
addr = @hash["address"]
|
39
|
+
msg run_cmd("ping #{addr}")
|
40
|
+
end
|
41
|
+
|
42
|
+
# runs traceroute on an ip address
|
43
|
+
# * argv = command-line arguments, requires an ip address (-a) argument
|
44
|
+
def cmd_traceroute argv
|
45
|
+
setup argv
|
46
|
+
addr = @hash["address"]
|
47
|
+
msg run_cmd("traceroute #{addr}")
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
# runs the cli command
|
53
|
+
def run_cmd(command, prompt=@prompt)
|
54
|
+
msg "run command #{command}"
|
55
|
+
@pipe.write("#{command}\r")
|
56
|
+
response = @pipe.readline(prompt)
|
57
|
+
@pipe.close
|
58
|
+
return response
|
59
|
+
end
|
60
|
+
|
61
|
+
def setup argv
|
62
|
+
parse_cli argv
|
63
|
+
@host = (@@mu_ip.nil?) ? "127.0.0.1" : @@mu_ip
|
64
|
+
@username = (@@mu_admin_user.nil?) ? "admin" : @@mu_admin_user
|
65
|
+
@password = (@@mu_admin_pass.nil?) ? "admin" : @@mu_admin_pass
|
66
|
+
@prompt = "MU>"
|
67
|
+
@pipe = IO.popen("./lib/mu/cli/muclish.tcl #{@host} #{@password} '#{@prompt}'", 'w+')
|
68
|
+
@pipe.sync = true
|
69
|
+
@banner = @pipe.readline(@prompt)
|
70
|
+
end
|
71
|
+
|
72
|
+
def parse_cli argv
|
73
|
+
@hash = {}
|
74
|
+
args = Array.new
|
75
|
+
while not argv.empty?
|
76
|
+
args << argv.shift if argv.first[0,1] != '-'
|
77
|
+
|
78
|
+
k = argv.shift
|
79
|
+
|
80
|
+
if [ '-a', '--address' ].member? k
|
81
|
+
@hash['address'] = shift(k, argv)
|
82
|
+
next
|
83
|
+
end
|
84
|
+
|
85
|
+
if [ '-h', '--help' ].member? k
|
86
|
+
help
|
87
|
+
exit
|
88
|
+
end
|
89
|
+
|
90
|
+
if [ '-m', '--mu_string' ].member? k
|
91
|
+
mu_string = shift(k, argv)
|
92
|
+
if mu_string =~ /(.+?):(.+?)@(.*)/
|
93
|
+
@@mu_admin_user = $1
|
94
|
+
@@mu_admin_pass = $2
|
95
|
+
@@mu_ip = $3
|
96
|
+
end
|
97
|
+
next
|
98
|
+
end
|
99
|
+
|
100
|
+
if [ '-o', '--output' ].member? k
|
101
|
+
$stdout.reopen(shift(k, argv), "w")
|
102
|
+
next
|
103
|
+
end
|
104
|
+
|
105
|
+
if [ '-v', '--verbose' ].member? k
|
106
|
+
$log.level = Logger::DEBUG
|
107
|
+
next
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
args
|
113
|
+
end
|
114
|
+
|
115
|
+
def help
|
116
|
+
helps = [
|
117
|
+
{ :short => '-a', :long => '--address', :value => '<string', :help => 'ip address to for ping or traceroute' },
|
118
|
+
{ :short => '-h', :long => '--help', :value => '', :help => 'Help on command line options' },
|
119
|
+
{ :short => '-o', :long => '--output', :value => '<string>', :help => 'output logging to this file' },
|
120
|
+
{ :short => '-m', :long => '--mu_string', :value => '<string>', :help => 'user, password, mu_ip in the form of admin:admin@10.9.8.7' },
|
121
|
+
{ :short => '-v', :long => '--verbose', :value => '', :help => 'set Logger::DEBUG level' }
|
122
|
+
]
|
123
|
+
|
124
|
+
cmds = [
|
125
|
+
"mu cmd_cli:cli_help",
|
126
|
+
"mu cmd_cli:history",
|
127
|
+
"mu cmd_cli:ping -a <address>",
|
128
|
+
"mu cmd_cli:question",
|
129
|
+
"mu cmd_cli:traceroute -a <address>",
|
130
|
+
]
|
131
|
+
|
132
|
+
max_long_size = helps.inject(0) { |memo, obj| [ obj[:long].size, memo ].max }
|
133
|
+
max_value_size = helps.inject(0) { |memo, obj| [ obj[:value].size, memo ].max }
|
134
|
+
puts
|
135
|
+
puts "Usage: mu cmd_cli:<command> <options>"
|
136
|
+
puts
|
137
|
+
helps.each do |h|
|
138
|
+
puts "%-*s %*s %-*s %s" % [max_long_size, h[:long], 2, h[:short], max_value_size, h[:value], h[:help]]
|
139
|
+
end
|
140
|
+
puts
|
141
|
+
puts "Available Commands"
|
142
|
+
puts
|
143
|
+
cmds.each do | c |
|
144
|
+
puts c
|
145
|
+
end
|
146
|
+
puts
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end # Command
|
151
|
+
end # Mu
|
@@ -0,0 +1,449 @@
|
|
1
|
+
# Use these commands to access the legacy REST API for Test Sets (Studio Verify).
|
2
|
+
# Until import_csv is implemented, the .csv file must exist on the Mu System and include a UUID.
|
3
|
+
|
4
|
+
require 'mu/api/ddt'
|
5
|
+
class Mu
|
6
|
+
class Command
|
7
|
+
class Cmd_ddt < Command
|
8
|
+
|
9
|
+
attr_accessor :host, :username, :password, :api, :hash
|
10
|
+
|
11
|
+
# displays command-line help
|
12
|
+
# * argv = command-line arguments
|
13
|
+
def cmd_help argv
|
14
|
+
help
|
15
|
+
end
|
16
|
+
|
17
|
+
# verifies the loaded scenario
|
18
|
+
# * argv = command-line arguments
|
19
|
+
def cmd_run argv
|
20
|
+
setup argv
|
21
|
+
response = @api.run
|
22
|
+
msg response
|
23
|
+
return response
|
24
|
+
end
|
25
|
+
|
26
|
+
# runs the loaded scenario and testset
|
27
|
+
# * argv = command-line arguments, requires a uuid (-u) argument
|
28
|
+
def cmd_run_testset argv
|
29
|
+
setup argv
|
30
|
+
uuid = @hash['uuid']
|
31
|
+
response = @api.run_testset(uuid)
|
32
|
+
msg response
|
33
|
+
return response
|
34
|
+
end
|
35
|
+
|
36
|
+
# creates a new Studio Verify session
|
37
|
+
# * argv = command-line arguments
|
38
|
+
def cmd_new_session argv
|
39
|
+
setup argv
|
40
|
+
response = @api.new_session
|
41
|
+
msg response
|
42
|
+
return response
|
43
|
+
end
|
44
|
+
|
45
|
+
# closes the currently active Studio Verify session
|
46
|
+
# * argv = command-line arguments
|
47
|
+
def cmd_close_session argv
|
48
|
+
setup argv
|
49
|
+
response = @api.close_session
|
50
|
+
msg response
|
51
|
+
return response
|
52
|
+
end
|
53
|
+
|
54
|
+
# returns an array of current Studio Verify session id's
|
55
|
+
# * argv = command-line arguments
|
56
|
+
def cmd_get_sessions argv
|
57
|
+
setup argv
|
58
|
+
response = @api.get_sessions
|
59
|
+
msg response
|
60
|
+
return response
|
61
|
+
end
|
62
|
+
|
63
|
+
# closes all existing Studio Verify sessions# * command-line args
|
64
|
+
# * argv = command-line arguments
|
65
|
+
def cmd_close_all_sessions argv
|
66
|
+
setup argv
|
67
|
+
response = @api.close_all_sessions
|
68
|
+
msg response
|
69
|
+
return response
|
70
|
+
end
|
71
|
+
|
72
|
+
# returns all Studio Verify sessions
|
73
|
+
# * argv = command-line arguments
|
74
|
+
def cmd_get_all_sessions argv
|
75
|
+
setup argv
|
76
|
+
response = @api.get_all_sessions
|
77
|
+
msg response
|
78
|
+
return response
|
79
|
+
end
|
80
|
+
|
81
|
+
# sets up a test session
|
82
|
+
# * argv = command-line arguments
|
83
|
+
def cmd_setup_test argv
|
84
|
+
setup argv
|
85
|
+
response = @api.setup_test
|
86
|
+
msg response
|
87
|
+
return response
|
88
|
+
end
|
89
|
+
|
90
|
+
# tears down a test session
|
91
|
+
# * argv = command-line arguments
|
92
|
+
def cmd_teardown_test argv
|
93
|
+
setup argv
|
94
|
+
response = @api.teardown_test
|
95
|
+
msg response
|
96
|
+
return response
|
97
|
+
end
|
98
|
+
|
99
|
+
# loads a Mu Studio scenario
|
100
|
+
# * argv = command-line arguments, requires the uuid (-u) argument, the uuid of a scenario that is already loaded on the Mu
|
101
|
+
def cmd_load_scenario argv
|
102
|
+
setup argv
|
103
|
+
uuid = @hash['uuid']
|
104
|
+
response = @api.load_scenario(uuid)
|
105
|
+
msg response
|
106
|
+
return response
|
107
|
+
end
|
108
|
+
|
109
|
+
# returns array of host hashmaps, e.g.
|
110
|
+
# [{"role"=>"192.168.30.188 (A1.V4)", "roleId"=>"host_0", "layer"=>"v4"}, {"role"=>"192.168.30.9 (dell-eth1.V4)", "roleId"=>"host_1", "layer"=>"v4"}]
|
111
|
+
# NOTE: the values of 'roleId' are what are passed to set_hosts as 'roles', not 'role'
|
112
|
+
# * argv = command-line arguments
|
113
|
+
def cmd_get_hosts argv
|
114
|
+
setup argv
|
115
|
+
response = @api.get_hosts
|
116
|
+
msg response
|
117
|
+
return response
|
118
|
+
end
|
119
|
+
|
120
|
+
# sets a Mu Studio scenario's host. takes an arrays of roles and names, e.g. ["h1", "h2"], ["a1", dell-9"]
|
121
|
+
# optional types array ["v4", "v4"]
|
122
|
+
# * argv = command-line arguments, requires an array of roles and names (and optionally, type). The roles must match those defined within the scenario
|
123
|
+
# * roles and names can be single-values or comma-separated lists.
|
124
|
+
# * type is a single value (v4, v6 or l2)
|
125
|
+
def cmd_set_hosts argv
|
126
|
+
setup argv
|
127
|
+
roles = @hash['roles']
|
128
|
+
names = @hash['names']
|
129
|
+
if @hash['type'].nil?
|
130
|
+
type = "v4"
|
131
|
+
else
|
132
|
+
type = @hash['type']
|
133
|
+
end
|
134
|
+
|
135
|
+
if names.include?(",")
|
136
|
+
names_array = names.split(",")
|
137
|
+
else
|
138
|
+
names_array = Array.new
|
139
|
+
names_array << names
|
140
|
+
end
|
141
|
+
|
142
|
+
if roles.include?(",")
|
143
|
+
roles_array = roles.split(",")
|
144
|
+
else
|
145
|
+
roles_array = Array.new
|
146
|
+
roles_array << roles
|
147
|
+
end
|
148
|
+
|
149
|
+
response = @api.set_hosts(roles_array, names_array, type)
|
150
|
+
msg response
|
151
|
+
return response
|
152
|
+
end
|
153
|
+
|
154
|
+
# returns the channel elements of a Mu Studio scenario
|
155
|
+
# * argv = command-line arguments
|
156
|
+
def cmd_get_channels argv
|
157
|
+
setup argv
|
158
|
+
response = @api.get_channels
|
159
|
+
msg response
|
160
|
+
return response
|
161
|
+
end
|
162
|
+
|
163
|
+
# sets the channel elements of a loaded scenario
|
164
|
+
# * argv = command-line arguments, requires arrays of roles and names. The roles must all be 'channel' and the names are names of valid hosts
|
165
|
+
# * roles and names can be single-values or comma-separated lists.
|
166
|
+
def cmd_set_channels argv
|
167
|
+
setup argv
|
168
|
+
roles = @hash['roles']
|
169
|
+
names = @hash['names']
|
170
|
+
|
171
|
+
if names.include?(",")
|
172
|
+
names_array = names.split(",")
|
173
|
+
else
|
174
|
+
names_array = Array.new
|
175
|
+
names_array << names
|
176
|
+
end
|
177
|
+
|
178
|
+
if roles.include?(",")
|
179
|
+
roles_array = roles.split(",")
|
180
|
+
else
|
181
|
+
roles_array = Array.new
|
182
|
+
roles_array << roles
|
183
|
+
end
|
184
|
+
|
185
|
+
response = @api.set_channels(roles_array, names_array)
|
186
|
+
msg response
|
187
|
+
return response
|
188
|
+
end
|
189
|
+
|
190
|
+
# returns array of options hashmap, consisting of name and value keys, e.g.
|
191
|
+
# [{"name"=>"io.timeout", "value"=>250}, {"name"=>"io.delay", "value"=>0}]
|
192
|
+
# * argv = command-line arguments
|
193
|
+
def cmd_get_options argv
|
194
|
+
setup argv
|
195
|
+
response = @api.get_options
|
196
|
+
msg response
|
197
|
+
return response
|
198
|
+
end
|
199
|
+
|
200
|
+
# sets the options of the loaded scenario
|
201
|
+
# * argv = command-line arguments, requires arrays of valid options names and values
|
202
|
+
# * names and values can be single-values or comma-separated lists.
|
203
|
+
def cmd_set_options argv
|
204
|
+
setup argv
|
205
|
+
names = @hash['names']
|
206
|
+
values = @hash['option_values']
|
207
|
+
|
208
|
+
if names.include?(",")
|
209
|
+
names_array = names.split(",")
|
210
|
+
else
|
211
|
+
names_array = Array.new
|
212
|
+
names_array << names
|
213
|
+
end
|
214
|
+
|
215
|
+
if values.include?(",")
|
216
|
+
values_array = values.split(",")
|
217
|
+
else
|
218
|
+
values_array = Array.new
|
219
|
+
values_array << values
|
220
|
+
end
|
221
|
+
|
222
|
+
response = @api.set_options(names_array, values_array)
|
223
|
+
msg response
|
224
|
+
return response
|
225
|
+
end
|
226
|
+
|
227
|
+
# returns the status of the current testset
|
228
|
+
# * argv = command-line arguments
|
229
|
+
def cmd_get_testset_status argv
|
230
|
+
setup argv
|
231
|
+
response = @api.get_testset_status
|
232
|
+
msg response
|
233
|
+
return response
|
234
|
+
end
|
235
|
+
|
236
|
+
# returns results from the current testset. can be called repeatedly during a test run.
|
237
|
+
# the end of a test is indicated by the presence of the word 'END' in the returned results array
|
238
|
+
# * argv = command-line arguments
|
239
|
+
def cmd_get_testset_results argv
|
240
|
+
setup argv
|
241
|
+
response = @api.get_testset_results
|
242
|
+
msg response
|
243
|
+
return response
|
244
|
+
end
|
245
|
+
|
246
|
+
# displays testset results
|
247
|
+
# * argv = command-line arguments
|
248
|
+
def cmd_display_results argv
|
249
|
+
setup argv
|
250
|
+
response = @api.results
|
251
|
+
msg response
|
252
|
+
return response
|
253
|
+
end
|
254
|
+
|
255
|
+
# exports a testset from Mu Studio to a csv file
|
256
|
+
# * argv = command-line arguments, requires a uuid (-u) argument that is the uuid of a testset on the Mu
|
257
|
+
def cmd_csv_export argv
|
258
|
+
setup argv
|
259
|
+
msg @api.new_session
|
260
|
+
uuid = @hash['uuid']
|
261
|
+
response = @api.csv_export(uuid)
|
262
|
+
@api.close_session
|
263
|
+
msg response
|
264
|
+
return response
|
265
|
+
end
|
266
|
+
|
267
|
+
# imports a csv-formatted testset to a Mu system
|
268
|
+
# * argv = command-line arguments, requires the csv testset file (-t)
|
269
|
+
def cmd_csv_import argv
|
270
|
+
setup argv
|
271
|
+
msg @api.new_session
|
272
|
+
testset_file = @hash['testset']
|
273
|
+
response = @api.csv_import(testset_file)
|
274
|
+
@api.close_session
|
275
|
+
msg response
|
276
|
+
return response
|
277
|
+
end
|
278
|
+
|
279
|
+
private
|
280
|
+
|
281
|
+
def setup argv
|
282
|
+
parse_cli argv
|
283
|
+
@host = (@@mu_ip.nil?) ? "127.0.0.1" : @@mu_ip
|
284
|
+
@username = (@@mu_admin_user.nil?) ? "admin" : @@mu_admin_user
|
285
|
+
@password = (@@mu_admin_pass.nil?) ? "admin" : @@mu_admin_pass
|
286
|
+
@cookie = ''
|
287
|
+
@testset = ''
|
288
|
+
@session_id = nil
|
289
|
+
@results = Array.new
|
290
|
+
@api = Ddt.new(@host, @username, @password)
|
291
|
+
msg "Created DdtApi object to :#{@host}", Logger::DEBUG
|
292
|
+
end
|
293
|
+
|
294
|
+
def parse_cli argv
|
295
|
+
args = Array.new
|
296
|
+
@hash = Hash.new
|
297
|
+
while not argv.empty?
|
298
|
+
args << argv.shift if argv.first[0,1] != '-'
|
299
|
+
|
300
|
+
k = argv.shift
|
301
|
+
|
302
|
+
if [ '-h', '--help' ].member? k
|
303
|
+
help
|
304
|
+
exit
|
305
|
+
end
|
306
|
+
|
307
|
+
if [ '-m', '--mu_string' ].member? k
|
308
|
+
mu_string = shift(k, argv)
|
309
|
+
if mu_string =~ /(.+?):(.+?)@(.*)/
|
310
|
+
@@mu_admin_user = $1
|
311
|
+
@@mu_admin_pass = $2
|
312
|
+
@@mu_ip = $3
|
313
|
+
end
|
314
|
+
next
|
315
|
+
end
|
316
|
+
|
317
|
+
if [ '-n', '--names' ].member? k
|
318
|
+
@hash['names'] = shift(k, argv)
|
319
|
+
next
|
320
|
+
end
|
321
|
+
|
322
|
+
if [ '-o', '--output' ].member? k
|
323
|
+
$stdout.reopen(shift(k, argv), "w")
|
324
|
+
next
|
325
|
+
end
|
326
|
+
|
327
|
+
if [ '-p', '--option_values' ].member? k
|
328
|
+
@hash['option_values'] = shift(k, argv)
|
329
|
+
next
|
330
|
+
end
|
331
|
+
|
332
|
+
if [ '-r', '--roles' ].member? k
|
333
|
+
@hash['roles'] = shift(k, argv)
|
334
|
+
next
|
335
|
+
end
|
336
|
+
|
337
|
+
if [ '-t', '--testset' ].member? k
|
338
|
+
@hash['testset'] = shift(k, argv)
|
339
|
+
next
|
340
|
+
end
|
341
|
+
|
342
|
+
if [ '-y', '--type' ].member? k
|
343
|
+
@hash['type'] = shift(k, argv)
|
344
|
+
next
|
345
|
+
end
|
346
|
+
|
347
|
+
if [ '-u', '--uuid' ].member? k
|
348
|
+
@hash['uuid'] = shift(k, argv)
|
349
|
+
next
|
350
|
+
end
|
351
|
+
|
352
|
+
if [ '-v', '--verbose' ].member? k
|
353
|
+
$log.level = Logger::DEBUG
|
354
|
+
next
|
355
|
+
end
|
356
|
+
|
357
|
+
end
|
358
|
+
|
359
|
+
args
|
360
|
+
end
|
361
|
+
|
362
|
+
def help
|
363
|
+
helps = [
|
364
|
+
{ :short => '-h', :long => '--help', :value => '', :help => 'help on command line options' },
|
365
|
+
{ :short => '-m', :long => '--mu_string', :value => '<string>', :help => 'user, password, mu_ip in the form of admin:admin@10.9.8.7' },
|
366
|
+
{ :short => '-n', :long => '--names', :value => '<string>', :help => 'comma-separated list of names used for set_hosts and set_channels' },
|
367
|
+
{ :short => '-o', :long => '--output', :value => '<string>', :help => 'output logging to this file' },
|
368
|
+
{ :short => '-p', :long => '--option_values', :value => '<string>', :help => 'coma-separated list of values array used for set_options' },
|
369
|
+
{ :short => '-r', :long => '--roles', :value => '<string>', :help => 'comma-separated list of roles used for set_hosts and set_channels' },
|
370
|
+
{ :short => '-t', :long => '--testset', :value => '<string>', :help => 'csv testset for import' },
|
371
|
+
{ :short => '-u', :long => '--uuid', :value => '<string>', :help => 'uuid arg used for load_scenario and run_testset' },
|
372
|
+
{ :short => '-v', :long => '--verbose', :value => '', :help => 'set Logger::DEBUG level' },
|
373
|
+
{ :short => '-y', :long => '--type', :value => '<string>', :help => 'network layer (v4, b6, l2) used for set_hosts and set_channels' },
|
374
|
+
]
|
375
|
+
|
376
|
+
cmds = [
|
377
|
+
"mu cmd_ddt:display_results",
|
378
|
+
"mu cmd_ddt:new_session",
|
379
|
+
"mu cmd_ddt:load_scenario -u <uuid>",
|
380
|
+
"mu cmd_ddt:get_hosts",
|
381
|
+
"mu cmd_ddt:set_hosts -r <roles> -n <names> -y <type>",
|
382
|
+
"mu cmd_ddt:get_channels",
|
383
|
+
"mu cmd_ddt:set_channels -r <roles> -n <names>",
|
384
|
+
"mu cmd_ddt:get_options",
|
385
|
+
"mu cmd_ddt:set_options -n <names> -p <option values>",
|
386
|
+
"mu cmd_ddt:get_sessions",
|
387
|
+
"mu cmd_ddt:setup_test",
|
388
|
+
"mu cmd_ddt:run",
|
389
|
+
"mu cmd_ddt:run_testset -u <uuid>",
|
390
|
+
"mu cmd_ddt:get_testset_results",
|
391
|
+
"mu cmd_ddt:get_testset_status",
|
392
|
+
"mu cmd_ddt:teardown_test",
|
393
|
+
"mu cmd_ddt:close_session",
|
394
|
+
"mu cmd_ddt:close_all_sessions",
|
395
|
+
"mu cmd_ddt:csv_export -u <uuid> ",
|
396
|
+
"mu cmd_ddt:csv_import -t <testset(csv file)> "
|
397
|
+
]
|
398
|
+
|
399
|
+
max_long_size = helps.inject(0) { |memo, obj| [ obj[:long].size, memo ].max }
|
400
|
+
max_value_size = helps.inject(0) { |memo, obj| [ obj[:value].size, memo ].max }
|
401
|
+
puts
|
402
|
+
puts "Usage: mu cmd_ddt:<command> <options>"
|
403
|
+
puts
|
404
|
+
helps.each do |h|
|
405
|
+
puts "%-*s %*s %-*s %s" % [max_long_size, h[:long], 2, h[:short], max_value_size, h[:value], h[:help]]
|
406
|
+
end
|
407
|
+
puts
|
408
|
+
puts "Available Commands"
|
409
|
+
puts
|
410
|
+
cmds.each do | c |
|
411
|
+
puts c
|
412
|
+
end
|
413
|
+
puts
|
414
|
+
end
|
415
|
+
|
416
|
+
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
=begin
|
422
|
+
first, create a session context. In it we can load a scenario, set its hosts,
|
423
|
+
channels and options
|
424
|
+
|
425
|
+
Next, create a test context. In it we can verify a scenario (run), run
|
426
|
+
a test set, and collect test results
|
427
|
+
|
428
|
+
If we need to make changes to the scenario, we need to teardown_test to return
|
429
|
+
to the session context, make the changes (set_hosts. set_options, set_channels),
|
430
|
+
and then call setup_test to create a new test context
|
431
|
+
|
432
|
+
Finally, we teardown_test and close_session
|
433
|
+
|
434
|
+
basic order of operations:
|
435
|
+
@api = DdtApi.new
|
436
|
+
|
437
|
+
@api.new_session # new session context
|
438
|
+
@api.load_scenario(scenario_uuid)
|
439
|
+
@api.set_hosts (required unless scenario template has the hosts you want) (host_roles_array, host_names_array)
|
440
|
+
@api.set_channels (optional)
|
441
|
+
@api.set_options (optional, to add or change scenario options)
|
442
|
+
@api.setup_test # takes the configured scenario and builds test context
|
443
|
+
@api.run # to verify
|
444
|
+
@api.run_testset(testsuite_uuid) # loads and runs test suite
|
445
|
+
@api.get_testset_status # poll until done
|
446
|
+
@api.get_testset_results
|
447
|
+
@api.teardown_test # to return to the session context, tears down the test context
|
448
|
+
@api.close_session # tears down the session context
|
449
|
+
=end
|