diff --git a/tempest/thirdparty/boto/test.py b/tempest/thirdparty/boto/test.py index b36e8c7317..6a9836bf2f 100644 --- a/tempest/thirdparty/boto/test.py +++ b/tempest/thirdparty/boto/test.py @@ -26,14 +26,12 @@ from boto import s3 import keystoneclient.exceptions import tempest.clients -from tempest.common.utils.file_utils import have_effective_read_access +from tempest.common.utils import file_utils from tempest import config from tempest import exceptions from tempest.openstack.common import log as logging import tempest.test -from tempest.thirdparty.boto.utils.wait import re_search_wait -from tempest.thirdparty.boto.utils.wait import state_wait -from tempest.thirdparty.boto.utils.wait import wait_exception +from tempest.thirdparty.boto.utils import wait CONF = config.CONF LOG = logging.getLogger(__name__) @@ -47,7 +45,7 @@ def decision_maker(): id_matcher = re.compile("[A-Za-z0-9]{20,}") def all_read(*args): - return all(map(have_effective_read_access, args)) + return all(map(file_utils.have_effective_read_access, args)) materials_path = CONF.boto.s3_materials_path ami_path = materials_path + os.sep + CONF.boto.ami_manifest @@ -327,7 +325,7 @@ class BotoTestCase(tempest.test.BaseTestCase): final_set = set((final_set,)) final_set |= self.gone_set lfunction = self.get_lfunction_gone(lfunction) - state = state_wait(lfunction, final_set, valid_set) + state = wait.state_wait(lfunction, final_set, valid_set) self.assertIn(state, valid_set | self.gone_set) return state @@ -377,8 +375,8 @@ class BotoTestCase(tempest.test.BaseTestCase): return "ASSOCIATED" return "DISASSOCIATED" - state = state_wait(_disassociate, "DISASSOCIATED", - set(("ASSOCIATED", "DISASSOCIATED"))) + state = wait.state_wait(_disassociate, "DISASSOCIATED", + set(("ASSOCIATED", "DISASSOCIATED"))) self.assertEqual(state, "DISASSOCIATED") def assertAddressReleasedWait(self, address): @@ -391,7 +389,7 @@ class BotoTestCase(tempest.test.BaseTestCase): return "DELETED" return "NOTDELETED" - state = state_wait(_address_delete, "DELETED") + state = wait.state_wait(_address_delete, "DELETED") self.assertEqual(state, "DELETED") def assertReSearch(self, regexp, string): @@ -462,7 +460,7 @@ class BotoTestCase(tempest.test.BaseTestCase): for instance in reservation.instances: try: instance.terminate() - re_search_wait(_instance_state, "_GONE") + wait.re_search_wait(_instance_state, "_GONE") except BaseException: LOG.exception("Failed to terminate instance %s " % instance) exc_num += 1 @@ -503,7 +501,8 @@ class BotoTestCase(tempest.test.BaseTestCase): return volume.status try: - re_search_wait(_volume_state, "available") # not validates status + wait.re_search_wait(_volume_state, "available") + # not validates status LOG.info(_volume_state()) volume.delete() except BaseException: @@ -520,7 +519,7 @@ class BotoTestCase(tempest.test.BaseTestCase): def _update(): snapshot.update(validate=True) - wait_exception(_update) + wait.wait_exception(_update) # you can specify tuples if you want to specify the status pattern diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py index 54861be594..bbfbb797ac 100644 --- a/tempest/thirdparty/boto/test_ec2_instance_run.py +++ b/tempest/thirdparty/boto/test_ec2_instance_run.py @@ -16,23 +16,21 @@ from boto import exception from tempest.common.utils import data_utils -from tempest.common.utils.linux.remote_client import RemoteClient +from tempest.common.utils.linux import remote_client from tempest import config from tempest import exceptions from tempest.openstack.common import log as logging -from tempest.test import attr -from tempest.test import skip_because -from tempest.thirdparty.boto.test import BotoTestCase -from tempest.thirdparty.boto.utils.s3 import s3_upload_dir -from tempest.thirdparty.boto.utils.wait import re_search_wait -from tempest.thirdparty.boto.utils.wait import state_wait +from tempest import test +from tempest.thirdparty.boto import test as boto_test +from tempest.thirdparty.boto.utils import s3 +from tempest.thirdparty.boto.utils import wait CONF = config.CONF LOG = logging.getLogger(__name__) -class InstanceRunTest(BotoTestCase): +class InstanceRunTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): @@ -57,7 +55,7 @@ class InstanceRunTest(BotoTestCase): cls.addResourceCleanUp(cls.destroy_bucket, cls.s3_client.connection_data, cls.bucket_name) - s3_upload_dir(bucket, cls.materials_path) + s3.s3_upload_dir(bucket, cls.materials_path) cls.images = {"ami": {"name": data_utils.rand_name("ami-name-"), "location": cls.bucket_name + "/" + ami_manifest}, @@ -78,14 +76,14 @@ class InstanceRunTest(BotoTestCase): def _state(): retr = cls.ec2_client.get_image(image["image_id"]) return retr.state - state = state_wait(_state, "available") + state = wait.state_wait(_state, "available") if state != "available": for _image in cls.images.itervalues(): cls.ec2_client.deregister_image(_image["image_id"]) raise exceptions.EC2RegisterImageException(image_id= image["image_id"]) - @attr(type='smoke') + @test.attr(type='smoke') def test_run_idempotent_instances(self): # EC2 run instances idempotently @@ -123,7 +121,7 @@ class InstanceRunTest(BotoTestCase): _terminate_reservation(reservation_1, rcuk_1) _terminate_reservation(reservation_2, rcuk_2) - @attr(type='smoke') + @test.attr(type='smoke') def test_run_stop_terminate_instance(self): # EC2 run, stop and terminate instance image_ami = self.ec2_client.get_image(self.images["ami"] @@ -148,7 +146,7 @@ class InstanceRunTest(BotoTestCase): instance.terminate() self.cancelResourceCleanUp(rcuk) - @attr(type='smoke') + @test.attr(type='smoke') def test_run_stop_terminate_instance_with_tags(self): # EC2 run, stop and terminate instance with tags image_ami = self.ec2_client.get_image(self.images["ami"] @@ -195,8 +193,8 @@ class InstanceRunTest(BotoTestCase): instance.terminate() self.cancelResourceCleanUp(rcuk) - @skip_because(bug="1098891") - @attr(type='smoke') + @test.skip_because(bug="1098891") + @test.attr(type='smoke') def test_run_terminate_instance(self): # EC2 run, terminate immediately image_ami = self.ec2_client.get_image(self.images["ami"] @@ -222,8 +220,8 @@ class InstanceRunTest(BotoTestCase): # NOTE(afazekas): doctored test case, # with normal validation it would fail - @skip_because(bug="1182679") - @attr(type='smoke') + @test.skip_because(bug="1182679") + @test.attr(type='smoke') def test_integration_1(self): # EC2 1. integration test (not strict) image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"]) @@ -271,9 +269,9 @@ class InstanceRunTest(BotoTestCase): self.assertVolumeStatusWait(volume, "available") # NOTE(afazekas): it may be reports available before it is available - ssh = RemoteClient(address.public_ip, - CONF.compute.ssh_user, - pkey=self.keypair.material) + ssh = remote_client.RemoteClient(address.public_ip, + CONF.compute.ssh_user, + pkey=self.keypair.material) text = data_utils.rand_name("Pattern text for console output -") resp = ssh.write_to_console(text) self.assertFalse(resp) @@ -282,7 +280,7 @@ class InstanceRunTest(BotoTestCase): output = instance.get_console_output() return output.output - re_search_wait(_output, text) + wait.re_search_wait(_output, text) part_lines = ssh.get_partitions().split('\n') volume.attach(instance.id, "/dev/vdh") @@ -291,7 +289,7 @@ class InstanceRunTest(BotoTestCase): return volume.status self.assertVolumeStatusWait(_volume_state, "in-use") - re_search_wait(_volume_state, "in-use") + wait.re_search_wait(_volume_state, "in-use") # NOTE(afazekas): Different Hypervisor backends names # differently the devices, @@ -305,7 +303,7 @@ class InstanceRunTest(BotoTestCase): return 'DECREASE' return 'EQUAL' - state_wait(_part_state, 'INCREASE') + wait.state_wait(_part_state, 'INCREASE') part_lines = ssh.get_partitions().split('\n') # TODO(afazekas): Resource compare to the flavor settings @@ -313,10 +311,10 @@ class InstanceRunTest(BotoTestCase): volume.detach() self.assertVolumeStatusWait(_volume_state, "available") - re_search_wait(_volume_state, "available") + wait.re_search_wait(_volume_state, "available") LOG.info("Volume %s state: %s", volume.id, volume.status) - state_wait(_part_state, 'DECREASE') + wait.state_wait(_part_state, 'DECREASE') instance.stop() address.disassociate() diff --git a/tempest/thirdparty/boto/test_ec2_keys.py b/tempest/thirdparty/boto/test_ec2_keys.py index 329ace3819..37484cfb6c 100644 --- a/tempest/thirdparty/boto/test_ec2_keys.py +++ b/tempest/thirdparty/boto/test_ec2_keys.py @@ -14,9 +14,8 @@ # under the License. from tempest.common.utils import data_utils -from tempest.test import attr -from tempest.test import skip_because -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test def compare_key_pairs(a, b): @@ -24,7 +23,7 @@ def compare_key_pairs(a, b): a.fingerprint == b.fingerprint) -class EC2KeysTest(BotoTestCase): +class EC2KeysTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): @@ -33,7 +32,7 @@ class EC2KeysTest(BotoTestCase): cls.ec = cls.ec2_error_code # TODO(afazekas): merge create, delete, get test cases - @attr(type='smoke') + @test.attr(type='smoke') def test_create_ec2_keypair(self): # EC2 create KeyPair key_name = data_utils.rand_name("keypair-") @@ -42,8 +41,8 @@ class EC2KeysTest(BotoTestCase): self.assertTrue(compare_key_pairs(keypair, self.client.get_key_pair(key_name))) - @skip_because(bug="1072318") - @attr(type='smoke') + @test.skip_because(bug="1072318") + @test.attr(type='smoke') def test_delete_ec2_keypair(self): # EC2 delete KeyPair key_name = data_utils.rand_name("keypair-") @@ -51,7 +50,7 @@ class EC2KeysTest(BotoTestCase): self.client.delete_key_pair(key_name) self.assertEqual(None, self.client.get_key_pair(key_name)) - @attr(type='smoke') + @test.attr(type='smoke') def test_get_ec2_keypair(self): # EC2 get KeyPair key_name = data_utils.rand_name("keypair-") @@ -60,7 +59,7 @@ class EC2KeysTest(BotoTestCase): self.assertTrue(compare_key_pairs(keypair, self.client.get_key_pair(key_name))) - @attr(type='smoke') + @test.attr(type='smoke') def test_duplicate_ec2_keypair(self): # EC2 duplicate KeyPair key_name = data_utils.rand_name("keypair-") diff --git a/tempest/thirdparty/boto/test_ec2_network.py b/tempest/thirdparty/boto/test_ec2_network.py index 4b2f01ff55..d508c07a4c 100644 --- a/tempest/thirdparty/boto/test_ec2_network.py +++ b/tempest/thirdparty/boto/test_ec2_network.py @@ -13,12 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.test import attr -from tempest.test import skip_because -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test -class EC2NetworkTest(BotoTestCase): +class EC2NetworkTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): @@ -26,8 +25,8 @@ class EC2NetworkTest(BotoTestCase): cls.client = cls.os.ec2api_client # Note(afazekas): these tests for things duable without an instance - @skip_because(bug="1080406") - @attr(type='smoke') + @test.skip_because(bug="1080406") + @test.attr(type='smoke') def test_disassociate_not_associated_floating_ip(self): # EC2 disassociate not associated floating ip ec2_codes = self.ec2_error_code diff --git a/tempest/thirdparty/boto/test_ec2_security_groups.py b/tempest/thirdparty/boto/test_ec2_security_groups.py index 9b58603d0c..86140ecb84 100644 --- a/tempest/thirdparty/boto/test_ec2_security_groups.py +++ b/tempest/thirdparty/boto/test_ec2_security_groups.py @@ -14,18 +14,18 @@ # under the License. from tempest.common.utils import data_utils -from tempest.test import attr -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test -class EC2SecurityGroupTest(BotoTestCase): +class EC2SecurityGroupTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): super(EC2SecurityGroupTest, cls).setUpClass() cls.client = cls.os.ec2api_client - @attr(type='smoke') + @test.attr(type='smoke') def test_create_authorize_security_group(self): # EC2 Create, authorize/revoke security group group_name = data_utils.rand_name("securty_group-") diff --git a/tempest/thirdparty/boto/test_ec2_volumes.py b/tempest/thirdparty/boto/test_ec2_volumes.py index 04671c5715..a493fdadc3 100644 --- a/tempest/thirdparty/boto/test_ec2_volumes.py +++ b/tempest/thirdparty/boto/test_ec2_volumes.py @@ -14,8 +14,8 @@ # under the License. from tempest.openstack.common import log as logging -from tempest.test import attr -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test LOG = logging.getLogger(__name__) @@ -25,7 +25,7 @@ def compare_volumes(a, b): a.size == b.size) -class EC2VolumesTest(BotoTestCase): +class EC2VolumesTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): @@ -33,7 +33,7 @@ class EC2VolumesTest(BotoTestCase): cls.client = cls.os.ec2api_client cls.zone = cls.client.get_good_zone() - @attr(type='smoke') + @test.attr(type='smoke') def test_create_get_delete(self): # EC2 Create, get, delete Volume volume = self.client.create_volume(1, self.zone) @@ -46,7 +46,7 @@ class EC2VolumesTest(BotoTestCase): self.client.delete_volume(volume.id) self.cancelResourceCleanUp(cuk) - @attr(type='smoke') + @test.attr(type='smoke') def test_create_volume_from_snapshot(self): # EC2 Create volume from snapshot volume = self.client.create_volume(1, self.zone) diff --git a/tempest/thirdparty/boto/test_s3_buckets.py b/tempest/thirdparty/boto/test_s3_buckets.py index f34faacadb..af6aa8bcc3 100644 --- a/tempest/thirdparty/boto/test_s3_buckets.py +++ b/tempest/thirdparty/boto/test_s3_buckets.py @@ -14,20 +14,19 @@ # under the License. from tempest.common.utils import data_utils -from tempest.test import attr -from tempest.test import skip_because -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test -class S3BucketsTest(BotoTestCase): +class S3BucketsTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): super(S3BucketsTest, cls).setUpClass() cls.client = cls.os.s3_client - @skip_because(bug="1076965") - @attr(type='smoke') + @test.skip_because(bug="1076965") + @test.attr(type='smoke') def test_create_and_get_delete_bucket(self): # S3 Create, get and delete bucket bucket_name = data_utils.rand_name("s3bucket-") diff --git a/tempest/thirdparty/boto/test_s3_ec2_images.py b/tempest/thirdparty/boto/test_s3_ec2_images.py index 9607a92a43..d2300eec58 100644 --- a/tempest/thirdparty/boto/test_s3_ec2_images.py +++ b/tempest/thirdparty/boto/test_s3_ec2_images.py @@ -17,14 +17,14 @@ import os from tempest.common.utils import data_utils from tempest import config -from tempest.test import attr -from tempest.thirdparty.boto.test import BotoTestCase -from tempest.thirdparty.boto.utils.s3 import s3_upload_dir +from tempest import test +from tempest.thirdparty.boto import test as boto_test +from tempest.thirdparty.boto.utils import s3 CONF = config.CONF -class S3ImagesTest(BotoTestCase): +class S3ImagesTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): @@ -46,9 +46,9 @@ class S3ImagesTest(BotoTestCase): cls.addResourceCleanUp(cls.destroy_bucket, cls.s3_client.connection_data, cls.bucket_name) - s3_upload_dir(bucket, cls.materials_path) + s3.s3_upload_dir(bucket, cls.materials_path) - @attr(type='smoke') + @test.attr(type='smoke') def test_register_get_deregister_ami_image(self): # Register and deregister ami image image = {"name": data_utils.rand_name("ami-name-"), diff --git a/tempest/thirdparty/boto/test_s3_objects.py b/tempest/thirdparty/boto/test_s3_objects.py index a102a22d49..1ae46de580 100644 --- a/tempest/thirdparty/boto/test_s3_objects.py +++ b/tempest/thirdparty/boto/test_s3_objects.py @@ -18,18 +18,18 @@ import contextlib import boto.s3.key from tempest.common.utils import data_utils -from tempest.test import attr -from tempest.thirdparty.boto.test import BotoTestCase +from tempest import test +from tempest.thirdparty.boto import test as boto_test -class S3BucketsTest(BotoTestCase): +class S3BucketsTest(boto_test.BotoTestCase): @classmethod def setUpClass(cls): super(S3BucketsTest, cls).setUpClass() cls.client = cls.os.s3_client - @attr(type='smoke') + @test.attr(type='smoke') def test_create_get_delete_object(self): # S3 Create, get and delete object bucket_name = data_utils.rand_name("s3bucket-") diff --git a/tempest/thirdparty/boto/utils/wait.py b/tempest/thirdparty/boto/utils/wait.py index eed0a9247e..752ed0f9bb 100644 --- a/tempest/thirdparty/boto/utils/wait.py +++ b/tempest/thirdparty/boto/utils/wait.py @@ -17,7 +17,7 @@ import re import time import boto.exception -from testtools import TestCase +import testtools from tempest import config from tempest.openstack.common import log as logging @@ -44,10 +44,11 @@ def state_wait(lfunction, final_set=set(), valid_set=None): return status dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: - raise TestCase.failureException("State change timeout exceeded!" - '(%ds) While waiting' - 'for %s at "%s"' % - (dtime, final_set, status)) + raise testtools.TestCase\ + .failureException("State change timeout exceeded!" + '(%ds) While waiting' + 'for %s at "%s"' % + (dtime, final_set, status)) time.sleep(CONF.boto.build_interval) old_status = status status = lfunction() @@ -67,10 +68,11 @@ def re_search_wait(lfunction, regexp): return result dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: - raise TestCase.failureException('Pattern find timeout exceeded!' - '(%ds) While waiting for' - '"%s" pattern in "%s"' % - (dtime, regexp, text)) + raise testtools.TestCase\ + .failureException('Pattern find timeout exceeded!' + '(%ds) While waiting for' + '"%s" pattern in "%s"' % + (dtime, regexp, text)) time.sleep(CONF.boto.build_interval) @@ -98,8 +100,8 @@ def wait_no_exception(lfunction, exc_class=None, exc_matcher=None): # Let the other exceptions propagate dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: - raise TestCase.failureException("Wait timeout exceeded! (%ds)" % - dtime) + raise testtools.TestCase\ + .failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(CONF.boto.build_interval) @@ -116,8 +118,8 @@ def wait_exception(lfunction): return exc dtime = time.time() - start_time if dtime > CONF.boto.build_timeout: - raise TestCase.failureException("Wait timeout exceeded! (%ds)" % - dtime) + raise testtools.TestCase\ + .failureException("Wait timeout exceeded! (%ds)" % dtime) time.sleep(CONF.boto.build_interval) # TODO(afazekas): consider strategy design pattern..