From f7b833b31311685a22e8330f82d003cce658157f Mon Sep 17 00:00:00 2001 From: vic Date: Tue, 5 Mar 2013 22:04:17 +0400 Subject: [PATCH] options for create_snapshot and for predefined_tar --- fuel_test/cobbler/test_compact.py | 12 +++++++++--- fuel_test/cobbler/test_full.py | 7 ++++--- fuel_test/cobbler/test_minimal.py | 5 ++++- fuel_test/cobbler/test_simple.py | 6 ++++-- fuel_test/cobbler/test_single.py | 6 ++++-- fuel_test/helpers.py | 11 +++++++---- fuel_test/settings.py | 2 ++ 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/fuel_test/cobbler/test_compact.py b/fuel_test/cobbler/test_compact.py index 59fd24b736..a6a7b6e644 100644 --- a/fuel_test/cobbler/test_compact.py +++ b/fuel_test/cobbler/test_compact.py @@ -2,6 +2,8 @@ from fuel_test.cobbler.cobbler_test_case import CobblerTestCase from fuel_test.helpers import is_not_essex import unittest from fuel_test.manifest import Manifest, Template +from fuel_test.settings import CREATE_SNAPSHOTS + class CompactTestCase(CobblerTestCase): def deploy_compact(self, quantum=True, loopback=True): @@ -25,7 +27,8 @@ class CompactTestCase(CobblerTestCase): quantums=self.nodes().quantums, quantum=True) self.deploy_compact() - self.environment().snapshot('compact', force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot('compact', force=True) def test_deploy_compact_wo_quantum(self): Manifest().write_openstack_manifest( @@ -35,7 +38,8 @@ class CompactTestCase(CobblerTestCase): quantums=self.nodes().quantums, quantum=False) self.deploy_compact(quantum=False) - self.environment().snapshot('compact_wo_quantum', force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot('compact_wo_quantum', force=True) def test_deploy_compact_wo_loopback(self): Manifest().write_openstack_manifest( @@ -45,7 +49,9 @@ class CompactTestCase(CobblerTestCase): quantums=self.nodes().quantums, quantum=False, loopback=False, use_syslog=False) self.deploy_compact(quantum=False, loopback=False) - self.environment().snapshot('compact_woloopback', force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot('compact_woloopback', force=True) + if __name__ == '__main__': unittest.main() diff --git a/fuel_test/cobbler/test_full.py b/fuel_test/cobbler/test_full.py index e50871db62..1ae560f635 100644 --- a/fuel_test/cobbler/test_full.py +++ b/fuel_test/cobbler/test_full.py @@ -2,6 +2,8 @@ import unittest from fuel_test.cobbler.cobbler_test_case import CobblerTestCase from fuel_test.helpers import is_not_essex from fuel_test.manifest import Manifest, Template +from fuel_test.settings import CREATE_SNAPSHOTS + class FullTestCase(CobblerTestCase): def test_full(self): @@ -25,9 +27,8 @@ class FullTestCase(CobblerTestCase): self.validate(self.nodes().proxies, 'puppet agent --test') Manifest().write_nagios_manifest(remote=self.remote()) self.validate(self.nodes().controllers[:1], 'puppet agent --test') - - def snapshot(self): - self.environment().snapshot('full', force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot('full', force=True) if __name__ == '__main__': unittest.main() diff --git a/fuel_test/cobbler/test_minimal.py b/fuel_test/cobbler/test_minimal.py index e654f12416..5b7203cfc6 100644 --- a/fuel_test/cobbler/test_minimal.py +++ b/fuel_test/cobbler/test_minimal.py @@ -2,6 +2,8 @@ import unittest from fuel_test.cobbler.cobbler_test_case import CobblerTestCase from fuel_test.helpers import is_not_essex from fuel_test.manifest import Manifest, Template +from fuel_test.settings import CREATE_SNAPSHOTS + class MinimalTestCase(CobblerTestCase): def test_minimal(self): @@ -18,7 +20,8 @@ class MinimalTestCase(CobblerTestCase): if is_not_essex(): self.validate(self.nodes().quantums, 'puppet agent --test') self.validate(self.nodes().computes, 'puppet agent --test') - self.environment().snapshot('minimal', force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot('minimal', force=True) if __name__ == '__main__': unittest.main() diff --git a/fuel_test/cobbler/test_simple.py b/fuel_test/cobbler/test_simple.py index e11af2d848..dd930d30ad 100644 --- a/fuel_test/cobbler/test_simple.py +++ b/fuel_test/cobbler/test_simple.py @@ -1,7 +1,8 @@ import unittest from fuel_test.cobbler.cobbler_test_case import CobblerTestCase from fuel_test.manifest import Manifest -from fuel_test.settings import OPENSTACK_SNAPSHOT +from fuel_test.settings import OPENSTACK_SNAPSHOT, CREATE_SNAPSHOTS + class SimpleTestCase(CobblerTestCase): def test_simple(self): @@ -12,7 +13,8 @@ class SimpleTestCase(CobblerTestCase): self.validate( self.nodes().controllers + self.nodes().computes, 'puppet agent --test') - self.environment().snapshot(OPENSTACK_SNAPSHOT, force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot(OPENSTACK_SNAPSHOT, force=True) if __name__ == '__main__': unittest.main() diff --git a/fuel_test/cobbler/test_single.py b/fuel_test/cobbler/test_single.py index 2881b7113f..b0b36c3dc4 100644 --- a/fuel_test/cobbler/test_single.py +++ b/fuel_test/cobbler/test_single.py @@ -1,7 +1,8 @@ import unittest from fuel_test.cobbler.cobbler_test_case import CobblerTestCase from fuel_test.manifest import Manifest -from fuel_test.settings import OPENSTACK_SNAPSHOT +from fuel_test.settings import OPENSTACK_SNAPSHOT, CREATE_SNAPSHOTS + class SingleTestCase(CobblerTestCase): def test_single(self): @@ -13,7 +14,8 @@ class SingleTestCase(CobblerTestCase): self.validate( self.nodes().controllers, 'puppet agent --test') - self.environment().snapshot(OPENSTACK_SNAPSHOT, force=True) + if CREATE_SNAPSHOTS: + self.environment().snapshot(OPENSTACK_SNAPSHOT, force=True) if __name__ == '__main__': unittest.main() diff --git a/fuel_test/helpers.py b/fuel_test/helpers.py index bf91235abd..eac4e767ce 100644 --- a/fuel_test/helpers.py +++ b/fuel_test/helpers.py @@ -6,7 +6,7 @@ from devops.helpers.helpers import wait import os import re from fuel_test.cobbler.cobbler_client import CobblerClient -from fuel_test.settings import OS_FAMILY, PUPPET_CLIENT_PACKAGE, PUPPET_VERSION, PUPPET_MASTER_SERVICE +from fuel_test.settings import OS_FAMILY, PUPPET_CLIENT_PACKAGE, PUPPET_VERSION, PUPPET_MASTER_SERVICE, EXIST_TAR from root import root def get_file_as_string(path): @@ -183,9 +183,12 @@ def upload_recipes(remote, remote_dir="/etc/puppet/modules/"): recipes_dir = root('deployment', 'puppet') tar_file = None try: - tar_file = remote.open('/tmp/recipes.tar', 'wb') - with tarfile.open(fileobj=tar_file, mode='w') as tar: - tar.add(recipes_dir, arcname='') + if EXIST_TAR: + remote.upload(EXIST_TAR, '/tmp/recipes.tar') + else: + tar_file = remote.open('/tmp/recipes.tar', 'wb') + with tarfile.open(fileobj=tar_file, mode='w') as tar: + tar.add(recipes_dir, arcname='') remote.mkdir(remote_dir) remote.check_call('tar -xf /tmp/recipes.tar -C %s' % remote_dir) finally: diff --git a/fuel_test/settings.py b/fuel_test/settings.py index 0b002150d0..e6b56b8051 100644 --- a/fuel_test/settings.py +++ b/fuel_test/settings.py @@ -98,3 +98,5 @@ POOLS = { } TEST_REPO = os.environ.get('TEST_REPO', 'false') == 'true' +EXIST_TAR = os.environ.get('EXIST_TAR', None) +CREATE_SNAPSHOTS = os.environ.get('CREATE_SNAPSHOTS', 'true') == 'true'