def testDuplicateSnapshotName(self):
        """
        Test creating a snapshot with duplicate name.
        """

        ((is_some, ss_object_path), rc, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object,
            {"origin": self._fs_object_path, "snapshot_name": self._SNAPSHOTNAME},
        )

        self.assertTrue(is_some)
        self.assertEqual(rc, StratisdErrors.OK)
        self.assertNotEqual(ss_object_path, "/")

        ((is_some, ss_object_path_dupe_name), rc, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object,
            {"origin": self._fs_object_path, "snapshot_name": self._SNAPSHOTNAME},
        )

        self.assertFalse(is_some)
        self.assertEqual(rc, StratisdErrors.OK)
        self.assertEqual(ss_object_path_dupe_name, "/")

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {})
        )
        self.assertEqual(len(list(result)), 2)
Example #2
0
    def testDuplicateSnapshotName(self):
        """
        Test creating a snapshot with duplicate name.
        """

        (ss_object_path, rc, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object, {
                'origin': self._fs_object_path,
                'snapshot_name': self._SNAPSHOTNAME
            })

        self.assertEqual(rc, StratisdErrors.OK)
        self.assertNotEqual(ss_object_path, "/")

        (ss_object_path_dupe_name, rc, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object, {
                'origin': self._fs_object_path,
                'snapshot_name': self._SNAPSHOTNAME
            })

        self.assertEqual(rc, StratisdErrors.ALREADY_EXISTS)
        self.assertEqual(ss_object_path_dupe_name, "/")

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 2)
Example #3
0
    def testNewName(self):
        """
        Test rename to new name.
        """
        filesystem = get_object(self._filesystem_object_path)
        (result, rc, _) = Filesystem.Methods.SetName(filesystem,
                                                     {'name': "new"})

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

        managed_objects = \
           ObjectManager.Methods.GetManagedObjects(self._proxy, {})
        (fs_object_path, _) = next(
            filesystems(managed_objects, {'Name': 'new'}))
        self.assertEqual(self._filesystem_object_path, fs_object_path)

        fs_object_path = \
           next(filesystems(managed_objects, {'Name': self._fs_name}), None)
        self.assertIsNone(fs_object_path)
    def testDestroyOne(self):
        """
        Test calling with a non-existant object path. This should succeed,
        because at the end the filesystem is not there.
        """
        (result, rc,
         _) = Pool.Methods.DestroyFilesystems(self._pool_object,
                                              {'filesystems': ['/']})
        self.assertEqual(rc, StratisdErrors.OK)
        self.assertEqual(len(result), 0)

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 0)
Example #5
0
    def test_destroy_one(self):
        """
        Test calling with a non-existant object path. This should succeed,
        because at the end the filesystem is not there.
        """
        ((_, result), return_code,
         _) = Pool.Methods.DestroyFilesystems(self._pool_object,
                                              {"filesystems": ["/"]})
        self.assertEqual(len(result), 0)
        self.assertEqual(return_code, StratisdErrors.OK)

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 0)
Example #6
0
    def testNewName(self):
        """
        Test rename to new name.
        """
        filesystem = get_object(self._filesystem_object_path)
        (result, rc, _) = Filesystem.Methods.SetName(filesystem,
                                                     {"name": "new"})

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

        managed_objects = ObjectManager.Methods.GetManagedObjects(
            self._proxy, {})
        (fs_object_path,
         _) = next(filesystems(props={
             "Name": "new"
         }).search(managed_objects))
        self.assertEqual(self._filesystem_object_path, fs_object_path)

        fs_object_path = next(
            filesystems(props={
                "Name": self._FSNAME
            }).search(managed_objects), None)
        self.assertIsNone(fs_object_path)
Example #7
0
    def testCreateWithConflict(self):
        """
        Test calling by specifying several volumes. Because there is already
        a volume with the given name, the creation of the new volumes should
        fail, and no additional volume should be created.
        """
        (result, rc, _) = Pool.Methods.CreateFilesystems(
            self._pool_object, {'specs': [self._VOLNAME, "newname"]})

        self.assertEqual(rc, StratisdErrors.ALREADY_EXISTS)
        self.assertEqual(len(result), 0)

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 1)
Example #8
0
    def testCreate(self):
        """
        Test calling with no actual volume specification. An empty volume
        list should always succeed, and it should not increase the
        number of volumes.
        """
        (result, rc,
         _) = Pool.Methods.CreateFilesystems(self._pool_object, {'specs': []})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 0)
Example #9
0
    def testCreateMultiple(self):
        """
        Test calling by specifying multiple volume names.  Currently multiple
        volume names are not supported due to possible d-bus timeouts.  When
        multiple volume support is added back - this test should be removed.
        """
        (result, rc, _) = Pool.Methods.CreateFilesystems(
            self._pool_object, {'specs': ["a", "b"]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 1)
Example #10
0
    def testDestroyOne(self):
        """
        Test calling by specifying the object path. Assume that destruction
        should always succeed.
        """
        fs_object_path = self._filesystems[0][0]
        (result, rc, _) = Pool.Methods.DestroyFilesystems(
            self._pool_object, {'filesystems': [fs_object_path]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 0)
Example #11
0
    def test_destroy_one(self):
        """
        Test calling by specifying the object path. Assume that destruction
        should always succeed.
        """
        fs_object_path = self._filesystems[0][0]
        ((is_some, result), return_code, _) = Pool.Methods.DestroyFilesystems(
            self._pool_object, {"filesystems": [fs_object_path]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 0)
Example #12
0
    def testDestroyTwo(self):
        """
        Test calling by specifying one existing volume name and one
        non-existing. Should succeed, but only the existing name should be
        returned.
        """
        fs_object_path = self._filesystems[0][0]
        (result, rc, _) = Pool.Methods.DestroyFilesystems(
            self._pool_object, {'filesystems': [fs_object_path, "/"]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 0)
Example #13
0
    def test_destroy_none(self):
        """
        Test calling with no actual volume specification. An empty volume
        list should always succeed, and it should not decrease the
        number of volumes.
        """
        ((_, result_changed), return_code,
         _) = Pool.Methods.DestroyFilesystems(self._pool_object,
                                              {"filesystems": []})

        self.assertEqual(len(result_changed), 0)
        self.assertEqual(return_code, StratisdErrors.OK)

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 0)
    def testCreateWithConflict(self):
        """
        Test calling by specifying several volumes. Because there is already
        a volume with the given name, only the new volumes should be created
        and the command should succeed.
        """
        ((is_some, result), rc, _) = Pool.Methods.CreateFilesystems(
            self._pool_object, {"specs": [self._FSNAME, "newname"]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 1)
Example #15
0
    def test_destroy_two(self):
        """
        Test calling by specifying one existing volume name and one
        non-existing. Should succeed, but only the existing name should be
        returned.
        """
        fs_object_path = self._filesystems[0][0]
        ((is_some, result), return_code, _) = Pool.Methods.DestroyFilesystems(
            self._pool_object, {"filesystems": [fs_object_path, "/"]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 0)
Example #16
0
    def testCreate(self):
        """
        Test creating a snapshot and ensure that it works.
        """

        (ss_object_path, rc, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object, {
                'origin': self._fs_object_path,
                'snapshot_name': self._SNAPSHOTNAME
            })

        self.assertEqual(rc, StratisdErrors.OK)
        self.assertNotEqual(ss_object_path, "/")

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 2)
Example #17
0
    def test_create(self):
        """
        Test creating a snapshot and ensure that it works.
        """

        ((is_some, ss_object_path), return_code, _) = Pool.Methods.SnapshotFilesystem(
            self._pool_object,
            {"origin": self._fs_object_path, "snapshot_name": self._SNAPSHOTNAME},
        )

        self.assertTrue(is_some)
        self.assertEqual(return_code, StratisdErrors.OK)
        self.assertNotEqual(ss_object_path, "/")

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {})
        )
        self.assertEqual(len(list(result)), 2)
    def testCreate(self):
        """
        Test calling by specifying a volume name. Because there is already
        a volume with the given name, the creation of the new volume should
        return the volume information as unchanged, and no additional volume
        should be created.
        """
        ((is_some, result), rc,
         _) = Pool.Methods.CreateFilesystems(self._pool_object,
                                             {"specs": [self._FSNAME]})

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len(list(result)), 1)
Example #19
0
    def testDuplicateSpecs(self):
        """
        Test calling with duplicate specification for same filesystem name.
        """
        new_name = "name"

        (result, rc, _) = Pool.Methods.CreateFilesystems(
            self._pool_object, {'specs': [new_name, new_name]})

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

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 1)
Example #20
0
    def testCreateOne(self):
        """
        Test calling by specifying a new and different volume name.
        The new volume will be created.
        """
        new_name = "newname"

        (result, rc, _) = Pool.Methods.CreateFilesystems(
            self._pool_object, {'specs': [new_name]})

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

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

        result = filesystems().search(
            ObjectManager.Methods.GetManagedObjects(self._proxy, {}))
        self.assertEqual(len([x for x in result]), 2)