Fix issue with snapshot name on error

In patching tests, when error happens
identical snapshot names was used in case
of error, so we can not revert all errored envs.

Change-Id: I0d8bde7989f4bacaec728759b060bd53f9f17cf7
This commit is contained in:
Tatyana Leontovich 2014-08-04 19:20:15 +00:00
parent 6b05280621
commit 342796c683
4 changed files with 54 additions and 20 deletions

View File

@ -53,16 +53,22 @@ def log_snapshot_on_error(func):
except SkipTest:
pass
except Exception:
name = 'error_%s' % func.__name__
description = "Failed in method '%s'." % func.__name__
logger.info("args is {0}".format(args[0].snapshot))
if args and args[0].snapshot:
name = 'error_%s' % args[0].snapshot
description = "Failed in method '%s'." % args[0].snapshot
else:
name = 'error_%s' % func.__name__
description = "Failed in method '%s'." % func.__name__
if args[0].env is not None:
try:
create_diagnostic_snapshot(args[0].env,
"fail", func.__name__)
except Exception:
"fail", name)
except:
logger.error(traceback.format_exc())
raise
finally:
logger.debug(args)
args[0].env.make_snapshot(snapshot_name=name[-50:],
description=description,
is_make=True)

View File

@ -0,0 +1,29 @@
update_templ = """Update os on {0}
Scenario:
1. Revert environment {1}
2. Upload tarball
3. Check that it uploaded
4. Extract data
5. Get available releases
6. Run update script
7. Check that new release appears
8. Put new release into cluster
9. Run cluster update
10. Run OSTF
11. Create snapshot
"""
rollback_templ = """Rollback os on {0}
Scenario:
1. Revert patched environment {1}
2. Get release ids
2. Identify release id for rollback
3. Run rollback
4. Check that rollback was successful
5. Run OSTF
6. Create snapshot
"""

View File

@ -1,5 +1,5 @@
def run_tests():
from proboscis import TestProgram
from proboscis import TestProgram # noqa
from tests import test_admin_node # noqa
from tests import test_ceph # noqa
@ -23,5 +23,6 @@ def run_tests():
# Run Proboscis and exit.
TestProgram().run_and_exit()
if __name__ == '__main__':
run_tests()

View File

@ -30,15 +30,11 @@ class TestPatch(TestBasic):
def __init__(self, snapshot):
super(TestPatch, self).__init__()
self.snapshot = snapshot
self.deploy_and_patch.__func__.func_name = "{0}_and_patch".format(
self.snapshot)
self.deploy_and_rollback.__func__.func_name = "{0}_rollback".format(
self.snapshot)
@test
@log_snapshot_on_error
def deploy_and_patch(self):
"""Update os on reverted cluster
"""Update OS on reverted env
Scenario:
1. Revert environment
@ -46,7 +42,7 @@ class TestPatch(TestBasic):
3. Check that it uploaded
4. Extract data
5. Get available releases
6. Run update script
6. Run upgrade script
7. Check that new release appears
8. Put new release into cluster
9. Run cluster update
@ -54,9 +50,11 @@ class TestPatch(TestBasic):
11. Create snapshot
"""
logger.info("snapshot name is {0}".format(self.snapshot))
if not self.env.get_virtual_environment().has_snapshot(self.snapshot):
raise SkipTest()
logger.error('There is no shaphot found {0}'.format(self.snapshot))
raise SkipTest('Can not find snapshot {0}'.format(self.snapshot))
self.env.revert_snapshot(self.snapshot)
@ -167,22 +165,23 @@ class TestPatch(TestBasic):
@test(depends_on=[deploy_and_patch])
@log_snapshot_on_error
def deploy_and_rollback(self):
"""Rollback os on reverted cluster
"""Rollback/Downgrade os on reverted env
Scenario:
1. Revert patched environment
2. Get release ids
2. Identify release id for rollback
3. Run rollback
4. Check that rollback was successful
2. Identify release id for rollback/downgrade
3. Run rollback/downgrade
4. Check that operation was successful
5. Run OSTF
6. Create snapshot
"""
logger.info("snapshot name is {0}".format(self.snapshot))
if not self.env.get_virtual_environment().has_snapshot(
'{0}_and_patch'.format(self.snapshot)):
raise SkipTest()
raise SkipTest('Can not find snapshot {0}'.format(self.snapshot))
self.env.revert_snapshot('{0}_and_patch'.format(self.snapshot))
@ -243,8 +242,7 @@ class TestPatch(TestBasic):
self.fuel_web.run_ostf(cluster_id=cluster_id,)
self.env.make_snapshot('{0}_and_rollback'.format(self.snapshot),
is_make=True)
self.env.make_snapshot('{0}_and_rollback'.format(self.snapshot))
@factory