Last active
December 25, 2015 22:49
-
-
Save shaon/b18dee35e700f2bb4129 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import time | |
from eucaops import Eucaops | |
from eutester.eutestcase import EutesterTestCase | |
import os | |
class InstanceBasics(EutesterTestCase): | |
def __init__(self): | |
#### Pre-conditions | |
self.setuptestcase() | |
self.setup_parser() | |
self.parser.add_argument("--build-number") | |
self.get_args() | |
# Setup basic eutester object | |
self.tester = Eucaops( credpath=self.args.credpath) | |
self.reservation = None | |
### Generate a group for the instance | |
self.group = self.tester.add_group(group_name="inst-vmware-grp-" + str(time.time()).replace(".", "") + self.tester.id_generator() + "-" + self.args.build_number) | |
self.tester.authorize_group_by_name(group_name=self.group.name) | |
self.tester.authorize_group_by_name(group_name=self.group.name, port=-1, protocol="icmp" ) | |
### Generate a keypair for the instance | |
self.keypair_name = "inst-vmware-key-" + str(time.time()).replace(".", "") + self.tester.id_generator() + "-" + self.args.build_number | |
self.keypair = self.tester.add_keypair(self.keypair_name) | |
### Get an image to work with | |
self.image = self.tester.get_emi("emi-DB7D3B90") | |
def clean_method(self): | |
""" | |
Description: Attempts to clean up resources created in this test | |
""" | |
try: | |
self.tester.cleanup_artifacts() | |
except Exception, e: | |
self.debug(str(e)) | |
def MyTest(self): | |
""" | |
Description: This test will simply run an instance and check that it is reachable via ssh. | |
""" | |
self.instance_list = self.tester.run_image(self.image, min=1, max=1, zone="PARTI01",keypair=self.keypair_name,group=self.group, timeout=800) | |
for instance in self.instance_list: | |
assert self.tester.ping(instance.public_dns_name) | |
for instance in self.instance_list: | |
instance.terminate_and_verify(timeout=800) | |
if __name__ == "__main__": | |
testcase = InstanceBasics() | |
### Use the list of tests passed from config/command line to determine what subset of tests to run | |
### or use a predefined list | |
list = testcase.args.tests or [ "MyTest"] | |
### Convert test suite methods to EutesterUnitTest objects | |
unit_list = [ ] | |
for test in list: | |
unit_list.append( testcase.create_testunit_by_name(test) ) | |
### Run the EutesterUnitTest objects | |
result = testcase.run_test_case_list(unit_list,clean_on_exit=True) | |
exit(result) | |
###################### | |
### Jenkins Setup ### | |
###################### | |
# CREDPATH=credentials | |
# if [ ! -d "$CREDPATH" ]; then | |
# mkdir $CREDPATH | |
# fi | |
# cat > credentials/eucarc << EOF | |
# $eucarc | |
# EOF | |
# | |
# cat > test_script << EOF | |
# $script | |
# EOF | |
# /share/eutester-base/bin/python ./test_script --credpath credentials --build-number $BUILD_NUMBER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment