summaryrefslogtreecommitdiffstats
path: root/ufo/test/unit/common/test_ring.py
diff options
context:
space:
mode:
authorPeter Portante <peter.portante@redhat.com>2013-04-04 13:08:32 -0400
committerAnand Avati <avati@redhat.com>2013-04-05 11:20:37 -0700
commit6a7d28c0f8c107baf376eceb9fc05d9e80bf74e5 (patch)
tree05adcb9cfab21adca87401032df6222239ef74d5 /ufo/test/unit/common/test_ring.py
parenta56dca94c3b174637074be46e9a537ba0ca02c4b (diff)
object-storage: use tox for unit tests; fix em too
Add the ability to use tox for unit tests, since it helps us solve the problem of supporting multiple branches that require different versions of dependencies, and allows us to possibly support multiple versions of python in the future. Also fix the code to work with pre-grizzly environments, by not requiring the constraints backport. Also fixed the xattr support to work with both pyxattr and xattr modules. And fixed the ring tests to also work without a live /etc/swift directory. BUG: 948657 (https://bugzilla.redhat.com/show_bug.cgi?id=948657) Change-Id: I2be79c8ef8916bb6552ef957094f9186a963a068 Signed-off-by: Peter Portante <peter.portante@redhat.com> Reviewed-on: http://review.gluster.org/4781 Reviewed-by: Alex Wheeler <wheelear@gmail.com> Tested-by: Alex Wheeler <wheelear@gmail.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'ufo/test/unit/common/test_ring.py')
-rw-r--r--ufo/test/unit/common/test_ring.py74
1 files changed, 24 insertions, 50 deletions
diff --git a/ufo/test/unit/common/test_ring.py b/ufo/test/unit/common/test_ring.py
index 48ed9520..8b7509cc 100644
--- a/ufo/test/unit/common/test_ring.py
+++ b/ufo/test/unit/common/test_ring.py
@@ -13,69 +13,43 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
import unittest
import gluster.swift.common.constraints
-from gluster.swift.common.ring import *
-from gluster.swift.common.Glusterfs import SWIFT_DIR
+import swift.common.utils
+from gluster.swift.common.ring import Ring
-def _mock_ring_data():
- return [{'zone': 1, 'weight': 100.0, 'ip': '127.0.0.1', 'port': 6012, \
- 'meta': '', 'device': 'test', 'id': 0},
- {'zone': 2, 'weight': 100.0, 'ip': '127.0.0.1', 'id': 1, \
- 'meta': '', 'device': 'iops', 'port': 6012}]
class TestRing(unittest.TestCase):
""" Tests for common.utils """
def setUp(self):
- self.ring = Ring(SWIFT_DIR, ring_name='object')
+ swift.common.utils.HASH_PATH_SUFFIX = 'endcap'
+ swiftdir = os.path.join(os.getcwd(), "common", "data")
+ self.ring = Ring(swiftdir, ring_name='object')
def test_first_device(self):
- try:
- __devs = self.ring._devs
- self.ring._devs = _mock_ring_data()
-
- part, node = self.ring.get_nodes('test')
- assert node[0]['device'] == 'test'
- node = self.ring.get_part_nodes(0)
- assert node[0]['device'] == 'test'
- for node in self.ring.get_more_nodes(0):
- assert node['device'] == 'volume_not_in_ring'
- finally:
- self.ring._devs = __devs
+ part, node = self.ring.get_nodes('test')
+ assert node[0]['device'] == 'test'
+ node = self.ring.get_part_nodes(0)
+ assert node[0]['device'] == 'test'
+ for node in self.ring.get_more_nodes(0):
+ assert node['device'] == 'volume_not_in_ring'
def test_invalid_device(self):
- try:
- __devs = self.ring._devs
- self.ring._devs = _mock_ring_data()
-
- part, node = self.ring.get_nodes('test2')
- assert node[0]['device'] == 'volume_not_in_ring'
- node = self.ring.get_part_nodes(0)
- assert node[0]['device'] == 'volume_not_in_ring'
- finally:
- self.ring._devs = __devs
+ part, node = self.ring.get_nodes('test2')
+ assert node[0]['device'] == 'volume_not_in_ring'
+ node = self.ring.get_part_nodes(0)
+ assert node[0]['device'] == 'volume_not_in_ring'
def test_second_device(self):
- try:
- __devs = self.ring._devs
- self.ring._devs = _mock_ring_data()
-
- part, node = self.ring.get_nodes('iops')
- assert node[0]['device'] == 'iops'
- node = self.ring.get_part_nodes(0)
- assert node[0]['device'] == 'iops'
- for node in self.ring.get_more_nodes(0):
- assert node['device'] == 'volume_not_in_ring'
- finally:
- self.ring._devs = __devs
+ part, node = self.ring.get_nodes('iops')
+ assert node[0]['device'] == 'iops'
+ node = self.ring.get_part_nodes(0)
+ assert node[0]['device'] == 'iops'
+ for node in self.ring.get_more_nodes(0):
+ assert node['device'] == 'volume_not_in_ring'
def test_second_device_with_reseller_prefix(self):
- try:
- __devs = self.ring._devs
- self.ring._devs = _mock_ring_data()
-
- part, node = self.ring.get_nodes('AUTH_iops')
- assert node[0]['device'] == 'iops'
- finally:
- self.ring._devs = __devs
+ part, node = self.ring.get_nodes('AUTH_iops')
+ assert node[0]['device'] == 'iops'