Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using a specific EMI and add an output option to write a file Nagios can parse #99

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions testcases/cloud_user/instances/instancetest.py
Expand Up @@ -167,7 +167,11 @@ def setUp(self, credpath=None):
### Generate a keypair for the instance
self.keypair = self.tester.add_keypair( "keypair-" + str(time.time()))
self.keypath = '%s/%s.pem' % (os.curdir, self.keypair.name)
self.image = self.tester.get_emi(root_device_type="instance-store")
### Use a random instance-store backed EMI if no cli option set
if arg_emi is False:
self.image = self.tester.get_emi(root_device_type="instance-store")
else:
self.image = self.tester.get_emi(arg_emi)
self.reservation = None
self.private_addressing = False
zones = self.tester.ec2.get_all_zones()
Expand Down Expand Up @@ -457,16 +461,21 @@ def run_testcase_thread(self, queue,delay = 20, name="MetaData"):
test instance functionality and features \
on a Eucalyptus Cloud. For more information, \
please refer to https://github.com/hspencer77/eutester/wiki/instancetest.",
usage="%(prog)s --credpath=<path to creds> [--xml] [--tests=test1,..testN]")
usage="%(prog)s --credpath=<path to creds> [--xml|nagios] [--emi=emi-id] [--tests=test1,..testN]")
parser.add_argument('--credpath',
help="path to user credentials", default=".eucarc")
parser.add_argument('--xml',
help="to provide JUnit style XML output", action="store_true", default=False)
parser.add_argument('--nagios',
help="to provide Nagios parsable output", action="store_true", default=False)
parser.add_argument('--emi',
help="specific emi to run", default=False)
parser.add_argument('--tests', nargs='+',
help="test cases to be executed",
default= ["BasicInstanceChecks","ElasticIps","PrivateIPAddressing","MaxSmallInstances","LargestInstance","MetaData", "DNSResolveCheck", "DNSCheck" "Reboot", "Churn"])
args = parser.parse_args()
arg_credpath = args.credpath
arg_emi = args.emi
for test in args.tests:
if args.xml:
try:
Expand All @@ -476,9 +485,22 @@ def run_testcase_thread(self, queue,delay = 20, name="MetaData"):
file = open("results/test-" + test + "result.xml", "w")
result = xmlrunner.XMLTestRunner(file).run(InstanceBasics(test))
file.close()
elif args.nagios:
try:
os.mkdir("/tmp/results")
except OSError:
pass
file = open("/tmp/results/test-" + test + "-result.txt", "w")
result = unittest.TextTestRunner(verbosity=2).run(InstanceBasics(test))
else:
result = unittest.TextTestRunner(verbosity=2).run(InstanceBasics(test))
if result.wasSuccessful():
if args.nagios:
file.write("PASS\n")
file.close()
pass
else:
if args.nagios:
file.write("FAIL\n")
file.close()
exit(1)