Eutester 0.0.6 documentation

eutester Package

Contents

eutester Package

eutester Package

class eutester.Eutester(credpath=None, aws_access_key_id=None, aws_secret_access_key=None)[source]

Bases: object

clear_fail_count()[source]

The counter for keeping track of all the errors

clear_fail_log()[source]
diff(list1, list2)[source]

Return the diff of the two lists

fail(message)[source]
found(command, regex)[source]

Returns a Boolean of whether the result of the command contains the regex

get_access_key()[source]

Parse the eucarc for the EC2_ACCESS_KEY

get_account_id()[source]

Parse the eucarc for the EC2_ACCOUNT_NUMBER

get_ec2_ip()[source]

Parse the eucarc for the EC2_URL

get_exectuion_time()[source]

Returns the total execution time since the instantiation of the Eutester object

get_port()[source]

Parse the eucarc for the EC2_ACCOUNT_NUMBER

get_s3_ip()[source]

Parse the eucarc for the S3_URL

get_secret_key()[source]

Parse the eucarc for the EC2_SECRET_KEY

get_user_id()[source]

Parse the eucarc for the EC2_ACCOUNT_NUMBER

grep(string, list)[source]

Remove the strings from the list that do not match the regex string

handle_timeout(signum, frame)[source]
id_generator(size=6, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789')[source]

Returns a string of size with random charachters from the chars array. size Size of string to return chars Array of characters to use in generation of the string

local(cmd)[source]

Run a command locally on the tester

parse_eucarc(field)[source]
ping(address, poll_count=10)[source]

Ping an IP and poll_count times (Default = 10) address Hostname to ping poll_count The amount of times to try to ping the hostname iwth 2 second gaps in between

scan_port_range(ip, start, stop, timeout=1, tcp=True)[source]

Attempts to connect to ports, returns list of ports which accepted a connection

sleep(seconds=1)[source]

Convinience function for time.sleep()

test_port_status(ip, port, timeout=5, tcp=True, verbose=True)[source]

Attempts to connect to tcp port at ip:port within timeout seconds

exception eutester.TimeoutFunctionException[source]

Bases: exceptions.Exception

Exception to raise on a timeout

euconfig Module

Created on May 11, 2012 @author: clarkmatthew

Simple utility to read a given config file and parse out the configuration. Uses python’s Config Parser but includes some utils to support legacy config files To use this utility, the config file given must use the following format: [prefix]key=value

example: Add the following lines to a file called /tmp/config.txt Note: This example is using the legacy config with ip, distro, and component info.

>cat /tmp/config.txt

1.1.1.1 CENTOS 5.7 64 REPO [CLC WS] 1.1.1.2 CENTOS 5.7 64 REPO [NC00]

[mytest] volumes=2 image=centos.img

[joestest] image=ubuntu.img name=joe iterations=3 output=/tmp/joesoutput.txt

To retrieve config info from this file from within a test: >conf = EuConfig(filename=’/tmp/config.txt’) >myimage = conf.get_config(‘mytest’,’image’) >joesimage = conf.get(‘joestest’,’image’) > >print myimage

centos.img
>print conf.legacybuf
1.1.1.1 CENTOS 5.7 64 REPO [CLC WS] 1.1.1.2 CENTOS 5.7 64 REPO [NC00]
class eutester.euconfig.EuConfig(filename='../input/2btested.lst', debugmethod=None, verbose=False)[source]
debug(msg)[source]
get(section, key)[source]
get_config_buf(lines=None)[source]

Gather config lines into list. To support legacy config, will exclude all lines read prior to detecting a section header. Will ignore blank lines and lines starting with “#” representing comments

get_legacy_config(lines=None)[source]

Gather all lines from the given config until a section header is reached In order to be backwards compatible with previous configuration files will return a buffer of file read until the first section header

read_config_file(filename)[source]

euinstance Module

Created on Mar 7, 2012 @author: clarkmatthew extension of the boto instance class, with added convenience methods + objects Add common instance test routines to this class

Sample usage:
testinstance = EuInstance.make_euinstance_from_instance( eutester.run_instances()[0] ) print testinstance.id output = testinstance.sys(“ls /dev/xd*”) print output[0] eutester.sys(‘ping ‘+testinstance.ip_address ) testinstance.sys(‘yum install ntpd’)
class eutester.euinstance.EuInstance(connection=None)[source]

Bases: boto.ec2.instance.Instance, eutester.taggedresource.TaggedResource

age_at_state = None
assertFilePresent(filepath)[source]

Method to check for the presence of a file at ‘filepath’ on the instance filepath - mandatory - string, the filepath to verify

attach_euvolume(euvolume, dev=None, timeout=60, overwrite=False)[source]

Method used to attach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being attached required - tester - the eucaops/eutester object/connection for this cloud optional - dev - string to specify the dev path to ‘request’ when attaching the volume to optional - timeout - integer- time allowed before failing optional - overwrite - flag to indicate whether to overwrite head data of a non-zero filled volume upon attach for md5

attach_euvolume_list(list, intervoldelay=0, timepervol=90, md5len=32)[source]
attach_volume(volume, dev=None, timeout=60, overwrite=False)[source]

Method used to attach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being attached required - tester - the eucaops/eutester object/connection for this cloud optional - dev - string to specify the dev path to ‘request’ when attaching the volume to optional - timeout - integer- time allowed before failing optional - overwrite - flag to indicate whether to overwrite head data of a non-zero filled volume upon attach for md5

attached_vols = []
auto_connect = True
bdm_vol = None
block_device_prefix = 'sd'
cmdstart = 0
connect_to_instance(timeout=60)[source]

Attempts to connect to an instance via ssh. timeout - optional - time in seconds to wait for connection before failure

debug(msg, traceback=1, method=None, frame=False)[source]

Used to print debug, defaults to print() but over ridden by self.debugmethod if not None msg - mandatory -string, message to be printed

debugmethod = None
detach_euvolume(euvolume, waitfordev=True, timeout=180)[source]

Method used to detach detach a volume to an instance and track it’s use by that instance required - euvolume - the euvolume object being deattached waitfordev - boolean to indicate whether or no to poll guest instance for local device to be removed optional - timeout - integer seconds to wait before timing out waiting for the volume to detach

found(command, regex)[source]

Returns a Boolean of whether the result of the command contains the regex

get_dev_dir(match=None)[source]

Attempts to return a list of devices in /dev which match the given grep criteria By default will attempt to match self.block_device_prefix if populated, otherwise will try to match sd,vd, and xd device prefixes. returns a list of matching dev names. match - optional - string used in grep search of /dev dir on instance

get_dev_md5(devpath, length, timeout=60)[source]
get_free_scsi_dev(prefix=None, maxdevs=16)[source]

The volume attach command requires a cloud level device name that is not currently associated with a volume Note: This is the device name from the clouds perspective, not necessarily the guest’s This method attempts to find a free device name to use in the command optional - prefix - string, pre-pended to the the device search string optional - maxdevs - number use to specify the max device names to iterate over.Some virt envs have a limit of 16 devs.

get_guestdevs_inuse_by_vols()[source]
get_metadata(element_path, prefix='latest/meta-data/')[source]

Return the lines of metadata from the element path provided

get_unsynced_volumes(euvol_list=None, md5length=32, timepervol=90, min_polls=2, check_md5=False)[source]

Description: Returns list of volumes which are: -in a state the cloud believes the vol is no longer attached -the attached device has changed, or is not found. If all euvols are shown as attached to this instance, and the last known local dev is present and/or a local device is found with matching md5 checksum then the list will return ‘None’ as all volumes are successfully attached and state is in sync. By default this method will iterate through all the known euvolumes attached to this euinstance. A subset can be provided in the list argument ‘euvol_list’. Returns a list of euvolumes for which a corresponding guest device could not be found, or the cloud no longer believes is attached.

Parameters:
  • euvol_list
    • optional - euvolume object list. Defaults to all self.attached_vols
  • md5length
    • optional - defaults to the length given in each euvolume. Used to calc md5 checksum of devices
  • timerpervolume – -optional - time to wait for device to appear, per volume before failing
  • min_polls
    • optional - minimum iterations to check guest devs before failing, despite timeout
  • check_md5
    • optional - find devices by md5 comparision. Default is to only perform this check when virtio_blk is in use.
get_user_group_info(username, index=3)[source]

Attempts to return a list of groups for a specific user on this instance. index is set at the grouplist by default [3], but can be adjust to include the username, password, and group id as well in the list. where the parsed string should be in format ‘name:password:groupid1:groupid2:groupid3...’

get_user_password(username)[source]

Attempts to verify whether or not a user ‘username’ has a password set or not on this instance. returns true if a password is detected, else false

get_users()[source]

Attempts to return a list of normal linux users local to this instance. Returns a list of all non-root users found within the uid_min/max range who are not marked nologin

init_volume_list(reattach=False, detach=True, timeout=300)[source]

This should be used when first creating a euinstance from an instance to insure the euinstance volume state is in sync with the cloud, mainly for the case where a euinstance is made from a pre-existing and in-use instance. Method to detect volumes which the cloud believes this guest is using, and attempt to match up the cloud dev with the local guest dev. In the case the local dev can not be found the volume will be detached. If the local device is found a euvolume object is created and appended the local attached_vols list. To confirm local state with the cloud state, the options ‘reattach’, or ‘detach’ can be used.

keypair = None
keypath = None
laststate = None
laststatetime = None
logger = None
classmethod make_euinstance_from_instance(instance, tester, debugmethod=None, keypair=None, keypath=None, password=None, username='root', auto_connect=True, verbose=True, timeout=120, private_addressing=False, reservation=None, cmdstart=None, retry=2)[source]

Primary constructor for this class. Note: to avoid an ssh session within this method, provide keys, username/pass later. Arguments: instance - mandatory- a Boto instance object used to build this euinstance object keypair - optional- a boto keypair object used for creating ssh connection to the instance password - optional- string used to create ssh connection to this instance as an alternative to keypair username - optional- string used to create ssh connection as an alternative to keypair timeout - optional- integer used for ssh connection timeout debugmethod - optional - method, used for debug output verbose - optional - boolean to determine if debug is to be printed using debug() retry - optional - integer, ssh connection attempts for non-authentication failures

md5_attached_euvolume(euvolume, timepergig=90, length=None, updatevol=True)[source]

Calculates an md5sum of the first ‘length’ bytes of the dev representing the attached euvolume. By default will use the md5len stored within the euvolume. The euvolume will be updated with the resulting checksum and length. Returns the md5 checksum euvolume - mandatory - euvolume object used to calc checksum against timepergig - optional - number of seconds used per gig in volume size used in calcuating timeout length - optional - number bytes to read from the head of the device file used in md5 calc updatevol - optional - boolean used to update the euvolume data or not

ops = None
password = None
printself(title=True, footer=True, printmethod=None)[source]
private_addressing = False
random_fill_volume(euvolume, srcdev=None, length=None)[source]

Attempts to fill the entie given euvolume with unique non-zero data. The srcdev is read from in a set size, and then used to write to the euvolume to populate it. The file helps with both speed up the copy in the urandom case, and adds both some level of randomness another src device as well as allows smaller src devs to be used to fill larger euvolumes by repeatedly reading into the copy. :param euvolume: the attached euvolume object to write data to :param srcdev: the source device to copy data from :param length: the number of bytes to copy into the euvolume :returns dd’s data/time stat

reboot_instance_and_verify(waitconnect=30, timeout=300, connect=True, checkvolstatus=False, pad=5)[source]

Attempts to reboot an instance and verify it’s state post reboot. waitconnect-optional-integer representing seconds to wait before attempting to connect to instance after reboot timeout-optional-integer, seconds. If a connection has failed, this timer is used to determine a retry onnect- optional - boolean to indicate whether an ssh session should be established once the expected state has been reached checkvolstatus - optional -boolean to be used to check volume status post start up

reservation = None
reset_ssh_connection()[source]
retry = 1
rootfs_device = 'sda'
scsidevs = []
security_groups = []
set_block_device_prefix()[source]
set_last_status(status=None)[source]
set_rootfs_device()[source]
ssh = None
start_instance_and_verify(timeout=300, state='running', failstate='terminated', connect=True, checkvolstatus=False)[source]

Attempts to start instance and verify state, and reconnects ssh session timeout -optional-time to wait on instance to go to state ‘state’ before failing state -optional-the expected state to signify success, default is running failstate -optional-a state transition that indicates failure, default is terminated connect- optional - boolean to indicate whether an ssh session should be established once the expected state has been reached checkvolstatus - optional -boolean to be used to check volume status post start up

stop_instance_and_verify(timeout=120, state='stopped', failstate='terminated')[source]

Attempts to stop instance and verify the state has gone to stopped state timeout -optional-time to wait on instance to go to state ‘state’ before failing state -optional-the expected state to signify success, default is stopped failstate -optional-a state transition that indicates failure, default is terminated

sys(cmd, verbose=True, code=None, timeout=120)[source]

Issues a command against the ssh connection to this instance Returns a list of the lines from stdout+stderr as a result of the command cmd - mandatory - string, the command to be executed verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds

terminate_and_verify(verify_vols=True, volto=30, timeout=300)[source]

Attempts to terminate the instance and verify delete on terminate state of an ebs root block dev if any. If flagged will attempt to verify the correct state of any volumes attached during the terminate operation.

Parameters:
  • verify_vols (boolean) – boolean used to flag whether or not to check for correct volume state after terminate
  • volto (integer) – timeout used for time in seconds to wait for volumes to detach and become available after terminating the instnace
  • timeout (integer) – timeout in seconds when waiting for an instance to go to terminated state.
tester = None
time_dd(ddcmd)[source]

Executes dd command on instance, parses and returns dd’s data/time stat

timeout = 60
update()[source]
username = None
verbose = True
verify_attached_vol_cloud_status(euvolume)[source]

Confirm that the cloud is showing the state for this euvolume as attached to this instance

virtio_blk = False
vol_write_random_data_get_md5(euvolume, srcdev=None, length=32, timepergig=90, overwrite=False)[source]

Attempts to copy some amount of data into an attached volume, and return the md5sum of that volume A brief check of the first 32 bytes is performed to see if this volume has pre-existing non-zero filled data. If pre-existing data is found, and the overwrite flag is not set then the write is not performed. Returns string with MD5 checksum calculated on ‘length’ bytes from the head of the device. volume - mandatory - boto volume object of the attached volume srcdev - optional - string, the file to copy into the volume timepergig - optional - the time in seconds per gig, used to estimate an adequate timeout period overwrite - optional - boolean. write to volume regardless of whether existing data is found

zero_fill_volume(euvolume)[source]

zero fills the given euvolume with,returns dd’s data/time stat

eulogger Module

Example: import eulogger self.logger = eulogger.Eulogger(name=’euca’) self.log = self.logger.log

self.log.debug(“This is a debug message”) self.log.critical(“this is a critical message”)

class eutester.eulogger.Eulogger(identifier='eulogger', log_level='debug', fdebug='%(message)s', ferr='%(funcName)s():%(lineno)d: %(message)', logfile='', clear=False)[source]

Bases: object

setupLogging(identifier, log_level, fdebug, ferr, logfile, clear)[source]

eupopulator Module

Created on Apr 25, 2012 @author: vic.iglesias@eucalyptus.com

class eutester.eupopulator.EuPopulator(eucaops, config_file=None)[source]

Bases: object

This class is intended to read in a config file using ConfigParser, then create resources based on the config file It is also able to serialize the current resources in a cloud into a file, read in that file and verify that the resources still exist in the same way. Serialization is done with Pickle.

addresses()[source]
buckets()[source]
depopulate()[source]
keypairs()[source]
populate()[source]

Takes the config and creates each of the resources based on their parameters

prefix_generator(size=6, chars='abcdefghijklmnopqrstuvwxyz0123456789')[source]
security_groups()[source]
serialize_resources(output_file='cloud_objects.dat')[source]

Takes a snapshot of the current resources in the system and puts them into a data structure, then pickles this struct into a file. output_file Filename to use when outputing the serialized data, if this is None then the byte stream will be returned

snapshots()[source]
volumes()[source]

euproperties Module

Created on Mar 7, 2012 @author: clarkmatthew Place holder class to provide convenience for testing, modifying, and retrieving Eucalyptus cloud property information Intention is to reduce the time in looking up property names, and values outside of the eutester test lib, etc Note: Debug output for the tester.sys command are controled by the eutester/eucaops object

Sample:

props = EucaProperties(myeutesterobject) #get some property values mysanhost = props.get_storage_sanhost()[0] mysanhostp1 = props.get_storage_sanhost(zone=’PARTI01’)[0]

#use a convenience method to set a property prop.set_storage_sanhost(‘192.168.1.1’,zone=’PARTI01’)

#get the property string value for a given property sanhostp1propertystring = props.get_storage_sanhost(zone=PARTI01)[1]

#reset a cloud property to it’s default value props.reset_property_to_default(sanhostp1propertystring)

exception eutester.euproperties.EuPropertiesException(value)[source]

Bases: exceptions.Exception

class eutester.euproperties.Euproperty(prop_mgr, property_string, servicetype, partition, name, value, mandatory=False)[source]
update()[source]
class eutester.euproperties.Euproperty_manager(tester, verbose=False, debugmethod=None)[source]
debug(msg)[source]

simple method for printing debug. msg - mandatory - string to be printed method - optional - callback to over ride default printing method

debugmethod = None
get_clc()[source]
get_euproperty_by_name(name)[source]
get_property_default_value(prop, ireadthewarning=False)[source]

Note: This hack method is intrusive! It will briefly reset the property This is a temporary method to get a properties default method prop - mandatory - string, eucalyptus property ireadthewarning - mandatory - boolean, to warn user this method is intrusive

get_property_value(prop)[source]

Returns a tuple containing the current property value plus the property string. prop - mandatory - string representing the property to fetch. ecuaops -optional - the eucaops/eutester object to fetch the property from

self.debug(“Getting property:”+prop) prop_string = self.clc.sys(self.cmdpath+’euca-describe-properties -U ‘+str(self.service_url)+’ -I ‘+str(self.access_key)+’ -S ‘+ str(self.secret_key) +’ | grep ‘ + prop, code=0) if (prop_string != []):

value = str(prop_string[0]).split()[2]
else:
raise EuPropertiesException(“describe properties returned null for “+prop)
get_storage_activestoragegroupcleaning(zone='PARTI00')[source]
get_storage_blockstoragemanager(zone='PARTI00')[source]
get_storage_chapuser(zone='PARTI00')[source]
get_storage_clipath(zone='PARTI00')[source]
get_storage_clonestoragegroup(zone='PARTI00')[source]
get_storage_dasdevice(zone='PARTI00')[source]
get_storage_loginscope(zone='PARTI00')[source]
get_storage_lunspallocator(zone='PARTI00')[source]
get_storage_majornumber(zone='PARTI00')[source]
get_storage_maxtotalvolumesizeingb(zone='PARTI00')[source]
get_storage_maxvolumesizeingb(zone='PARTI00')[source]
get_storage_minornumber(zone='PARTI00')[source]
get_storage_ncpaths(zone='PARTI00')[source]
get_storage_quiescetimeseconds(zone='PARTI00')[source]
get_storage_sanhost(zone='PARTI00')[source]
get_storage_sanpassword(zone='PARTI00')[source]
get_storage_sanuser(zone='PARTI00')[source]
get_storage_scpaths(zone='PARTI00')[source]
get_storage_shouldtransfersnapshots(zone='PARTI00')[source]
get_storage_snappercent(zone='PARTI00')[source]
get_storage_storagepool(zone='PARTI00')[source]
get_storage_storeprefix(zone='PARTI00')[source]
get_storage_syncrate(zone='PARTI00')[source]
get_storage_tid(zone='PARTI00')[source]
get_storage_timeoutinmillis(zone='PARTI00')[source]
get_storage_volumesdir(zone='PARTI00')[source]
get_storage_zerofillvolumes(zone='PARTI00')[source]
get_storageinterface(zone='PARTI00')[source]
get_walrus_storagemaxtotalsnapshotsizeingb(tester=None)[source]
parse_euproperty_from_string(str)[source]

Intended to convert a line of ouptut from euca-describe-properties into a euproperty. :param str: line of output, example: “PROPERTY walrus.storagemaxbucketsizeinmb 5120” :returns euproperty

reset_property_to_default(prop)[source]

Sets a property ‘prop’ at eucaops/eutester object ‘eucaops’ to it’s default value Returns new value prop - mandatory - string representing the property to set ucaops - optional - the eucaops/eutester object to set the property at

set_property(prop, value)[source]

Sets the property ‘prop’ at eucaops/eutester object ‘tester’ to ‘value’ Returns new value prop - mandatory - string representing the property to set value - mandatory - string representing the value to set the property to eucaops - optional - the eucaops/eutester object to set the property at

set_storage_activestoragegroupcleaning(boolean, zone='PARTI00')[source]
set_storage_blockstoragemanager(string, zone='PARTI00')[source]
set_storage_chapuser(string, zone='PARTI00')[source]
set_storage_clipath(path, zone='PARTI00')[source]
set_storage_clonestoragegroup(string, zone='PARTI00')[source]
set_storage_dasdevice(value, zone='PARTI00')[source]
set_storage_loginscope(int, zone='PARTI00')[source]
set_storage_lunspallocator(string, zone='PARTI00')[source]
set_storage_majornumber(value, zone='PARTI00')[source]
set_storage_maxtotalvolumesizeingb(value, zone='PARTI00')[source]
set_storage_maxvolumesizeingb(value, zone='PARTI00')[source]
set_storage_minornumber(value, zone='PARTI00')[source]
set_storage_ncpaths(string, zone='PARTI00')[source]
set_storage_quiescetimeseconds(int, zone='PARTI00')[source]
set_storage_sanhost(value, zone='PARTI00')[source]
set_storage_sanpassword(value, zone='PARTI00')[source]
set_storage_sanuser(value, zone='PARTI00')[source]
set_storage_scpaths(string, zone='PARTI00')[source]
set_storage_shouldtransfersnapshots(value, zone='PARTI00')[source]
set_storage_snappercent(value, zone='PARTI00')[source]
set_storage_storagepool(int, zone='PARTI00')[source]
set_storage_storeprefix(value, zone='PARTI00')[source]
set_storage_syncrate(string, zone='PARTI00')[source]
set_storage_tid(value, zone='PARTI00')[source]
set_storage_timeoutinmillis(int, zone='PARTI00')[source]
set_storage_volumesdir(value, zone='PARTI00')[source]
set_storage_zerofillvolumes(value, zone='PARTI00')[source]
set_storageinterface(value, zone='PARTI00')[source]
set_walrus_storagemaxtotalsnapshotsizeingb(value, tester=None)[source]
tester = None
update_property_list()[source]
verbose = False
class eutester.euproperties.Euproperty_type[source]
authentication = 'authentication'
bootstrap = 'bootstrap'
cloud = 'cloud'
cluster = 'cluster'
classmethod get_type_by_string(str)[source]
reporting = 'reporting'
storage = 'storage'
system = 'system'
vmwarebroker = 'vmwarebroker'
walrus = 'walrus'
www = 'www'

euservice Module

class eutester.euservice.Eunode(hostname, partition, tester=None)[source]
class eutester.euservice.Euservice(service_string, tester=None)[source]
disable()[source]
enable()[source]
isDisabled()[source]
isEnabled()[source]
start()[source]
stop()[source]
class eutester.euservice.EuserviceManager(tester)[source]

Bases: object

all_services_operational()[source]
disable(euservice)[source]
enable(euservice)[source]
get(type=None, partition=None, attempt_both=True)[source]
get_all_services()[source]
get_conclusive_enabled_clc()[source]
get_disabled(list_of_services)[source]
get_disabled_clc()[source]
get_disabled_walrus()[source]
get_enabled(list_of_services)[source]
get_enabled_clc()[source]
get_enabled_walrus()[source]
isReachable(address)[source]
modify_process(euservice, command)[source]
modify_service(euservice, state)[source]
populate_nodes()[source]
reset()[source]
start(euservice)[source]
start_all()[source]
stop(euservice)[source]
sync_credentials()[source]
update(name=None)[source]
wait_for_service(euservice, state='ENABLED', attempt_both=True, timeout=600)[source]
class eutester.euservice.Partition(name, service_manager)[source]
ccs = []
get_disabled(list)[source]
get_disabled_cc()[source]
get_disabled_sc()[source]
get_disabled_vb()[source]
get_enabled(list)[source]
get_enabled_cc()[source]
get_enabled_sc()[source]
get_enabled_vb()[source]
instances = []
name = ''
ncs = []
scs = []
vbs = []
volumes = []

eutestcase Module

class eutester.eutestcase.EutesterTestCase(name=None, debugmethod=None, use_default_file=True, default_config='eutester.conf')[source]

Bases: unittest.case.TestCase

add_arg(arg, value)[source]

Description: Adds an arg ‘arg’ within the local testcase args namespace and assigns it ‘value’. If arg exists already in testcase.args, then an exception will be raised.

Parameters:
  • arg (string) – string name of arg to set.
  • value (value) – value to set arg to
clean_method()[source]
color = <eutester.eutestcase.TestColor instance at 0x109aa2098>
compile_all_args()[source]
create_testunit_by_name(name, obj=None, eof=True, autoarg=True, *args, **kwargs)[source]

Description: Attempts to match a method name contained with object ‘obj’, and create a EutesterTestUnit object from that method and the provided positional as well as keyword arguments provided.

Parameters:
  • name (string) – Name of method to look for within instance of object ‘obj’
  • obj (class instance) – Instance type, defaults to self testcase object
  • args (positional arguements) – None or more positional arguments to be passed to method to be run
  • kwargs (keyword arguments) – None or more keyword arguements to be passed to method to be run
create_testunit_from_method(method, *args, **kwargs)[source]
Description: Convenience method calling EutesterTestUnit.
Creates a EutesterTestUnit object from a method and set of arguments to be fed to that method
Parameters:
  • method (method) – The underlying method for this object to wrap, run and provide information on
  • eof (boolean) – Boolean to indicate whether this testunit should cause a test list to end of failure
  • autoarg (boolean) – Boolean to indicate whether to autopopulate this testunit with values from global testcase.args
  • args (list of positional arguments) – the positional arguments to be fed to the given testunit ‘method’
  • kwargs (list of keyword arguements) – list of keyword
Return type:

EutesterTestUnit

Returns:

EutesterTestUnit object

debug(msg, traceback=1, color=None, linebyline=True)[source]

Description: Method for printing debug

type msg: string param msg: Mandatory string buffer to be printed in debug message

type traceback: integer param traceback: integer value for what frame to inspect to derive the originating method and method line number

type color: TestColor color param color: Optional ascii text color scheme. See TestColor for more info.

disable_color()[source]
do_with_args(meth, *args, **kwargs)[source]

Description: Convenience method used to wrap the provided instance_method, function, or object type ‘meth’ and populate meth’s positional and keyword arguments with the local testcase.args created from the CLI and/or config file, as well as the *args and **kwargs variable length arguments passed into this method.

Parameters:
  • meth (method) – A method or class initiator to wrapped/populated with this testcase objects namespace args
  • args (positional arguments) – None or more values representing positional arguments to be passed to ‘meth’ when executed. These will take precedence over local testcase obj namespace args
  • kwargs (keyword arguments) – None or more values reprsenting keyword arguments to be passed to ‘meth’ when executed. These will take precedence over local testcase obj namespace args and positional args
enable_color()[source]
endfailure(msg='')[source]
endsuccess(msg='')[source]
format_line_for_color(msg, color)[source]
get_arg(arg)[source]

Description: Fetchs the value of an arg within the local testcase args namespace. If the arg does not exist, None will be returned.

Parameters:arg (string) – string name of arg to get.
Return type:value
Returns:Value of arguement given, or None if not found
get_args(use_cli=True, file_sections=[])[source]

Description: Method will attempt to retrieve all command line arguments presented through local testcase’s ‘argparse’ methods, as well as retrieve all EuConfig file arguments. All arguments will be combined into a single namespace object held locally at ‘testcase.args’. Note: cli arg ‘config’ must be provided for config file valus to be store in self.args.

Parameters:
  • use_cli (boolean) – Boolean to indicate whether or not to create and read from a cli argparsing object
  • use_default_files – Boolean to indicate whether or not to read default config file at $HOME/.eutester/eutester.conf (not indicated by cli)
  • sections (list) – list of EuConfig sections to read configuration values from, and store in self.args.
Return type:

arparse.namespace obj

Returns:

namespace object with values from cli and config file arguements

get_default_userhome_config(fname='eutester.conf')[source]

Description: Attempts to fetch the file ‘fname’ from the current user’s home dir. Returns path to the user’s home dir default eutester config file.

Parameters:fname (string) – the eutester default config file name
Return type:string
Returns:string representing the path to ‘fname’, the default eutester conf file.
classmethod get_meth_arg_names(meth)[source]

Description: Return varnames within argcount :type:meth: method :param: meth: method to fetch arg names for

Return type:list
Returns:list of strings representing the varnames within argcount for this method
classmethod get_method_fcode(meth)[source]
get_pretty_args(testunit)[source]

Description: Returns a string buf containing formated arg:value for printing later

Type :testunit: Eutestcase.eutestertestunit object
Param :testunit: A testunit object for which the namespace args will be used
Return type:string
Returns:formated string containing args and their values.
classmethod get_testunit_method_arg_dict(testunit)[source]
getline(len)[source]
has_arg(arg)[source]

Description: If arg is present in local testcase args namespace, will return True, else False

Parameters:arg (string) – string name of arg to check for.
Return type:boolean
Returns:True if arg is present, false if not
populate_testunit_with_args(testunit, namespace=None)[source]
Description: Checks a given test unit’s available positional and key word args lists for matching
values contained with the given namespace, by default will use local testcase.args. If testunit’s underlying method has arguments matching the namespace provided, then those args will be applied to the testunits args referenced when running the testunit. Namespace values will not be applied/overwrite testunits, if the testunit already has conflicting values in it’s args(positional) list or kwargs(keyword args) dict.
Type :testunit: Eutestcase.eutestertestunit object
Param :testunit: A testunit object for which the namespace values will be applied
Type :namespace: namespace obj
Param :namespace: namespace obj containing args/values to be applied to testunit. None by default will use local testunit args.
print_test_list_results(list=None, printout=True, printmethod=None)[source]

Description: Prints a formated list of results for a list of EutesterTestUnits

Parameters:
  • list (list) – list of EutesterTestUnits
  • printout (boolean) – boolean to flag whether to print using printmethod or self.debug, or to return a string buffer representing the results output
  • printmethod (method) – method to use for printing test result output. Default is self.debug
print_test_list_short_stats(list, printmethod=None)[source]
classmethod print_testunit_method_arg_values(testunit)[source]
resultdefault(msg, printout=True, color='blueongrey')[source]
resulterr(msg, printout=True, color='failred')[source]
resultfail(msg, printout=True, color='redongrey')[source]
run_method_by_name(name, obj=None, *args, **kwargs)[source]

Description: Find a method within an instance of obj and run that method with either args/kwargs provided or any self.args which match the methods varname.

Parameters:
  • name (string) – Name of method to look for within instance of object ‘obj’
  • obj (class instance) – Instance type, defaults to self testcase object
  • args (positional arguements) – None or more positional arguments to be passed to method to be run
  • kwargs (keyword arguments) – None or more keyword arguements to be passed to method to be run
run_test_case_list(list, eof=True, clean_on_exit=True, printresults=True)[source]

Desscription: wrapper to execute a list of ebsTestCase objects

Parameters:
  • list (list) – list of EutesterTestUnit objects to be run
  • eof (boolean) – Flag to indicate whether run_test_case_list should exit on any failures. If this is set to False it will exit only when a given EutesterTestUnit fails and has it’s eof flag set to True.
  • clean_on_exit (boolean) – Flag to indicate if clean_on_exit should be ran at end of test list execution.
  • printresults (boolean) – Flag to indicate whether or not to print a summary of results upon run_test_case_list completion.
Return type:

integer

Returns:

integer exit code to represent pass/fail of the list executed.

run_test_list_by_name(list)[source]
set_arg(arg, value)[source]

Description: Sets an arg ‘arg’ within the local testcase args namespace to ‘value’. If arg does not exist in testcase.args, then it will be created.

Parameters:
  • arg (string) – string name of arg to set.
  • value (value) – value to set arg to
setup_debugmethod(testcasename=None)[source]
setup_parser(testname=None, description=None, emi=True, zone=True, vmtype=True, keypair=True, credpath=True, password=True, config=True, configblocks=True, ignoreblocks=True, color=True, testlist=True, userdata=True, instance_user=True, instance_password=True, region=True)[source]

Description: Convenience method to setup argparse parser and some canned default arguments, based upon the boolean values provided. For each item marked as ‘True’ this method will add pre-defined command line arguments, help strings and default values. This will then be available by the end script as an alternative to recreating these items on a per script bassis.

Parameters:
  • testname (string) – Name used for argparse (help menu, etc.)
  • description (string) – Description used for argparse (help menu, etc.)
  • emi (boolean) – Flag to present the emi command line argument/option for providing an image emi id via the cli
  • zone (boolean) – Flag to present the zone command line argument/option for providing a zone via the cli
  • vmtype (boolean) – Flag to present the vmtype command line argument/option for providing a vmtype via the cli
  • kepair – Flag to present the keypair command line argument/option for providing a keypair via the cli
  • credpath (boolean) – Flag to present the credpath command line argument/option for providing a local path to creds via the cli
  • password (boolean) – Flag to present the password command line argument/option for providing password

used in establishing machine ssh sessions

Parameters:
  • config (boolean) – Flag to present the config file command line argument/option for providing path to config file
  • configblocks (string list) – Flag to present the configblocks command line arg/option used to provide list of configuration blocks to read from Note: By default if a config file is provided the script will only look for blocks; ‘globals’, and the filename of the script being run.
  • ignoreblocks (string list) – Flag to present the configblocks command line arg/option used to provide list of configuration blocks to ignore if present in configfile Note: By default if a config file is provided the script will look for blocks; ‘globals’, and the filename of the script being run
  • testlist (string list) – Flag to present the testlist command line argument/option for providing a list of testnames to run
  • userdata (boolean) – Flag to present the userdata command line argument/option for providing userdata to instance(s) within test
  • instance_user (boolean) – Flag to present the instance_user command line argument/option for providing an ssh username for instance login via the cli
  • instance_password (boolean) – Flag to present the instance_password command line argument/option for providing a ssh password for instance login via the cli
  • use_color (flag) – Flag to enable/disable use of ascci color codes in debug output.
setuptestcase(name=None, debugmethod=None, use_default_file=True, default_config='eutester.conf')[source]
show_args(args=None)[source]
Description: Prints args names and values for debug purposes.
By default will use the local testcase.args, else args can be provided.
Parameters:args (namespace object) – namespace object to be printed,by default None will print local testcase’s args.
show_self()[source]
startmsg(msg='')[source]
status(msg, traceback=2, b=1, a=0, testcolor=None)[source]

Description: Convenience method to format debug output

Parameters:
  • msg (string) – The string to be formated and printed via self.debug
  • traceback (integer) – integer value for what frame to inspect to derive the originating method and method line number

:param b:number of blank lines to print before msg

:param a:number of blank lines to print after msg

Parameters:testcolor (TestColor color) – Optional TestColor ascii color scheme
class eutester.eutestcase.EutesterTestResult[source]

standardized test results

failed = 'failed'
not_run = 'not_run'
passed = 'passed'
class eutester.eutestcase.EutesterTestUnit(method, *args, **kwargs)[source]

Description: Convenience class to run wrap individual methods, and run and store and access results.

type method: method param method: The underlying method for this object to wrap, run and provide information on

type args: list of arguments param args: the arguments to be fed to the given ‘method’

type eof: boolean param eof: boolean to indicate whether a failure while running the given ‘method’ should end the test case exectution.

classmethod create_testcase_from_method(method, eof=False, *args, **kwargs)[source]

Description: Creates a EutesterTestUnit object from a method and set of arguments to be fed to that method

type method: method param method: The underlying method for this object to wrap, run and provide information on

type args: list of arguments param args: the arguments to be fed to the given ‘method’

get_test_method_description()[source]

Description: Attempts to derive test unit description for the registered test method. Keys off the string “Description:” preceded by any amount of white space and ending with either a blank line or the string “EndDescription”. This is used in debug output when providing info to the user as to the method being run as a testunit’s intention/description.

run()[source]

Description: Wrapper which attempts to run self.method and handle failures, record time.

set_kwarg(kwarg, val)[source]
class eutester.eutestcase.TestColor[source]
backgrounds = {'blue': 44, 'setasdefault': 49, 'black': 40, 'yellow': 43, 'cyan': 46, 'green': 42, 'magenta': 45, 'white': 47, 'red': 41}
canned_colors = {'reset': '\x1b[0m', 'blinkwhiteonred': '\x1b[1;5;37;41m', 'whiteongreen': '\x1b[1;37;42m', 'failred': '\x1b[101m', 'whiteonblue': '\x1b[1;37;44m', 'blueongrey': '\x1b[1;34;47m', 'redongrey': '\x1b[1;31;47m', 'red': '\x1b[31m'}
foregrounds = {'blue': 34, 'setasdefault': 39, 'black': 30, 'yellow': 33, 'cyan': 36, 'green': 32, 'magenta': 35, 'white': 37, 'red': 31}
formats = {'reset': '0', 'dim': '2', 'reverse': '7', 'blink': '5', 'uline': '4', 'hidden': '8', 'bold': '1'}
classmethod get_bg_from_string(bg)[source]
classmethod get_canned_color(color)[source]
classmethod get_color(fmt=0, fg='', bg='')[source]

Description: Method to return ascii color codes to format terminal output. Examples:

blinking_red_on_black = get_color(‘blink’, ‘red’, ‘blue’) bold_white_fg = get_color(‘bold’, ‘white, ‘’) green_fg = get_color(‘’,’green’,’‘)

print bold_white_fg+”This text is bold white”+TestColor.reset

Parameters:
  • fmt (color attribute) – An integer or string that represents an ascii color attribute. see TestColor.formats
  • fg (ascii foreground attribute) – An integer or string that represents an ascii foreground color attribute. see TestColor.foregrounds
  • bg (ascii background attribute) – An integer or string that represents an ascii background color attribute. see TestColor.backgrounds
classmethod get_fg_from_string(fg)[source]
classmethod get_format_from_string(format)[source]
reset = '\x1b[0m'

euvolume Module

Created on Mar 7, 2012 @author: clarkmatthew Place holder for volume test specific convenience methods+objects to extend boto’s volume class

class eutester.euvolume.EuVolume(connection=None)[source]

Bases: boto.ec2.volume.Volume, eutester.taggedresource.TaggedResource

clouddev = ''
eutest_ageatstatus = None

Note: Different hypervisors will honor the requested cloud dev differently, so the requested device can not be relied up as the device it attached to on the guest ‘guestdev’

eutest_cmdstart = None
eutest_cmdtime = None
eutest_createorder = None
eutest_failmsg = None
eutest_laststatus = None
eutest_laststatustime = None
guestdev = ''
classmethod make_euvol_from_vol(volume, tester=None, cmdstart=None)[source]
md5 = None
md5len = 32
printself(title=True, footer=True, printmethod=None)[source]
set_last_status(status=None)[source]
tester = None
update()[source]

machine Module

class eutester.machine.Distro[source]
centos_5 = <eutester.machine.DistroRelease instance at 0x1089fdf80>
centos_6 = <eutester.machine.DistroRelease instance at 0x1089fdef0>
debian_squeeze = <eutester.machine.DistroRelease instance at 0x1089fddd0>
debian_wheezy = <eutester.machine.DistroRelease instance at 0x1089fde18>
fedora_18 = <eutester.machine.DistroRelease instance at 0x1089fdfc8>
classmethod get_distros(Distro)[source]
rhel_5 = <eutester.machine.DistroRelease instance at 0x1089fdf38>
rhel_6 = <eutester.machine.DistroRelease instance at 0x1089fde60>
ubuntu_lucid = <eutester.machine.DistroRelease instance at 0x1089fdcf8>
ubuntu_precise = <eutester.machine.DistroRelease instance at 0x1089fdd88>
vmware_4 = <eutester.machine.DistroRelease instance at 0x108a1b098>
vmware_5 = <eutester.machine.DistroRelease instance at 0x108a1b050>
class eutester.machine.DistroName[source]
centos = 'centos'
debian = 'debian'
fedora = 'fedora'
rhel = 'rhel'
ubuntu = 'ubuntu'
vmware = 'vmware'
class eutester.machine.DistroRelease(distro_name, distro_number, distro_release='', package_manager=None)[source]
class eutester.machine.Machine(hostname, distro='', distro_ver='', arch='', source='', components='', connect=True, password=None, keypath=None, username='root', timeout=120, retry=2, debugmethod=None, verbose=True)[source]
add_repo(url, name='test-repo')[source]
chown(user, path)[source]
cmd(cmd, verbose=True, timeout=120, listformat=False, cb=None, cbargs=[])[source]

Issues a command against the ssh connection to this instance returns dict containing:

[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exit (exitcode) of the command, in the case a call back fires, this status code is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

cmd - mandatory - string, the command to be executed verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds listformat -optional - specifies returned output in list of lines, or single string buffer cb - optional - call back function, accepting string buffer, returning true false see sshconnection for more info

convert_to_distro(distro_name, distro_release)[source]
debug(msg)[source]

Used to print debug, defaults to print() but over ridden by self.debugmethod if not None msg - mandatory -string, message to be printed

dump_netfail_info(ip=None, mac=None, pass1=None, pass2=None, showpass=True, taillength=50)[source]

Debug method to provide potentially helpful info from current machine when debugging connectivity issues.

found(command, regex, verbose=True)[source]

Returns a Boolean of whether the result of the command contains the regex

get_available(path, unit=1)[source]

Return df output’s available field. By default this is KB. path - optional -string. unit - optional -integer used to divide return value. Can be used to convert KB to MB, GB, TB, etc..

get_df_info(path=None, verbose=True)[source]

Return df’s output in dict format for a given path. If path is not given will give the df info for the current working dir used in the ssh session this command is executed in (ie: /home/user or /root). path - optional -string, used to specifiy path to use in df command. Default is PWD of ssh shelled command verbose - optional -boolean, used to specify whether or debug is printed during this command. Example:

dirpath = ‘/disk1/storage’ dfout = self.get_df_info(path=dirpath) available_space = dfout[‘available’] mounted_on = dfout[‘mounted’] filesystem = dfout[‘filesystem’]
get_file_groupid(path)[source]
get_file_perms_flag(path)[source]
get_file_size(path)[source]
get_file_stat(path)[source]
get_file_userid(path)[source]
get_installed_packages()[source]
get_masked_pass(pwd, firstlast=True, charcount=True, show=False)[source]

format password for printing options: pwd - string- the text password to format firstlast -boolean - show the first and last characters in pwd charcount -boolean - print a “*” for each char in pwd, otherwise return fixed string ‘hidden‘ show - boolean - convert pwd to str() and return it in plain text

get_package_info()[source]
install(package, nogpg=False)[source]
interrupt_network(time=120, interface='eth0')[source]
mkfs(partition, type='ext3')[source]
mount(device, path)[source]
ping_check(host)[source]
ping_cmd(host, count=2, pingtimeout=10, commandtimeout=120, listformat=False, verbose=True)[source]
poll_log(log_file='/var/log/messages')[source]
reboot(force=True)[source]
refresh_connection()[source]
refresh_ssh()[source]
save_all_logs(path='logs')[source]

Save log buffers to a file

save_log(log_file, path='logs')[source]

Save log buffer for log_file to the path to a file

start_log(log_file='/var/log/messages')[source]

Start thread to poll logs

stop_log(log_file='/var/log/messages')[source]

Terminate thread that is polling logs

str_found(buf, regex, search=True)[source]

Return True if given regex matches against given string

str_found_cb(buf, regex, verbose, search=True)[source]

Return sshcbreturn type setting stop to True if given regex matches against given string buf

sys(cmd, verbose=True, timeout=120, listformat=True, code=None)[source]

Issues a command against the ssh connection to this instance Returns a list of the lines from stdout+stderr as a result of the command

sys_until_found(cmd, regex, verbose=True, timeout=120, listformat=True)[source]

Run a command until output of command satisfies/finds regex or EOF is found. returns dict containing:

[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exit (exitcode) of the command, in the case a call back fires, this status code is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

cmd - mandatory - string, the command to be executed regex - mandatory - regex to look for verbose - optional - boolean flag to enable debug timeout - optional - command timeout in seconds listformat -optional - specifies returned output in list of lines, or single string buffer

update_repos()[source]
upgrade(package=None, nogpg=False)[source]
wget_remote_image(url, path=None, user=None, password=None, retryconn=True, timeout=300)[source]
wget_status_cb(buf)[source]

repoutils Module

class eutester.repoutils.Apt(machine)[source]

Bases: eutester.repoutils.PackageManager

add_repo(url, name=None)[source]
install(package)[source]
update_repos()[source]
upgrade(package=None)[source]
class eutester.repoutils.Package[source]
name = None
version = None
class eutester.repoutils.PackageManager[source]
add_repo(url, name=None)[source]
get_installed_packages()[source]
get_package_info()[source]
install(package)[source]
machine = None
name = None
update_repos()[source]
upgrade(package=None)[source]
class eutester.repoutils.RepoUtils(machine, package_manager='yum')[source]
class eutester.repoutils.Yum(machine)[source]

Bases: eutester.repoutils.PackageManager

add_repo(url, name=None)[source]
install(package, nogpg=False)[source]
update_repos()[source]
upgrade(package=None, nogpg=False)[source]

sshconnection Module

Created on Mar 7, 2012 @author: clarkmatthew

simple class to establish an ssh session example usage:

import sshconnection ssh = SshConnection( ‘192.168.1.1’, keypath=’/home/testuser/keyfile.pem’)

#use sys() to get either a list of output lines or a single string buffer depending on listformat flag output = ssh.sys(‘ls /dev/sd*’,timeout=10) print output[0] print ssh.lastcmd+” exited with code: “+str(ssh.lastexitcode)

#...or use cmd to get a dict of output, exitstatus, and elapsed time to execute... out = ssh.cmd(‘ping 192.168.1.2 -c 1 -W 5’)

print out[‘cmd’]+” exited with status:”+out[‘status’]+”, elapsed time:”+out[‘elapsed’] print out[‘output’]
exception eutester.sshconnection.CommandTimeoutException(value)[source]

Bases: exceptions.Exception

class eutester.sshconnection.SshCbReturn(stop=False, statuscode=-1, settimer=0, buf=None, nextargs=[])[source]

Used to return data from an ssh cmd callback method that can be used to handle output as it’s rx’d instead of... waiting for the cmd to finish and returned buffer. See SshConnection.cmd() for more info. The call back must return type SshCbReturn.

If cb returns stop==True, recv loop will end, and channel will be closed, cmd will return. if cb settimer is > 0, timer timeout will be adjusted for this time if cb statuscode is != -1 cmd status will return with this value if cb nextargs is set, the next time cb is called these args will be passed instead if cb buf is not None, the cmd[‘output’] buffer will be appended with this buf
class eutester.sshconnection.SshConnection(host, proxy=None, keypair=None, keypath=None, password=None, username='root', timeout=60, retry=1, debugmethod=None, verbose=False)[source]
close()[source]
cmd(cmd, verbose=None, timeout=120, readtimeout=20, listformat=False, cb=None, cbargs=[])[source]

Runs a command ‘cmd’ within an ssh connection. Upon success returns dict representing outcome of the command. Returns dict:

[‘cmd’] - The command which was executed [‘output’] - The std out/err from the executed command [‘status’] - The exit (exitcode) of the command, in the case a call back fires, this status code is unreliable. [‘cbfired’] - Boolean to indicate whether or not the provided callback fired (ie returned False) [‘elapsed’] - Time elapsed waiting for command loop to end.

Arguments: cmd - mandatory - string representing the command to be run against the remote ssh session verbose - optional - will default to global setting, can be set per cmd() as well here timeout - optional - integer used to timeout the overall cmd() operation in case of remote blocking listformat - optional - boolean, if set returns output as list of lines, else a single buffer/string cb - optional - callback, method that can be used to handle output as it’s rx’d instead of...

waiting for the cmd to finish and return buffer. Must accept string buffer, and return an integer to be used as cmd status. Must return type ‘sshconnection.SshCbReturn’ If cb returns stop, recv loop will end, and channel will be closed. if cb settimer is > 0, timer timeout will be adjusted for this time if cb statuscode is != -1 cmd status will return with this value if cb nextargs is set, the next time cb is called these args will be passed instead

cbargs - optional - list of arguments to be appended to output buffer and passed to cb

cmd_not_executed_code = -99
cmd_timeout_err_code = -100
debug(msg)[source]

simple method for printing debug. msg - mandatory - string to be printed method - optional - callback to over ride default printing method

get_ssh_connection(hostname, username='root', password=None, keypath=None, timeout=60, retry=1)[source]

Create a paramiko ssh session to hostname. Will attempt to authenticate first with a keypath if provided, if the sshkey file path is not provided. username and password will be used to authenticate. This leaves out the case where a password is passed as the password needed to unlock the key file. This 3rd case may need to be added but may mask failures in tests for key inseration when using tests who’s images have baked in passwords for login access(tbd). Upon success returns a paramiko sshclient with an established connection. hostname - mandatory - hostname or ip to establish ssh connection with username - optional - username used to authenticate ssh session password - optional - password used to authenticate ssh session keypath - optional - full path to sshkey file used to authenticate ssh session timeout - optional - tcp timeout retry - optional - amount of retry attempts to establish ssh connection for errors outside of authentication

refresh_connection()[source]
ssh_sys_timeout(chan, start, cmd)[source]

callback to be scheduled during ssh cmds which have timed out. chan - paramiko channel to be closed start - time.time() used to calc elapsed time when this fired for debug

sys(cmd, verbose=False, timeout=120, listformat=True, code=None)[source]

Issue a command cmd and return output in list format cmd - mandatory - string representing the command to be run against the remote ssh session verbose - optional - will default to global setting, can be set per cmd() as well here timeout - optional - integer used to timeout the overall cmd() operation in case of remote blockingd

xmlrunner Module

XML Test Runner for PyUnit

class eutester.xmlrunner.XMLTestRunner(stream=None)[source]

Bases: object

A test runner that stores results in XML format compatible with JUnit.

XMLTestRunner(stream=None) -> XML test runner

The XML file is written to the supplied stream. If stream is None, the results are stored in a file called TEST-<module>.<class>.xml in the current working directory (if not overridden with the path property), where <module> and <class> are the module and class name of the test class.

path

The path where the XML files are stored.

This property is ignored when the XML file is written to a file stream.

run(test)[source]

Run the given test case or test suite.

class eutester.xmlrunner.XMLTestRunnerTest(methodName='runTest')[source]

Bases: unittest.case.TestCase

class NullStream[source]

Bases: object

A file-like object that discards everything written to it.

write(buffer)[source]
XMLTestRunnerTest.setUp()[source]
XMLTestRunnerTest.test_error()[source]

Regression test: Check whether a test run with a erroneous test matches a previous run.

XMLTestRunnerTest.test_failure()[source]

Regression test: Check whether a test run with a failing test matches a previous run.

XMLTestRunnerTest.test_no_tests()[source]

Regression test: Check whether a test run without any tests matches a previous run.

XMLTestRunnerTest.test_stderr_capture()[source]

Regression test: Check whether a test run with output to stderr matches a previous run.

XMLTestRunnerTest.test_stdout_capture()[source]

Regression test: Check whether a test run with output to stdout matches a previous run.

XMLTestRunnerTest.test_success()[source]

Regression test: Check whether a test run with a successful test matches a previous run.

XMLTestRunnerTest.test_unittests_changing_stderr()[source]

Check whether the XMLTestRunner recovers gracefully from unit tests that change stderr, but don’t change it back properly.

XMLTestRunnerTest.test_unittests_changing_stdout()[source]

Check whether the XMLTestRunner recovers gracefully from unit tests that change stdout, but don’t change it back properly.

Contents