Fix ring device checks in probetests

If a device has been removed from one of the rings, it actually is set as None
within the ring. In that case the length of the devices is not True without
filtering the None devices. However, if the length matched the condition but
included a removed device the probetests would fail with a TypeError.

This fix could be done also in swift/common/ring/ring.py, but it seems it only
affects probetests right now, thus fixing it there and not changing the current
behavior.

Change-Id: I8ccf9b32a51957e040dd370bc9f711d4328d17b1
This commit is contained in:
Christian Schwede 2015-10-07 19:48:17 +00:00
parent 75e10aa77c
commit c30ceec6f1

View File

@ -198,10 +198,12 @@ def get_ring(ring_name, required_replicas, required_devices,
if ring.replica_count != required_replicas:
raise SkipTest('%s has %s replicas instead of %s' % (
ring.serialized_path, ring.replica_count, required_replicas))
if len(ring.devs) != required_devices:
devs = [dev for dev in ring.devs if dev is not None]
if len(devs) != required_devices:
raise SkipTest('%s has %s devices instead of %s' % (
ring.serialized_path, len(ring.devs), required_devices))
for dev in ring.devs:
for dev in devs:
# verify server is exposing mounted device
ipport = (dev['ip'], dev['port'])
_, server_number = get_server_number(ipport, ipport2server)