Merge "Remove skips that are no longer necessary"
diff --git a/tempest/testboto.py b/tempest/testboto.py
index c38bf99..09ac950 100644
--- a/tempest/testboto.py
+++ b/tempest/testboto.py
@@ -22,6 +22,7 @@
 
 import boto
 from boto.exception import BotoServerError
+from boto.exception import EC2ResponseError
 from boto.s3.bucket import Bucket
 from boto.s3.key import Key
 import nose
@@ -203,26 +204,32 @@
                                'deleting', 'deleted', 'error'))
     valid_snapshot_status = set(('pending', 'completed', 'error'))
 
-    #TODO(afazekas): object base version for resurces supports update
-    def waitImageState(self, lfunction, wait_for):
-        state = state_wait(lfunction, wait_for, self.valid_image_state)
-        self.assertIn(state, self.valid_image_state)
+    gone_set = set(('_GONE',))
+
+    def state_wait_gone(self, lfunction, final_set, valid_set):
+        if not isinstance(final_set, set):
+            final_set = set((final_set,))
+        final_set |= self.gone_set
+        state = state_wait(lfunction, final_set, valid_set)
+        self.assertIn(state, valid_set | self.gone_set)
         return state
 
+    #TODO(afazekas): object based versions for resurces which supports update
+    def waitImageState(self, lfunction, wait_for):
+        return self.state_wait_gone(lfunction, wait_for,
+                                    self.valid_image_state)
+
     def waitInstanceState(self, lfunction, wait_for):
-        state = state_wait(lfunction, wait_for, self.valid_instance_state)
-        self.assertIn(state, self.valid_instance_state)
-        return state
+        return self.state_wait_gone(lfunction, wait_for,
+                                    self.valid_instance_state)
 
     def waitVolumeStatus(self, lfunction, wait_for):
-        state = state_wait(lfunction, wait_for, self.valid_volume_status)
-        self.assertIn(state, self.valid_volume_status)
-        return state
+        return self.state_wait_gone(lfunction, wait_for,
+                                    self.valid_volume_status)
 
     def waitSnapshotStatus(self, lfunction, wait_for):
-        state = state_wait(lfunction, wait_for, self.valid_snapshot_status)
-        self.assertIn(state, self.valid_snapshot_status)
-        return state
+        return self.state_wait_gone(lfunction, wait_for,
+                                    self.valid_snapshot_status)
 
     def assertImageStateWait(self, lfunction, wait_for):
         state = self.waitImageState(lfunction, wait_for)
@@ -323,13 +330,22 @@
             try:
                 instance.update(validate=True)
             except ValueError:
-                return "terminated"
+                return "_GONE"
+            except EC2ResponseError as exc:
+                if cls.ec2_error_code.\
+                client.InvalidInstanceID.NotFound.match(exc):
+                    return "_GONE"
+                #NOTE(afazekas): incorrect code,
+                # but the resource must be destoreyd
+                if exc.error_code == "InstanceNotFound":
+                    return "_GONE"
+
             return instance.state
 
         for instance in reservation.instances:
             try:
                 instance.terminate()
-                re_search_wait(_instance_state, "terminated")
+                re_search_wait(_instance_state, "_GONE")
             except BaseException as exc:
                 LOG.exception(exc)
                 exc_num += 1
@@ -345,8 +361,6 @@
            Use just for teardown!
         """
         #NOTE(afazekas): should wait/try until all related instance terminates
-        #2.   looks like it is locked even if the instance not listed
-        time.sleep(1)
         group.delete()
 
     @classmethod
diff --git a/tempest/tests/boto/test_ec2_instance_run.py b/tempest/tests/boto/test_ec2_instance_run.py
index 331e54c..6a8778a 100644
--- a/tempest/tests/boto/test_ec2_instance_run.py
+++ b/tempest/tests/boto/test_ec2_instance_run.py
@@ -18,6 +18,7 @@
 from contextlib import closing
 import logging
 
+from boto.exception import EC2ResponseError
 from boto.s3.key import Key
 import nose
 from nose.plugins.attrib import attr
@@ -121,7 +122,7 @@
         self.cancelResourceCleanUp(rcuk)
 
     @attr(type='smoke')
-    @unittest.skip("Skipped until the Bug #1098112 is resolved")
+    @unittest.skip("Skipped until the Bug #1098891 is resolved")
     def test_run_terminate_instance(self):
         # EC2 run, terminate immediately
         image_ami = self.ec2_client.get_image(self.images["ami"]
@@ -132,9 +133,18 @@
 
         for instance in reservation.instances:
             instance.terminate()
-
-        instance.update(validate=True)
-        self.assertNotEqual(instance.state, "running")
+        try:
+            instance.update(validate=True)
+        except ValueError:
+            pass
+        except EC2ResponseError as exc:
+            if self.ec2_error_code.\
+                client.InvalidInstanceID.NotFound.match(exc):
+                pass
+            else:
+                raise
+        else:
+            self.assertNotEqual(instance.state, "running")
 
     #NOTE(afazekas): doctored test case,
     # with normal validation it would fail
diff --git a/tempest/tests/compute/__init__.py b/tempest/tests/compute/__init__.py
index 0258708..190cb5f 100644
--- a/tempest/tests/compute/__init__.py
+++ b/tempest/tests/compute/__init__.py
@@ -21,6 +21,7 @@
 
 from tempest import clients
 from tempest import config
+from tempest.exceptions import InvalidConfiguration
 
 LOG = logging.getLogger(__name__)
 
@@ -51,19 +52,15 @@
     # Validate reference data exists
     # If not, we raise the exception here and prevent
     # going forward...
-    try:
-        image_ref = CONFIG.compute.image_ref
-        image_ref_alt = CONFIG.compute.image_ref_alt
-        images_client.get_image(image_ref)
-        images_client.get_image(image_ref_alt)
+    image_ref = CONFIG.compute.image_ref
+    image_ref_alt = CONFIG.compute.image_ref_alt
+    images_client.get_image(image_ref)
+    images_client.get_image(image_ref_alt)
 
-        flavor_ref = CONFIG.compute.flavor_ref
-        flavor_ref_alt = CONFIG.compute.flavor_ref_alt
-        flavors_client.get_flavor_details(flavor_ref)
-        flavors_client.get_flavor_details(flavor_ref_alt)
-    except Exception as e:
-        msg = "Failed basic configuration: %s" % e
-        raise nose.SkipTest(msg)
+    flavor_ref = CONFIG.compute.flavor_ref
+    flavor_ref_alt = CONFIG.compute.flavor_ref_alt
+    flavors_client.get_flavor_details(flavor_ref)
+    flavors_client.get_flavor_details(flavor_ref_alt)
 
     # Determine if there are two regular users that can be
     # used in testing. If the test cases are allowed to create
@@ -79,6 +76,7 @@
             user2_tenant_name = CONFIG.compute.alt_tenant_name
             if not user2_password or not user2_tenant_name:
                 msg = ("Alternate user specified but not alternate "
-                       "tenant or password")
-                raise nose.SkipTest(msg)
+                       "tenant or password: alt_tenant_name=%s alt_password=%s"
+                       % (user2_tenant_name, user2_password))
+                raise InvalidConfiguration(msg)
             MULTI_USER = True
diff --git a/tempest/tests/compute/servers/test_list_server_filters.py b/tempest/tests/compute/servers/test_list_server_filters.py
index 5eea24f..d943e5d 100644
--- a/tempest/tests/compute/servers/test_list_server_filters.py
+++ b/tempest/tests/compute/servers/test_list_server_filters.py
@@ -208,7 +208,6 @@
                                 ListServerFiltersTest):
     @classmethod
     def setUpClass(cls):
-        raise nose.SkipTest("Until Bug 1039753 is fixed")
         super(ListServerFiltersTestJSON, cls).setUpClass()
         ListServerFiltersTest.setUpClass(cls)
 
@@ -222,7 +221,6 @@
                                ListServerFiltersTest):
     @classmethod
     def setUpClass(cls):
-        raise nose.SkipTest("Until Bug 1039753 is fixed")
         super(ListServerFiltersTestXML, cls).setUpClass()
         ListServerFiltersTest.setUpClass(cls)
 
diff --git a/tempest/tests/identity/admin/test_users.py b/tempest/tests/identity/admin/test_users.py
index a921833..2818536 100644
--- a/tempest/tests/identity/admin/test_users.py
+++ b/tempest/tests/identity/admin/test_users.py
@@ -194,6 +194,7 @@
     @attr(type='negative')
     def test_authentication_with_invalid_username(self):
         # Non-existent user's token should not get authenticated
+        self.data.setup_test_user()
         self.assertRaises(exceptions.Unauthorized, self.token_client.auth,
                           'junkuser123', self.data.test_password,
                           self.data.test_tenant)