Skip to content

Commit 590dc3e

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Skip object-store functional tests when Swift is not available"
2 parents d010c00 + 022fdb1 commit 590dc3e

3 files changed

Lines changed: 48 additions & 11 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
from openstackclient.tests.functional import base
14+
15+
16+
class ObjectStoreTests(base.TestCase):
17+
"""Functional tests for Object Store commands"""
18+
19+
@classmethod
20+
def setUpClass(cls):
21+
super(ObjectStoreTests, cls).setUpClass()
22+
cls.haz_object_store = base.is_service_enabled('object-store')

openstackclient/tests/functional/object/v1/test_container.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,37 @@
1212

1313
import uuid
1414

15-
from openstackclient.tests.functional import base
15+
# from openstackclient.tests.functional import base
16+
from openstackclient.tests.functional.object.v1 import common
1617

1718

18-
class ContainerTests(base.TestCase):
19-
"""Functional tests for object containers. """
19+
class ContainerTests(common.ObjectStoreTests):
20+
"""Functional tests for Object Store container commands"""
2021
NAME = uuid.uuid4().hex
2122

2223
@classmethod
2324
def setUpClass(cls):
2425
super(ContainerTests, cls).setUpClass()
25-
opts = cls.get_opts(['container'])
26-
raw_output = cls.openstack('container create ' + cls.NAME + opts)
27-
cls.assertOutput(cls.NAME + '\n', raw_output)
26+
if cls.haz_object_store:
27+
opts = cls.get_opts(['container'])
28+
raw_output = cls.openstack('container create ' + cls.NAME + opts)
29+
cls.assertOutput(cls.NAME + '\n', raw_output)
2830

2931
@classmethod
3032
def tearDownClass(cls):
3133
try:
32-
raw_output = cls.openstack('container delete ' + cls.NAME)
33-
cls.assertOutput('', raw_output)
34+
if cls.haz_object_store:
35+
raw_output = cls.openstack('container delete ' + cls.NAME)
36+
cls.assertOutput('', raw_output)
3437
finally:
3538
super(ContainerTests, cls).tearDownClass()
3639

40+
def setUp(self):
41+
super(ContainerTests, self).setUp()
42+
# Skip tests if no object-store is present
43+
if not self.haz_object_store:
44+
self.skipTest("No object-store service present")
45+
3746
def test_container_list(self):
3847
opts = self.get_opts(['Name'])
3948
raw_output = self.openstack('container list' + opts)

openstackclient/tests/functional/object/v1/test_object.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,24 @@
1414
import tempfile
1515
import uuid
1616

17-
from openstackclient.tests.functional import base
17+
from openstackclient.tests.functional.object.v1 import common
1818

1919
BASIC_LIST_HEADERS = ['Name']
2020
CONTAINER_FIELDS = ['account', 'container', 'x-trans-id']
2121
OBJECT_FIELDS = ['object', 'container', 'etag']
2222

2323

24-
class ObjectTests(base.TestCase):
25-
"""Functional tests for Object commands. """
24+
class ObjectTests(common.ObjectStoreTests):
25+
"""Functional tests for Object Store object commands"""
2626

2727
CONTAINER_NAME = uuid.uuid4().hex
2828

29+
def setUp(self):
30+
super(ObjectTests, self).setUp()
31+
# Skip tests if no object-store is present
32+
if not self.haz_object_store:
33+
self.skipTest("No object-store service present")
34+
2935
def test_object(self):
3036
with tempfile.NamedTemporaryFile() as f:
3137
f.write('test content')

0 commit comments

Comments
 (0)