Skip to content

Commit

Permalink
Finish fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaublitz committed Aug 21, 2019
1 parent a53205f commit fdca5b9
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 60 deletions.
2 changes: 1 addition & 1 deletion src/dbus_api/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fn get_base_tree<'a>(dbus_context: DbusContext) -> (Tree<MTFn<TData>, TData>, db
// a(o): Array of object paths for block devices
//
// Rust representation: (bool, (dbus::Path, Vec<dbus::Path>))
.out_arg(("result", "(b(oao)"))
.out_arg(("result", "(b(oao))"))
.out_arg(("return_code", "q"))
.out_arg(("return_string", "s"));

Expand Down
4 changes: 2 additions & 2 deletions tests/client-dbus/tests/dbus/filesystem/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
super().setUp()
self._fs_name = "fs"
self._proxy = get_object(TOP_OBJECT)
((self._pool_object_path, _), _, _) = Manager.Methods.CreatePool(
((_, (self._pool_object_path, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{
"name": self._POOLNAME,
Expand All @@ -51,7 +51,7 @@ def setUp(self):
},
)
self._pool_object = get_object(self._pool_object_path)
(created, _, _) = Pool.Methods.CreateFilesystems(
((_, created), _, _) = Pool.Methods.CreateFilesystems(
self._pool_object, {"specs": [self._fs_name]}
)
self._filesystem_object_path = created[0][0]
Expand Down
9 changes: 5 additions & 4 deletions tests/client-dbus/tests/dbus/filesystem/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def setUp(self):
super().setUp()
self._fs_name = "fs"
self._proxy = get_object(TOP_OBJECT)
((self._pool_object_path, _), _, _) = Manager.Methods.CreatePool(
((_, (self._pool_object_path, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{
"name": self._POOLNAME,
Expand All @@ -54,7 +54,7 @@ def setUp(self):
},
)
self._pool_object = get_object(self._pool_object_path)
(created, _, _) = Pool.Methods.CreateFilesystems(
((_, created), _, _) = Pool.Methods.CreateFilesystems(
self._pool_object, {"specs": [self._fs_name]}
)
self._filesystem_object_path = created[0][0]
Expand All @@ -65,12 +65,13 @@ def testNullMapping(self):
Test rename to same name.
"""
filesystem = get_object(self._filesystem_object_path)
(result, rc, _) = Filesystem.Methods.SetName(
((is_some, result), rc, _) = Filesystem.Methods.SetName(
filesystem, {"name": self._fs_name}
)

self.assertEqual(rc, StratisdErrors.OK)
self.assertFalse(result)
self.assertFalse(is_some)
self.assertEqual(result, "0" * 32)

def testNewName(self):
"""
Expand Down
8 changes: 4 additions & 4 deletions tests/client-dbus/tests/dbus/manager/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def testCreate(self):
If rc is OK, then pool must exist.
"""
devs = _DEVICE_STRATEGY()
((_, _, (poolpath, devnodes)), rc, _) = Manager.Methods.CreatePool(
((_, (poolpath, devnodes)), rc, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": devs},
)
Expand Down Expand Up @@ -121,16 +121,16 @@ def testCreate(self):
ObjectManager.Methods.GetManagedObjects(self._proxy, {})
)

(_, rc, _) = Manager.Methods.CreatePool(
((is_some, _), rc, _) = Manager.Methods.CreatePool(
self._proxy,
{
"name": self._POOLNAME,
"redundancy": (True, 0),
"devices": _DEVICE_STRATEGY(),
},
)
expected_rc = StratisdErrors.ALREADY_EXISTS
self.assertEqual(rc, expected_rc)
self.assertEqual(rc, StratisdErrors.OK)
self.assertFalse(is_some)

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
pools2 = [x for x in pools().search(managed_objects)]
Expand Down
10 changes: 5 additions & 5 deletions tests/client-dbus/tests/dbus/manager/test_destroy.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def setUp(self):
"""
super().setUp()
self._proxy = get_object(TOP_OBJECT)
((poolpath, _), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{
"name": self._POOLNAME,
Expand All @@ -145,9 +145,9 @@ def testExecution(self):
managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
(pool, _) = next(pools(props={"Name": self._POOLNAME}).search(managed_objects))

(result, rc, _) = Manager.Methods.DestroyPool(self._proxy, {"pool": pool})
((is_some, _), rc, _) = Manager.Methods.DestroyPool(self._proxy, {"pool": pool})
self.assertEqual(rc, StratisdErrors.BUSY)
self.assertEqual(result, False)
self.assertFalse(is_some)

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
(pool1, _) = next(pools(props={"Name": self._POOLNAME}).search(managed_objects))
Expand Down Expand Up @@ -181,10 +181,10 @@ def testExecution(self):
managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
(pool, _) = next(pools(props={"Name": self._POOLNAME}).search(managed_objects))

(result, rc, _) = Manager.Methods.DestroyPool(self._proxy, {"pool": pool})
((is_some, _), rc, _) = Manager.Methods.DestroyPool(self._proxy, {"pool": pool})

self.assertEqual(rc, StratisdErrors.OK)
self.assertEqual(result, True)
self.assertTrue(is_some)

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
self.assertIsNone(
Expand Down
24 changes: 8 additions & 16 deletions tests/client-dbus/tests/dbus/pool/test_add_cache_devs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,12 @@ def testSomeDevs(self):
else:
self.assertEqual(num_devices_added, 0)

blockdev_uuids = frozenset(result)
blockdev_paths = frozenset(result)

# blockdevs exported on the D-Bus are exactly those added
blockdevs2 = list(blockdevs(props={"Pool": pool}).search(managed_objects))
blockdevs2_uuids = frozenset(
[data["org.storage.stratis1.blockdev"]["Uuid"] for (_, data) in blockdevs2]
)
self.assertEqual(blockdevs2_uuids, blockdev_uuids)
blockdevs2_paths = frozenset([op for (op, _) in blockdevs2])
self.assertEqual(blockdevs2_paths, blockdev_paths)

# no duplicates in the object paths
self.assertEqual(len(blockdevs2), num_devices_added)
Expand Down Expand Up @@ -132,7 +130,7 @@ def setUp(self):
},
)
self._pool_object = get_object(poolpath)
self._devuuids = frozenset([devuuid for devuuid in devs])
self._devpaths = frozenset([devpath for devpath in devs])
Manager.Methods.ConfigureSimulator(self._proxy, {"denominator": 8})

def testEmptyDevs(self):
Expand All @@ -143,7 +141,7 @@ def testEmptyDevs(self):
(pool, _) = next(pools(props={"Name": self._POOLNAME}).search(managed_objects))

blockdevs1 = blockdevs(props={"Pool": pool, "Tier": 0}).search(managed_objects)
self.assertEqual(self._devuuids, frozenset(op for (op, _) in blockdevs1))
self.assertEqual(self._devpaths, frozenset(op for (op, _) in blockdevs1))
blockdevs2 = blockdevs(props={"Pool": pool, "Tier": 1}).search(managed_objects)
self.assertEqual(list(blockdevs2), [])

Expand All @@ -154,7 +152,7 @@ def testEmptyDevs(self):

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
blockdevs3 = blockdevs(props={"Pool": pool}).search(managed_objects)
self.assertEqual(frozenset(op for (op, _) in blockdevs3), self._devuuids)
self.assertEqual(frozenset(op for (op, _) in blockdevs3), self._devpaths)

def testSomeDevs(self):
"""
Expand All @@ -164,7 +162,7 @@ def testSomeDevs(self):
(pool, _) = next(pools(props={"Name": self._POOLNAME}).search(managed_objects))

blockdevs1 = blockdevs(props={"Pool": pool, "Tier": 0}).search(managed_objects)
self.assertEqual(self._devuuids, frozenset(op for (op, _) in blockdevs1))
self.assertEqual(self._devpaths, frozenset(op for (op, _) in blockdevs1))
(result, rc, _) = Pool.Methods.AddCacheDevs(
self._pool_object, {"devices": _DEVICE_STRATEGY()}
)
Expand Down Expand Up @@ -195,10 +193,4 @@ def testSomeDevs(self):

# The number of datadevs has remained the same
blockdevs5 = blockdevs(props={"Pool": pool, "Tier": 0}).search(managed_objects)
self.assertEqual(
frozenset(
data["org.storage.stratis1.blockdev"]["Uuid"]
for (_, data) in blockdevs5
),
self._devuuids,
)
self.assertEqual(frozenset(op for (op, _) in blockdevs5), self._devpaths)
2 changes: 1 addition & 1 deletion tests/client-dbus/tests/dbus/pool/test_add_data_devs.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setUp(self):
"""
super().setUp()
self._proxy = get_object(TOP_OBJECT)
((_, ((poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": []},
)
Expand Down
18 changes: 9 additions & 9 deletions tests/client-dbus/tests/dbus/pool/test_create_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self):
super().setUp()
self._proxy = get_object(TOP_OBJECT)
self._devs = _DEVICE_STRATEGY()
((_, ((poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": self._devs},
)
Expand All @@ -63,7 +63,7 @@ def testCreate(self):
self._pool_object, {"specs": []}
)

self.assertEqual(is_some, False)
self.assertFalse(is_some)
self.assertEqual(len(result), 0)
self.assertEqual(rc, StratisdErrors.OK)

Expand All @@ -83,7 +83,7 @@ def testDuplicateSpecs(self):
self._pool_object, {"specs": [new_name, new_name]}
)

self.assertEqual(is_some, True)
self.assertTrue(is_some)
self.assertEqual(len(result), 1)
self.assertEqual(rc, StratisdErrors.OK)

Expand Down Expand Up @@ -111,7 +111,7 @@ def setUp(self):
super().setUp()
self._proxy = get_object(TOP_OBJECT)
self._devs = _DEVICE_STRATEGY()
((_, ((poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": self._devs},
)
Expand All @@ -131,7 +131,7 @@ def testCreate(self):
)

self.assertEqual(rc, StratisdErrors.OK)
self.assertEqual(is_some, False)
self.assertFalse(is_some)
self.assertEqual(len(result), 0)

result = filesystems().search(
Expand All @@ -151,10 +151,10 @@ def testCreateOne(self):
)

self.assertEqual(rc, StratisdErrors.OK)
self.assertEqual(is_some, True)
self.assertTrue(is_some)
self.assertEqual(len(result), 1)

(_, fs_name, _) = result[0]
(_, fs_name) = result[0]
self.assertEqual(fs_name, new_name)

result = filesystems().search(
Expand All @@ -174,7 +174,7 @@ def testCreateWithConflict(self):
)

self.assertEqual(rc, StratisdErrors.OK)
self.assertEqual(is_some, True)
self.assertTrue(is_some)
self.assertEqual(len(result), 0)
self.assertEqual(result[0][1], "newname")

Expand All @@ -194,7 +194,7 @@ def testCreateMultiple(self):
)

self.assertEqual(rc, StratisdErrors.ERROR)
self.assertEqual(is_some, False)
self.assertFalse(is_some)
self.assertEqual(len(result), 0)

result = filesystems().search(
Expand Down
2 changes: 1 addition & 1 deletion tests/client-dbus/tests/dbus/pool/test_create_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def setUp(self):
super().setUp()
self._proxy = get_object(TOP_OBJECT)
self._devs = _DEVICE_STRATEGY()
((_, ((poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": self._devs},
)
Expand Down
23 changes: 11 additions & 12 deletions tests/client-dbus/tests/dbus/pool/test_destroy_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setUp(self):
super().setUp()
self._proxy = get_object(TOP_OBJECT)
self._devs = _DEVICE_STRATEGY()
((_, ((poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": self._devs},
)
Expand Down Expand Up @@ -74,13 +74,10 @@ def testDestroyOne(self):
Test calling with a non-existant object path. This should succeed,
because at the end the filesystem is not there.
"""
(
(_, (result_changed, result_unchanged)),
rc,
_,
) = Pool.Methods.DestroyFilesystems(self._pool_object, {"filesystems": ["/"]})
self.assertEqual(len(result_changed), 0)
self.assertEqual(len(result_unchanged), 1)
((_, result), rc, _) = Pool.Methods.DestroyFilesystems(
self._pool_object, {"filesystems": ["/"]}
)
self.assertEqual(len(result), 0)
self.assertEqual(rc, StratisdErrors.OK)

result = filesystems().search(
Expand All @@ -104,12 +101,12 @@ def setUp(self):
super().setUp()
self._proxy = get_object(TOP_OBJECT)
self._devs = _DEVICE_STRATEGY()
((_, ((self._poolpath, _), _)), _, _) = Manager.Methods.CreatePool(
((_, (self._poolpath, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{"name": self._POOLNAME, "redundancy": (True, 0), "devices": self._devs},
)
self._pool_object = get_object(self._poolpath)
(self._filesystems, _, _) = Pool.Methods.CreateFilesystems(
((_, self._filesystems), _, _) = Pool.Methods.CreateFilesystems(
self._pool_object, {"specs": [(self._VOLNAME, "", None)]}
)
Manager.Methods.ConfigureSimulator(self._proxy, {"denominator": 8})
Expand All @@ -120,10 +117,11 @@ def testDestroyOne(self):
should always succeed.
"""
fs_object_path = self._filesystems[0][0]
(result, rc, _) = Pool.Methods.DestroyFilesystems(
((is_some, result), rc, _) = Pool.Methods.DestroyFilesystems(
self._pool_object, {"filesystems": [fs_object_path]}
)

self.assertTrue(is_some)
self.assertEqual(len(result), 1)
self.assertEqual(rc, StratisdErrors.OK)

Expand All @@ -139,10 +137,11 @@ def testDestroyTwo(self):
returned.
"""
fs_object_path = self._filesystems[0][0]
(result, rc, _) = Pool.Methods.DestroyFilesystems(
((is_some, result), rc, _) = Pool.Methods.DestroyFilesystems(
self._pool_object, {"filesystems": [fs_object_path, "/"]}
)

self.assertTrue(is_some)
self.assertEqual(len(result), 1)
self.assertEqual(rc, StratisdErrors.OK)

Expand Down
12 changes: 7 additions & 5 deletions tests/client-dbus/tests/dbus/pool/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def setUp(self):
"""
super().setUp()
self._proxy = get_object(TOP_OBJECT)
((_, _, (self._pool_object_path, _)), _, _) = Manager.Methods.CreatePool(
((_, (self._pool_object_path, _)), _, _) = Manager.Methods.CreatePool(
self._proxy,
{
"name": self._POOLNAME,
Expand All @@ -58,12 +58,12 @@ def testNullMapping(self):
"""
Test rename to same name.
"""
(result, rc, _) = Pool.Methods.SetName(
((is_some, _), rc, _) = Pool.Methods.SetName(
self._pool_object, {"name": self._POOLNAME}
)

self.assertEqual(rc, StratisdErrors.OK)
self.assertFalse(result)
self.assertFalse(is_some)

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
result = next(
Expand All @@ -79,9 +79,11 @@ def testNewName(self):
"""
new_name = "new"

(result, rc, _) = Pool.Methods.SetName(self._pool_object, {"name": new_name})
((is_some, _), rc, _) = Pool.Methods.SetName(
self._pool_object, {"name": new_name}
)

self.assertTrue(result)
self.assertTrue(is_some)
self.assertEqual(rc, StratisdErrors.OK)

managed_objects = ObjectManager.Methods.GetManagedObjects(self._proxy, {})
Expand Down

0 comments on commit fdca5b9

Please sign in to comment.