Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 497 lines (446 sloc) 19.559 kB
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
1 import getopt
07e0a16 @kbatten add more advanced parsing to testinput -p arguments
kbatten authored
2 import re
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
3 from builds.build_query import BuildQuery
4 import logger
5 import ConfigParser
4684cec @kbatten expand home directory shortcut for ssh_key location
kbatten authored
6 import os
bb1793d @suhailkhaki CBQE-303 Implemented support for "star" topology and minor refactorin…
suhailkhaki authored
7 import collections
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
8
9 #class to parse the inputs either from command line or from a ini file
10 #command line supports a subset of
11 # configuration
12 # which tests
13 # ideally should accept a regular expression
14
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
15
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
16 class TestInputSingleton():
17 input = None
18
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
19
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
20 class TestInput(object):
21
22 def __init__(self):
23 self.servers = []
1260202 @kbatten add a moxis tag to testrunner ini
kbatten authored
24 self.moxis = []
ca5eb43 Revert "CBQA-21 XDCR base testclass (super class)"
Farshid Ghods authored
25 self.clusters = {}
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
26 self.membase_settings = None
27 self.test_params = {}
5591d08 @IrynaMironava CBQE-1531: fix building tuq from source
IrynaMironava authored
28 self.tuq_client = {}
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
29 #servers , each server can have u,p,port,directory
30
eb4016f @vmx CBQE-2430: Don't require a default value for test input parameters
vmx authored
31 def param(self, name, *args):
32 """Returns the paramater or a default value
33
34 The first parameter is the name of property, the second
35 parameter is the default value. If not default value is given,
36 an exception will be raised.
37 """
a58b060 @vmx Move functions to get parameters into the TestInput class
vmx authored
38 if name in self.test_params:
39 return TestInput._parse_param(self.test_params[name])
eb4016f @vmx CBQE-2430: Don't require a default value for test input parameters
vmx authored
40 elif len(args) == 1:
41 return args[0]
a58b060 @vmx Move functions to get parameters into the TestInput class
vmx authored
42 else:
eb4016f @vmx CBQE-2430: Don't require a default value for test input parameters
vmx authored
43 raise Exception("Parameter `{}` must be set "
44 "in the test configuration".format(name))
a58b060 @vmx Move functions to get parameters into the TestInput class
vmx authored
45
46 @staticmethod
47 def _parse_param(value):
48 try:
49 return int(value)
50 except ValueError:
9b21ecf @kbatten add 1.8.1 upgrade tests
kbatten authored
51 pass
52
53 try:
54 return float(value)
55 except ValueError:
56 pass
57
58 if value.lower() == "false":
59 return False
60
61 if value.lower() == "true":
62 return True
63
64 return value
a58b060 @vmx Move functions to get parameters into the TestInput class
vmx authored
65
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
66
67 class TestInputServer(object):
68 def __init__(self):
69 self.ip = ''
0caa10b @IrynaMironava CBQE-927: add upgrade test with hostnames
IrynaMironava authored
70 self.hostname = ''
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
71 self.ssh_username = ''
72 self.ssh_password = ''
73 self.ssh_key = ''
74 self.rest_username = ''
75 self.rest_password = ''
0e02441 @paragagarwal CBQE-0: Framework for Recovery 2i and related tests
paragagarwal authored
76 self.services = ''
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
77 self.port = ''
78 self.cli_path = ''
40aa7e5 @kbatten set the membase data path if provided in the ini file
kbatten authored
79 self.data_path = ''
16e90a7 @pavel-paulau MB-100: allow to set index_path in installation script
pavel-paulau authored
80 self.index_path = ''
d76eff8 @paragagarwal CBQE-2544: Support for simple.conf for n1ql+2i integration tests
paragagarwal authored
81 self.n1ql_port = ''
d1c6ce1 @paragagarwal CBQE-0:index stats support
paragagarwal authored
82 self.index_port = ''
2ed303b @subalakr CBQE-2613: es test fixes and more additions
subalakr authored
83 self.es_username = ''
84 self.es_password = ''
37632c0 @paragagarwal CBQE-0::Upgrade tests fixes - online and offline upgrade
paragagarwal authored
85 self.upgraded = False
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
86
1af5180 @farshidce minor fix in set_get_tests setup method
farshidce authored
87 def __str__(self):
bb1793d @suhailkhaki CBQE-303 Implemented support for "star" topology and minor refactorin…
suhailkhaki authored
88 #ip_str = "ip:{0}".format(self.ip)
89 ip_str = "ip:{0} port:{1}".format(self.ip, self.port)
1af5180 @farshidce minor fix in set_get_tests setup method
farshidce authored
90 ssh_username_str = "ssh_username:{0}".format(self.ssh_username)
91 return "{0} {1}".format(ip_str, ssh_username_str)
92
93 def __repr__(self):
bb1793d @suhailkhaki CBQE-303 Implemented support for "star" topology and minor refactorin…
suhailkhaki authored
94 #ip_str = "ip:{0}".format(self.ip)
95 ip_str = "ip:{0} port:{1}".format(self.ip, self.port)
1af5180 @farshidce minor fix in set_get_tests setup method
farshidce authored
96 ssh_username_str = "ssh_username:{0}".format(self.ssh_username)
97 return "{0} {1}".format(ip_str, ssh_username_str)
98
99
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
100 class TestInputMembaseSetting(object):
101
102 def __init__(self):
103 self.rest_username = ''
104 self.rest_password = ''
105
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
106
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
107 class TestInputBuild(object):
108 def __init__(self):
109 self.version = ''
110 self.url = ''
111
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
112
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
113 # we parse this and then pass it on to all the test case
114 class TestInputParser():
115
116 @staticmethod
117 def get_test_input(argv):
118 #if file is given use parse_from_file
119 #if its from command line
2d1513b @pavel-paulau MB-100: fixed missing '-l' option
pavel-paulau authored
120 (opts, args) = getopt.getopt(argv[1:], 'ht:c:v:s:i:p:l:', [])
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
121 #first let's loop over and find out if user has asked for help
122 #if it has i
123 params = {}
124 has_ini = False
125 ini_file = ''
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
126 for option, argument in opts:
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
127 if option == '-h':
128 print 'usage'
129 return
130 if option == '-i':
131 has_ini = True
132 ini_file = argument
133 if option == '-p':
07e0a16 @kbatten add more advanced parsing to testinput -p arguments
kbatten authored
134 # takes in a string of the form "p1=v1,v2,p2=v3,p3=v4,v5,v6"
135 # converts to a dictionary of the form {"p1":"v1,v2","p2":"v3","p3":"v4,v5,v6"}
136 argument_split = [a.strip() for a in re.split("[,]?([^,=]+)=", argument)[1:]]
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
137 pairs = dict(zip(argument_split[::2], argument_split[1::2]))
07e0a16 @kbatten add more advanced parsing to testinput -p arguments
kbatten authored
138 for pair in pairs.iteritems():
139 if pair[0] == "vbuckets":
140 # takes in a string of the form "1-100,140,150-160"
141 # converts to an array with all those values inclusive
142 vbuckets = set()
143 for v in pair[1].split(","):
144 r = v.split("-")
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
145 vbuckets.update(range(int(r[0]), int(r[-1]) + 1))
07e0a16 @kbatten add more advanced parsing to testinput -p arguments
kbatten authored
146 params[pair[0]] = sorted(vbuckets)
147 else:
148 argument_list = [a.strip() for a in pair[1].split(",")]
149 if len(argument_list) > 1:
150 # if the parameter had multiple entries seperated by comma
151 # then store as a list
152 # ex. {'vbuckets':[1,2,3,4,100]}
153 params[pair[0]] = argument_list
154 else:
155 # if parameter only had one entry then store as a string
156 # ex. {'product':'cb'}
157 params[pair[0]] = argument_list[0]
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
158
159 if has_ini:
160 input = TestInputParser.parse_from_file(ini_file)
161 #now let's get the test specific parameters
162 else:
163 input = TestInputParser.parse_from_command_line(argv)
164 input.test_params = params
32c29a8 @ronniedada [perf ref] get num_nodes and num_clients in TestInput
ronniedada authored
165
166 if "num_clients" not in input.test_params.keys() and input.clients: # do not override the command line value
167 input.test_params["num_clients"] = len(input.clients)
168 if "num_nodes" not in input.test_params.keys() and input.servers:
169 input.test_params["num_nodes"] = len(input.servers)
170
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
171 return input
172
173 @staticmethod
174 def parse_from_file(file):
175 servers = []
176 ips = []
177 input = TestInput()
178 config = ConfigParser.ConfigParser()
179 config.read(file)
180 sections = config.sections()
181 global_properties = {}
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
182 count = 0
183 start = 0
184 end = 0
185 cluster_ips = []
186 clusters = {}
1260202 @kbatten add a moxis tag to testrunner ini
kbatten authored
187 moxis = []
5591d08 @IrynaMironava CBQE-1531: fix building tuq from source
IrynaMironava authored
188 input.tuq_client = {}
1260202 @kbatten add a moxis tag to testrunner ini
kbatten authored
189 moxi_ips = []
0e6804f @kakumar Perf: Add clients list in input.
kakumar authored
190 client_ips = []
a83088d @pavel-paulau CBD-150: read dashboard address from ini file
pavel-paulau authored
191 input.dashboard = []
129214e @IrynaMironava MB-3103: Implement selenium UI tests
IrynaMironava authored
192 input.ui_conf = {}
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
193 for section in sections:
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
194 result = re.search('^cluster', section)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
195 if section == 'servers':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
196 ips = TestInputParser.get_server_ips(config, section)
1260202 @kbatten add a moxis tag to testrunner ini
kbatten authored
197 elif section == 'moxis':
198 moxi_ips = TestInputParser.get_server_ips(config, section)
0e6804f @kakumar Perf: Add clients list in input.
kakumar authored
199 elif section == 'clients':
200 client_ips = TestInputParser.get_server_ips(config, section)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
201 elif section == 'membase':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
202 input.membase_settings = TestInputParser.get_membase_settings(config, section)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
203 elif section == 'global':
204 #get global stuff and override for those unset
205 for option in config.options(section):
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
206 global_properties[option] = config.get(section, option)
a83088d @pavel-paulau CBD-150: read dashboard address from ini file
pavel-paulau authored
207 elif section == 'dashboard':
208 input.dashboard = TestInputParser.get_server_ips(config, section)
129214e @IrynaMironava MB-3103: Implement selenium UI tests
IrynaMironava authored
209 elif section == 'uiconf':
210 input.ui_conf = TestInputParser.get_ui_tests_config(config, section)
76222b7 @IrynaMironava CBQE-1531: add possibility to run tuq_client on a different server
IrynaMironava authored
211 elif section == 'tuq_client':
5591d08 @IrynaMironava CBQE-1531: fix building tuq from source
IrynaMironava authored
212 input.tuq_client = TestInputParser.get_tuq_config(config, section)
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
213 elif result is not None:
214 cluster_list = TestInputParser.get_server_ips(config, section)
215 cluster_ips.extend(cluster_list)
216 clusters[count] = len(cluster_list)
217 count += 1
218
219 # Setup 'cluster#' tag as dict
220 # input.clusters -> {0: [ip:10.1.6.210 ssh_username:root, ip:10.1.6.211 ssh_username:root]}
221 for cluster_ip in cluster_ips:
222 servers.append(TestInputParser.get_server(cluster_ip, config))
223 servers = TestInputParser.get_server_options(servers, input.membase_settings, global_properties)
5591d08 @IrynaMironava CBQE-1531: fix building tuq from source
IrynaMironava authored
224 if 'client' in input.tuq_client and input.tuq_client['client']:
225 input.tuq_client['client'] = TestInputParser.get_server_options([input.tuq_client['client'],],
226 input.membase_settings,
227 global_properties)[0]
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
228 for key, value in clusters.items():
229 end += value
230 input.clusters[key] = servers[start:end]
bb1793d @suhailkhaki CBQE-303 Implemented support for "star" topology and minor refactorin…
suhailkhaki authored
231 start += value
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
232
233 # Setting up 'servers' tag
234 servers = []
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
235 for ip in ips:
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
236 servers.append(TestInputParser.get_server(ip, config))
237 input.servers = TestInputParser.get_server_options(servers, input.membase_settings, global_properties)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
238
1260202 @kbatten add a moxis tag to testrunner ini
kbatten authored
239 # Setting up 'moxis' tag
240 moxis = []
241 for moxi_ip in moxi_ips:
242 moxis.append(TestInputParser.get_server(moxi_ip, config))
243 input.moxis = TestInputParser.get_server_options(moxis, input.membase_settings, global_properties)
244
0e6804f @kakumar Perf: Add clients list in input.
kakumar authored
245 # Setting up 'clients' tag
246 input.clients = client_ips
247
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
248 return input
249
250 @staticmethod
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
251 def get_server_options(servers, membase_settings, global_properties):
252 for server in servers:
253 if server.ssh_username == '' and 'username' in global_properties:
254 server.ssh_username = global_properties['username']
255 if server.ssh_password == '' and 'password' in global_properties:
256 server.ssh_password = global_properties['password']
257 if server.ssh_key == '' and 'ssh_key' in global_properties:
4684cec @kbatten expand home directory shortcut for ssh_key location
kbatten authored
258 server.ssh_key = os.path.expanduser(global_properties['ssh_key'])
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
259 if not server.port and 'port' in global_properties:
260 server.port = global_properties['port']
261 if server.cli_path == '' and 'cli' in global_properties:
262 server.cli_path = global_properties['cli']
263 if server.rest_username == '' and membase_settings.rest_username != '':
264 server.rest_username = membase_settings.rest_username
265 if server.rest_password == '' and membase_settings.rest_password != '':
266 server.rest_password = membase_settings.rest_password
267 if server.data_path == '' and 'data_path' in global_properties:
268 server.data_path = global_properties['data_path']
16e90a7 @pavel-paulau MB-100: allow to set index_path in installation script
pavel-paulau authored
269 if server.index_path == '' and 'index_path' in global_properties:
270 server.index_path = global_properties['index_path']
0e02441 @paragagarwal CBQE-0: Framework for Recovery 2i and related tests
paragagarwal authored
271 if server.services == '' and 'services' in global_properties:
272 server.services = global_properties['services']
d76eff8 @paragagarwal CBQE-2544: Support for simple.conf for n1ql+2i integration tests
paragagarwal authored
273 if server.n1ql_port == '' and 'n1ql_port' in global_properties:
274 server.n1ql_port = global_properties['n1ql_port']
d1c6ce1 @paragagarwal CBQE-0:index stats support
paragagarwal authored
275 if server.index_port == '' and 'index_port' in global_properties:
276 server.index_port = global_properties['index_port']
2ed303b @subalakr CBQE-2613: es test fixes and more additions
subalakr authored
277 if server.es_username == '' and 'es_username' in global_properties:
278 server.es_username = global_properties['es_username']
279 if server.es_password == '' and 'es_password' in global_properties:
280 server.es_password = global_properties['es_password']
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
281 return servers
282
283 @staticmethod
284 def get_server_ips(config, section):
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
285 ips = []
286 options = config.options(section)
287 for option in options:
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
288 ips.append(config.get(section, option))
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
289 return ips
290
291 @staticmethod
129214e @IrynaMironava MB-3103: Implement selenium UI tests
IrynaMironava authored
292 def get_ui_tests_config(config, section):
293 conf = {}
4e64a44 @IrynaMironava MB-3103: UI tests launching
IrynaMironava authored
294 server = TestInputServer()
129214e @IrynaMironava MB-3103: Implement selenium UI tests
IrynaMironava authored
295 options = config.options(section)
296 for option in options:
4e64a44 @IrynaMironava MB-3103: UI tests launching
IrynaMironava authored
297 if option == 'selenium_ip':
298 server.ip = config.get(section, option)
299 elif option == 'selenium_port':
300 server.port = config.get(section, option)
301 elif option == 'selenium_user':
302 server.ssh_username = config.get(section, option)
303 elif option == 'selenium_password':
304 server.ssh_password = config.get(section, option)
305 else:
306 conf[option] = config.get(section, option)
307 conf['server'] = server
129214e @IrynaMironava MB-3103: Implement selenium UI tests
IrynaMironava authored
308 return conf
309
310 @staticmethod
5591d08 @IrynaMironava CBQE-1531: fix building tuq from source
IrynaMironava authored
311 def get_tuq_config(config, section):
312 conf = {}
313 server = TestInputServer()
314 options = config.options(section)
315 for option in options:
316 if option == 'ip':
317 ip = config.get(section, option)
318 conf['client'] = TestInputParser.get_server(ip, config)
319 else:
320 conf[option] = config.get(section, option)
321 conf[option] = config.get(section, option)
322 return conf
323
324 @staticmethod
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
325 def get_server(ip, config):
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
326 server = TestInputServer()
327 server.ip = ip
328 for section in config.sections():
329 if section == ip:
330 options = config.options(section)
331 for option in options:
332 if option == 'username':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
333 server.ssh_username = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
334 if option == 'password':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
335 server.ssh_password = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
336 if option == 'cli':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
337 server.cli_path = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
338 if option == 'ssh_key':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
339 server.ssh_key = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
340 if option == 'port':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
341 server.port = config.get(section, option)
06a7d5d @farshidce modified testrunner code to work with ns_server
farshidce authored
342 if option == 'ip':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
343 server.ip = config.get(section, option)
0e02441 @paragagarwal CBQE-0: Framework for Recovery 2i and related tests
paragagarwal authored
344 if option == 'services':
345 server.services = config.get(section, option)
d76eff8 @paragagarwal CBQE-2544: Support for simple.conf for n1ql+2i integration tests
paragagarwal authored
346 if option == 'n1ql_port':
347 server.n1ql_port = config.get(section, option)
d1c6ce1 @paragagarwal CBQE-0:index stats support
paragagarwal authored
348 if option == 'index_port':
349 server.index_port = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
350 break
351 #get username
352 #get password
353 #get port
354 #get cli_path
355 #get key
356 return server
357
358 @staticmethod
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
359 def get_membase_build(config, section):
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
360 membase_build = TestInputBuild()
361 for option in config.options(section):
362 if option == 'version':
363 pass
364 if option == 'url':
365 pass
366 return membase_build
367
368 @staticmethod
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
369 def get_membase_settings(config, section):
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
370 membase_settings = TestInputMembaseSetting()
371 for option in config.options(section):
372 if option == 'rest_username':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
373 membase_settings.rest_username = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
374 if option == 'rest_password':
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
375 membase_settings.rest_password = config.get(section, option)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
376 return membase_settings
377
378 @staticmethod
379 def parse_from_command_line(argv):
380
381 input = TestInput()
382
383 try:
384 # -f : won't be parse here anynore
385 # -s will have comma separated list of servers
386 # -t : wont be parsed here anymore
387 # -v : version
388 # -u : url
389 # -b : will have the path to cli
390 # -k : key file
391 # -p : for smtp ( taken care of by jenkins)
392 # -o : taken care of by jenkins
393 servers = []
394 membase_setting = None
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
395 (opts, args) = getopt.getopt(argv[1:], 'h:t:c:i:p:', [])
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
396 #first let's loop over and find out if user has asked for help
397 need_help = False
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
398 for option, argument in opts:
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
399 if option == "-h":
400 print 'usage...'
401 need_help = True
402 break
403 if need_help:
404 return
405 #first let's populate the server list and the version number
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
406 for option, argument in opts:
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
407 if option == "-s":
408 #handle server list
409 servers = TestInputParser.handle_command_line_s(argument)
410 elif option == "-u" or option == "-v":
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
411 input_build = TestInputParser.handle_command_line_u_or_v(option, argument)
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
412
413 #now we can override the username pass and cli_path info
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
414 for option, argument in opts:
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
415 if option == "-k":
416 #handle server list
417 for server in servers:
418 if server.ssh_key == '':
419 server.ssh_key = argument
420 elif option == "--username":
421 #handle server list
422 for server in servers:
423 if server.ssh_username == '':
424 server.ssh_username = argument
425 elif option == "--password":
426 #handle server list
427 for server in servers:
428 if server.ssh_password == '':
429 server.ssh_password = argument
430 elif option == "-b":
431 #handle server list
432 for server in servers:
433 if server.cli_path == '':
434 server.cli_path = argument
435 # loop over stuff once again and set the default
436 # value
437 for server in servers:
438 if server.ssh_username == '':
439 server.ssh_username = 'root'
440 if server.ssh_password == '':
441 server.ssh_password = 'northscale!23'
442 if server.cli_path == '':
443 server.cli_path = '/opt/membase/bin/'
444 if not server.port:
445 server.port = 8091
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
446 input.servers = servers
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
447 input.membase_settings = membase_setting
448 return input
449 except Exception:
9e49bac @farshidce instantiate logger in except: block
farshidce authored
450 log = logger.Logger.get_logger()
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
451 log.error("unable to parse input arguments")
452 raise
453
454 @staticmethod
a23d15e @kkumar86 Add support for cluster tag in resource file
kkumar86 authored
455 def handle_command_line_u_or_v(option, argument):
e47cbbb @farshidce made changes to testrunner for parsing input file
farshidce authored
456 input_build = TestInputBuild()
457 if option == "-u":
458 # let's check whether this url exists or not
459 # let's extract version from this url
460 pass
461 if option == "-v":
462 allbuilds = BuildQuery().get_all_builds()
463 for build in allbuilds:
464 if build.product_version == argument:
465 input_build.url = build.url
466 input_build.version = argument
467 break
468 return input_build
469
470 #returns list of server objects
471 @staticmethod
472 def handle_command_line_s(argument):
473 #ip:port:username:password:clipath
474
475 ips = argument.split(",")
476 servers = []
477
478 for ip in ips:
479 server = TestInputServer()
480 if ip.find(":") == -1:
481 pass
482 else:
483 info = ip.split(":")
484 #info[0] : ip
485 #info[1] : port
486 #info[2] :username
487 #info[3] : password
488 #info[4] : cli path
489 server.ip = info[0]
490 server.port = info[1]
491 server.ssh_username = info[2]
492 server.ssh_password = info[3]
493 server.cli_path = info[4]
494 servers.append(server)
495
496 return servers
Something went wrong with that request. Please try again.