This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding the beginning of the test framework
- Loading branch information
BuzzTroll
committed
Oct 15, 2010
1 parent
1060f06
commit 08a2b8f
Showing
14 changed files
with
393 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,135 @@ | ||
# See TODO.txt | ||
# See TODO.txt | ||
import epumgmt.main.em_args as em_args | ||
import epumgmt.main.em_core as em_core | ||
from epumgmt.api.exceptions import * | ||
import string | ||
import sys | ||
import time | ||
|
||
import logging | ||
|
||
from epumgmt.api.exceptions import * | ||
from epumgmt.main import get_class_by_keyword, get_all_configs | ||
from epumgmt.main import Modules, ACTIONS | ||
import epumgmt.main.em_core_creation as em_core_creation | ||
import epumgmt.main.em_core_eventgather as em_core_eventgather | ||
import epumgmt.main.em_core_fetchkill as em_core_fetchkill | ||
import epumgmt.main.em_core_findworkers as em_core_findworkers | ||
import epumgmt.main.em_core_logfetch as em_core_logfetch | ||
import epumgmt.main.em_core_persistence as em_core_persistence | ||
import epumgmt.main.em_core_status as em_core_status | ||
import epumgmt.main.em_core_termination as em_core_termination | ||
|
||
|
||
control_args = {} | ||
for k in em_args.ALL_EC_ARGS_LIST: | ||
control_args[k.name] = k | ||
|
||
class EPUMgmtOpts(object): | ||
|
||
def __init__(self, name=None, conf_file=None, cmd_opts=None): | ||
""" | ||
Create an option set. All parameters are default except for | ||
the mandatory ones which are required to create the object. | ||
Alternatively the values in this object can be populated with a | ||
command line option parsed structure. | ||
""" | ||
# create a dictionary of command line options. | ||
self.conf = conf_file | ||
self.name = name | ||
|
||
if cmd_opts: | ||
for k in control_args: | ||
ca = control_args[k] | ||
ca.value = cmd_opts.__dict__[k] | ||
|
||
if self.conf == None: | ||
msg = "The conf_file argument is required" | ||
raise InvalidInput(msg) | ||
if self.name == None: | ||
msg = "The name argument is required" | ||
raise InvalidInput(msg) | ||
|
||
def __setattr__(self, name, value): | ||
if name not in control_args: | ||
raise InvalidInput("No such option %s" % (name)) | ||
ca = control_args[name] | ||
ca.value = value | ||
|
||
def __getattr__(self, name): | ||
if name not in control_args: | ||
raise InvalidInput("No such option %s" % (name)) | ||
ca = control_args[name] | ||
return ca.value | ||
|
||
class EPUMgmtAction(object): | ||
|
||
def __init__(self, opts): | ||
ac = get_all_configs(opts.conf) | ||
|
||
p_cls = get_class_by_keyword("Parameters", allconfigs=ac) | ||
self.p = p_cls(ac, opts) | ||
|
||
c_cls = get_class_by_keyword("Common", allconfigs=ac) | ||
self.c = c_cls(self.p) | ||
|
||
event_gather_cls = self.c.get_class_by_keyword("EventGather") | ||
event_gather = event_gather_cls(self.p, self.c) | ||
|
||
iaas_cls = self.c.get_class_by_keyword("IaaS") | ||
iaas = iaas_cls(self.p, self.c) | ||
|
||
persistence = em_core_persistence.Persistence(self.p, self.c) | ||
|
||
runlogs_cls = self.c.get_class_by_keyword("Runlogs") | ||
runlogs = runlogs_cls(self.p, self.c) | ||
|
||
services_cls = self.c.get_class_by_keyword("Services") | ||
services = services_cls(self.p, self.c) | ||
|
||
event_gather.validate() | ||
iaas.validate() | ||
persistence.validate() | ||
runlogs.validate() | ||
services.validate() | ||
|
||
self.m = Modules(event_gather, iaas, persistence, runlogs, services) | ||
|
||
def set_logfile(self, fname): | ||
|
||
self.c.log = logging.getLogger("epu_test_logger") | ||
|
||
def create(self, runname, haservice): | ||
return em_core_creation.create(self.p, self.c, self.m, runname) | ||
|
||
def update(self, runname): | ||
return em_core_eventgather.update_events(self.p, self.c, self.m, runname) | ||
|
||
def kill(self, runname): | ||
try: | ||
em_core_findworkers.find(self.p, self.c, self.m, ACTIONS.KILLRUN, runname, once=True) | ||
em_core_logfetch.fetch_all(self.p, self.c, self.m, runname) | ||
except KeyboardInterrupt: | ||
raise | ||
except: | ||
self.c.log.exception("Fetch failed, moving on to terminate anyhow") | ||
return em_core_termination.terminate(self.p, self.c, self.m, runname) | ||
|
||
|
||
def fetch_kill(self, runname): | ||
em_core_findworkers.find(self.p, self.c, self.m, ACTIONS.FETCH_KILL, runname, once=True) | ||
em_core_fetchkill.fetch_kill(self.p, self.c, self.m, runname) | ||
|
||
def logfetch(self, runname): | ||
return em_core_logfetch.fetch_all(self.p, self.c, self.m, runname) | ||
|
||
def findworkers(self, runname, once=False): | ||
return em_core_findworkers.find(self.p, self.c, self.m, ACTIONS.FIND_WORKERS_ONCE, runname) | ||
|
||
def status(self, runname): | ||
return em_core_status.status(self.p, self.c, self.m, runname) | ||
|
||
def epumgmt_run(opts, dbgmsgs=None): | ||
em_core.core(opts, dbgmsgs=dbgmsgs) | ||
|
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ def create(p, c, m, run_name): | |
msg += "\n\nSSH suggestion:\n%s" % ' '.join(sshcmd) | ||
c.log.info(msg) | ||
|
||
return vm |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
import nose.tools | ||
import sys | ||
import os | ||
import uuid | ||
|
||
from epumgmt.api import * | ||
|
||
import run_rabbit | ||
|
||
class TestSimpleOps(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.runname = str(uuid.uuid1()).replace("-", "") | ||
conf = os.path.join(os.environ['EPUMGMT_HOME'], "etc/epumgmt/main.conf") | ||
self.epu_opts = EPUMgmtOpts(conf_file=conf) | ||
self.my_vars_file = os.environ['EPU_TEST_VARS'] | ||
self.epu_opts.jsonvars = self.my_vars_file | ||
self.epu_action = EPUMgmtAction(self.epu_opts) | ||
self.epu_action.set_logfile(os.path.join(os.environ['EPUMGMT_HOME'], "tests/tests.logs")) | ||
|
||
|
||
def tearDown(self): | ||
self.epu_action.killrun(self.runname) | ||
|
||
def test_main_sequence(self): | ||
self.epu_opts.haservice = "provisioner" | ||
self.epu_action.create(self.runname) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#/bin/bash | ||
|
||
PYTHON_EXE="/usr/bin/env python" | ||
|
||
EPU_HOME_REL="`dirname $0`/.." | ||
export EPUMGMT_HOME=`cd $EPU_HOME_REL; pwd` | ||
NIMBUS_CONTROL_PYLIB="$NIMBUS_CONTROL_DIR/lib/python" | ||
NIMBUS_CONTROL_PYSRC="$NIMBUS_CONTROL_DIR/src/python" | ||
PYTHONPATH="$EPUMGMT_HOME/lib/python:$EPUMGMT_HOME/src/python" | ||
export PYTHONPATH | ||
|
||
|
||
TESTS_DIR_REL="`dirname $0`" | ||
TESTS_DIR=`cd $TESTS_DIR_REL; pwd` | ||
|
||
cd $TESTS_DIR | ||
|
||
json_file=`mktemp` | ||
out_file=`mktemp` | ||
export EPU_TEST_VARS=$json_file | ||
rabbit_instance= | ||
|
||
function on_exit() | ||
{ | ||
rm -f $json_file | ||
rm -f $out_file | ||
} | ||
|
||
trap on_exit EXIT | ||
|
||
|
||
echo "running rabbitmq VM on ec2, this may take a bit" | ||
./run_rabbit.py $json_file $EPU_RABBIT_ID | tee $out_file | ||
if [ $PIPESTATUS -ne 0 ]; then | ||
echo "first attempt at rabbit failed. trying again without instance id" | ||
./run_rabbit.py $json_file | tee $out_file | ||
if [ $PIPESTATUS -ne 0 ]; then | ||
echo "could not start rabbit, sorry" | ||
exit 1 | ||
fi | ||
fi | ||
rabbit_instance=`tail -n 1 $out_file` | ||
export EPU_RABBIT_ID=$rabbit_instance | ||
|
||
echo $rabbit_instance | ||
echo "export EPU_RABBIT_ID=$rabbit_instance" > test_env.sh | ||
|
||
failed_tests="" | ||
cd scripts | ||
final_rc=0 | ||
for t in *tests.py | ||
do | ||
$PYTHON_EXE $t | ||
if [ $? -ne 0 ]; then | ||
failed_tests="$t $failed_tests" | ||
final_rc=1 | ||
fi | ||
done | ||
#nosetests *tests.py | ||
|
||
exit $final_rc |
Oops, something went wrong.