Repository navigation
Expand file tree
/
Copy pathrunTestCase.py
More file actions
executable file
·88 lines (70 loc) · 2.57 KB
/
Copy pathrunTestCase.py
File metadata and controls
executable file
·88 lines (70 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
# sanity tests
import api.tbed
import api.tutils
import time
import sys
import api.objmodel
import testcases.tcBasic
import testcases.tcPolicy
import testcases.tcNetwork
import testcases.tcTrigger
import testcases.tcAci
import argparse
import os
import exceptions
import traceback
# Create the parser and sub parser
parser = argparse.ArgumentParser()
parser.add_argument('--version', action='version', version='1.0.0')
parser.add_argument("-nodes", required=True, help="list of nodes(comma seperated)")
parser.add_argument("-iteration", default="3", help="Number of iterations")
parser.add_argument("-user", default='vagrant', help="User id for ssh")
parser.add_argument("-password", default='vagrant', help="password for ssh")
parser.add_argument("-binpath", default='/opt/gopath/bin', help="netplugin/netmaster binary path")
parser.add_argument("-containers", default='0', help="number of containers")
parser.add_argument("-short", default='false', help="do a quick run of the tests for quick validation")
# Parse the args
args = parser.parse_args()
addrList = args.nodes.split(",")
shortRun = args.short.lower()
numCntr = len(addrList) * 2
numIteration = int(args.iteration)
numTriggerTests = 6
if args.containers != '0':
numCntr = int(args.containers)
if shortRun == "true":
print "doing a short run"
numCntr = len(addrList) * 2
numIteration = 1
numTriggerTests = 1
api.tutils.info("Running " + str(numIteration) + " iterations with " + str(numCntr) + " containers on " + str(len(addrList)) + " nodes")
try:
# Time when test started
startTime = time.time()
# Setup testbed
testbed = api.tbed.Testbed(addrList, args.user, args.password, args.binpath)
time.sleep(15)
testbed.chekForNetpluginErrors()
# Run single test case
testcases.tcTrigger.netmasterSwitchoverTest(testbed, numCntr, numIteration)
# Cleanup testbed
testbed.cleanup()
# Calculate how long it took
doneTime = time.time()
elapsedTime = doneTime - startTime
api.tutils.log("Test started at " + time.asctime(time.localtime(startTime)))
api.tutils.log("Test ended at " + time.asctime(time.localtime(doneTime)))
if elapsedTime > 120.0:
api.tutils.log("Tests took " + str(elapsedTime/60) + " minutes")
else:
api.tutils.log("Tests took " + str(elapsedTime) + " seconds")
api.tutils.info("testcase passed")
os._exit(0)
except exceptions.KeyboardInterrupt:
print "\n\n Keyboard interrupt.... Exiting\n"
os._exit(1)
except: # catch *all* exceptions
print "Exception: "
traceback.print_exc()
os._exit(1)