local test run complete
This commit is contained in:
parent
de403151a9
commit
69eb2fccfd
@ -109,56 +109,30 @@ def start(args):
|
||||
clouds(args)
|
||||
sys.exit(1)
|
||||
|
||||
# run the damn test
|
||||
t = Tester(args.cloud_id)
|
||||
results = t.run_local()
|
||||
|
||||
# store the results
|
||||
test = db.query(Test).filter_by(cloud_id=args.cloud_id).first()
|
||||
|
||||
# if cloud doesn't have a test id already or the test id isn't specified
|
||||
if test is None:
|
||||
# creat a new test
|
||||
print 'Adding a new test.'
|
||||
test = Test(args.cloud_id)
|
||||
# creat a new test
|
||||
print 'Adding a new test.'
|
||||
test = Test(args.cloud_id)
|
||||
test.config = t.config
|
||||
db.add(test)
|
||||
db.commit()
|
||||
print 'test added with id: %s' % test.id
|
||||
|
||||
#test.config =
|
||||
db.add(test)
|
||||
|
||||
# TODO tie in config generation here
|
||||
db.commit()
|
||||
print 'test added with id: %s' % test.id
|
||||
|
||||
else:
|
||||
print 'existing test.. loaded it has id: %s ' % test.id
|
||||
|
||||
# weather we already have a test or we just loaded it .. we can now check its status
|
||||
# what is the current status?
|
||||
test_status = db.query(TestStatus).filter_by(test_id=test.id).order_by(TestStatus.id.desc()).first()
|
||||
|
||||
if test_status is None:
|
||||
# no entries in the status log.. add 'new'
|
||||
test_status = TestStatus(test.id, 'new')
|
||||
db.add(test_status)
|
||||
db.commit()
|
||||
|
||||
print 'status is: %s' % test_status.message
|
||||
|
||||
if test_status.message in ('stalled','failed'):
|
||||
# stalled: clean up , trigger clean start new test run
|
||||
print 'Test has stalled or failed and needs to be kicked'
|
||||
status(args)
|
||||
|
||||
elif test_status.message in ('ready','finished','new','canceled'):
|
||||
#finished, new, canceled: trigger clean start new test run
|
||||
print 'start clean and run'
|
||||
test_status = TestStatus(test.id, 'running')
|
||||
db.add(test_status)
|
||||
db.commit()
|
||||
|
||||
t = Tester(args.cloud_id)
|
||||
t.run()
|
||||
|
||||
elif test_status.message in ('running'):
|
||||
# running: report the current status
|
||||
print 'already running '
|
||||
status(args)
|
||||
# do cleanup and then mark the last status to 'canceled'
|
||||
test_result = TestResults()
|
||||
test_result.test_id = test.id
|
||||
test_result.blob = result
|
||||
|
||||
|
||||
db.add(test_result)
|
||||
db.commit()
|
||||
|
||||
|
||||
def status(args):
|
||||
|
@ -16,13 +16,14 @@
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
from subprocess import call
|
||||
from textwrap import dedent
|
||||
from refstack.common.tempest_config import TempestConfig
|
||||
import testrepository.repository.file
|
||||
from testrepository import ui
|
||||
from testrepository.commands import run
|
||||
#from testrepository.commands import run
|
||||
from testrepository.commands import init
|
||||
|
||||
from fabric.api import run
|
||||
|
||||
class TestRepositoryUI(ui.AbstractUI):
|
||||
"""nothing"""
|
||||
@ -75,11 +76,9 @@ class TestRepositorySource(object):
|
||||
self._ui.c = self.testr_directory+'tempest.conf'
|
||||
|
||||
cmd = run.run(self._ui)
|
||||
try:
|
||||
res = cmd.execute()
|
||||
finally:
|
||||
os.chdir(here)
|
||||
|
||||
|
||||
res = cmd.execute()
|
||||
|
||||
|
||||
def testrepository_last_stream(self):
|
||||
factory = testrepository.repository.file.RepositoryFactory()
|
||||
@ -133,23 +132,40 @@ class Tester(object):
|
||||
# setup the repo wrapper.. this creates the repo if its not already there
|
||||
tr = TestRepositorySource(self.test_path)
|
||||
|
||||
"""TODO: So this is supposed to use the testr wrapper to trigger a run.. however..
|
||||
I am completly blocked on how to make it work the right way.. so I am moving on
|
||||
for now once the congigs are setup and repo initiated it will call a subprocess
|
||||
run the command .. THEN query the repo for the last set of results and store the
|
||||
subunit stream.
|
||||
|
||||
# run tests
|
||||
tr.run()
|
||||
|
||||
#tr.run()
|
||||
"""
|
||||
|
||||
print "starting test"
|
||||
call([self.test_path+'runtests.sh']) # replace this
|
||||
print "finished with tests"
|
||||
|
||||
# get back the results
|
||||
result = tr.testrepository_last_stream()
|
||||
|
||||
# write results to database maybe .. or return them .. not sure which ..
|
||||
return result.read()
|
||||
|
||||
#return None
|
||||
|
||||
def write_config(self, path):
|
||||
"""writes config to path specified"""
|
||||
# get the config
|
||||
print "writing configs %s" % path
|
||||
|
||||
output = self.tempest_config.build_config_from_keystone()
|
||||
self.config = self.tempest_config.build_config_from_keystone()
|
||||
|
||||
runtests_script = """#!/bin/bash
|
||||
cd %s
|
||||
testr run
|
||||
exit $?""" % path
|
||||
|
||||
"""TODO make this cleaner"""
|
||||
testr_output = """[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
@ -158,10 +174,14 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
group_regex=([^\.]*\.)*"""
|
||||
|
||||
with open(path+"runtests.sh", "w") as runtests_script_file:
|
||||
runtests_script_file.write(runtests_script)
|
||||
|
||||
os.chmod(path+"runtests.sh", 0744)
|
||||
|
||||
with open(path+"tempest.conf", "w") as config_file:
|
||||
config_file.write(output)
|
||||
config_file.write(self.config)
|
||||
|
||||
with open(path+".testr.conf", "w") as testr_config_file:
|
||||
testr_config_file.write(testr_output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user