Use class-level skips when necessary

This commit switches @skipUnless decorator to class-level skips in
TestKuryrRestartScenario and TestPortPoolScenario. This way we're not
wasting time to do setUp and tearDown for a class that will run no tests.

Change-Id: Iebac5953c5d615da68ab0237fc09e0deebc65e85
This commit is contained in:
Michał Dulko 2018-07-17 11:09:29 +02:00
parent 594df0f4c1
commit 937e8d7b61
2 changed files with 16 additions and 10 deletions

View File

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import testtools
import time
from tempest import config
@ -27,11 +26,15 @@ CONF = config.CONF
class TestKuryrRestartScenario(base.BaseKuryrScenarioTest):
@testtools.skipUnless(
CONF.kuryr_kubernetes.containerized and
CONF.kuryr_kubernetes.run_tests_serial,
"CNI and controller should be containerized and this test should run "
"on gate, configured to run sequentially")
@classmethod
def skip_checks(cls):
super(TestKuryrRestartScenario, cls).skip_checks()
if (not CONF.kuryr_kubernetes.containerized or
not CONF.kuryr_kubernetes.run_tests_serial):
raise cls.skipException(
"CNI and controller should be containerized and this test "
"should run on gate, configured to run sequentially.")
@decorators.idempotent_id('bddf5441-1244-449d-a125-b5fdcfb1a1a7')
def test_kuryr_pod_delete(self):
# find kuryr CNI and controller pods, delete them one by one and create

View File

@ -15,7 +15,6 @@
from oslo_log import log as logging
from tempest import config
from tempest.lib import decorators
import testtools
from kuryr_tempest_plugin.tests.scenario import base
@ -25,9 +24,13 @@ CONF = config.CONF
class TestPortPoolScenario(base.BaseKuryrScenarioTest):
@testtools.skipUnless(
CONF.kuryr_kubernetes.port_pool_enabled,
"Port pool feature should be enabled to run this test")
@classmethod
def skip_checks(cls):
super(TestPortPoolScenario, cls).skip_checks()
if not CONF.kuryr_kubernetes.port_pool_enabled:
raise cls.skipException(
"Port pool feature should be enabled to run this test.")
@decorators.idempotent_id('bddf5441-1244-449d-a125-b5fddfb1a3aa')
def test_port_pool(self):
# check the original length of list of ports