Beispiel #1
0
    def test_patch_volume(self):
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        self.assertEqual("Premium", volume.service_level)

        volume_patch = VolumePatch(service_level="Standard")
        volume = self.client.volumes.update(volume_patch, TEST_RG, TEST_ACC_1,
                                            TEST_POOL_1, TEST_VOL_1)
        self.assertEqual("Standard", volume.service_level)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                   TEST_VOL_1).wait()
        wait_for_no_volume(self.client,
                           TEST_RG,
                           TEST_ACC_1,
                           TEST_POOL_1,
                           TEST_VOL_1,
                           live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_assign_snapshot_policy_to_volume(self):
        # create volume and snapshot policy
        create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                      TEST_VOL_1)
        snapshot_policy = create_snapshot_policy(self.client,
                                                 TEST_SNAPSHOT_POLICY_1)
        # assign the snapshot policy to the volume
        snapshot = VolumeSnapshotProperties(
            snapshot_policy_id=snapshot_policy.id)
        data_protection = VolumePatchPropertiesDataProtection(
            snapshot=snapshot)
        volume_patch = VolumePatch(data_protection=data_protection)
        volume = self.client.volumes.begin_update(TEST_RG, TEST_ACC_1,
                                                  TEST_POOL_1, TEST_VOL_1,
                                                  volume_patch).result()

        self.assertEqual(volume.data_protection.snapshot.snapshot_policy_id,
                         snapshot_policy.id)

        # cleanup
        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_snapshot_policy(self.client,
                               TEST_SNAPSHOT_POLICY_1,
                               live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #3
0
    def test_create_delete_list_volume(self):
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 1)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                   TEST_VOL_1).wait()
        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 0)

        wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                           TEST_VOL_1)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_get_volume_by_name(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      LOCATION,
                      live=self.is_live)

        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                         TEST_VOL_1)
        assert volume.name == TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #5
0
    def test_patch_volume(self):
        raise unittest.SkipTest("Skipping Volume test")
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        self.assertEqual("Premium", volume.service_level)
        self.assertEqual(100 * GIGABYTE, volume.usage_threshold)

        volume_patch = VolumePatch(usage_threshold=200 * GIGABYTE)
        volume = self.client.volumes.update(volume_patch, TEST_RG, TEST_ACC_1,
                                            TEST_POOL_1, TEST_VOL_1)
        self.assertEqual("Premium", volume.service_level)
        # unchanged
        self.assertEqual(200 * GIGABYTE, volume.usage_threshold)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                   TEST_VOL_1).wait()
        wait_for_no_volume(self.client,
                           TEST_RG,
                           TEST_ACC_1,
                           TEST_POOL_1,
                           TEST_VOL_1,
                           live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_patch_volume(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        assert "Premium" == volume.service_level
        assert 100 * GIGABYTE == volume.usage_threshold

        volume_patch = VolumePatch(usage_threshold=200 * GIGABYTE)
        volume = self.client.volumes.begin_update(TEST_RG, TEST_ACC_1,
                                                  TEST_POOL_1, TEST_VOL_1,
                                                  volume_patch).result()
        assert "Premium" == volume.service_level
        assert 200 * GIGABYTE == volume.usage_threshold

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_get_volume_by_name(self):
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      LOCATION,
                      live=self.is_live)

        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                         TEST_VOL_1)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_patch_volume(self):
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        self.assertEqual("Premium", volume.service_level)
        self.assertEqual(100 * GIGABYTE, volume.usage_threshold)

        volume_patch = VolumePatch(usage_threshold=200 * GIGABYTE)
        volume = self.client.volumes.begin_update(TEST_RG, TEST_ACC_1,
                                                  TEST_POOL_1, TEST_VOL_1,
                                                  volume_patch).result()
        self.assertEqual("Premium", volume.service_level)
        self.assertEqual(200 * GIGABYTE, volume.usage_threshold)

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_list_snapshots(self):
        snapshot = create_snapshot(self.client, TEST_RG, TEST_ACC_1,
                                   TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1,
                                   LOCATION)
        snapshot = create_snapshot(self.client,
                                   TEST_RG,
                                   TEST_ACC_1,
                                   TEST_POOL_1,
                                   TEST_VOL_1,
                                   TEST_SNAPSHOT_2,
                                   LOCATION,
                                   snapshot_only=True)

        snapshot_list = self.client.snapshots.list(TEST_RG, TEST_ACC_1,
                                                   TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(len(list(snapshot_list)), 2)
        idx = 0
        for snapshot in snapshot_list:
            self.assertEqual(snapshot.name, snapshots[idx])
            idx += 1

        delete_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                        TEST_VOL_1, TEST_SNAPSHOT_1)
        delete_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                        TEST_VOL_1, TEST_SNAPSHOT_2)
        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                      TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
Beispiel #10
0
    def test_update_volume(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, live=self.is_live)
        self.assertEqual("Premium", volume.service_level)
        self.assertEqual(100 * GIGABYTE, volume.usage_threshold)

        volume_body = Volume(
            usage_threshold = 200 * GIGABYTE,
            creation_token=TEST_VOL_1,
            service_level="Premium", # cannot differ from pool
            location=LOCATION,
            subnet_id = "/subscriptions/" + SUBSID + "/resourceGroups/" + TEST_RG + "/providers/Microsoft.Network/virtualNetworks/" + VNET + "/subnets/default"
        )

        volume = self.client.volumes.create_or_update(
            volume_body,
            TEST_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1
        ).result()
        self.assertEqual("Premium", volume.service_level);  # unchanged
        self.assertEqual(200 * GIGABYTE, volume.usage_threshold)

        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, live=self.is_live)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #11
0
    def test_update_volume(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(volume.service_level, "Premium")
        self.assertEqual(volume.usage_threshold, 100 * GIGABYTE)

        volume_body = Volume(
            usage_threshold = 100 * GIGABYTE,
            creation_token=TEST_VOL_1,
            service_level="Standard",
            location=LOCATION,
            subnet_id = "/subscriptions/" + SUBSID + "/resourceGroups/" + TEST_RG + "/providers/Microsoft.Network/virtualNetworks/" + VNET + "/subnets/default"
        )

        volume = self.client.volumes.create_or_update(
            volume_body,
            TEST_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1
        ).result()
        self.assertEqual(volume.service_level, "Standard")

        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
Beispiel #12
0
    def test_create_delete_list_volume(self):
        raise unittest.SkipTest("Skipping Volume test")
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)
        # check default export policy and protocol
        self.assertTrue(volume.export_policy.rules[0].nfsv3),
        self.assertFalse(volume.export_policy.rules[0].nfsv41)
        self.assertEqual("0.0.0.0/0",
                         volume.export_policy.rules[0].allowed_clients)
        self.assertEqual(volume.protocol_types[0], "NFSv3")

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 1)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                   TEST_VOL_1).wait()
        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 0)

        wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                           TEST_VOL_1)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #13
0
    def test_get_volume_by_name(self):
        raise unittest.SkipTest("Skipping Volume test")
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               LOCATION,
                               live=self.is_live)

        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                         TEST_VOL_1)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                   TEST_VOL_1).wait()
        wait_for_no_volume(self.client,
                           TEST_RG,
                           TEST_ACC_1,
                           TEST_POOL_1,
                           TEST_VOL_1,
                           live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #14
0
    def test_get_volume_by_name(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, LOCATION)

        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(volume.name, TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
Beispiel #15
0
    def test_get_snapshot_by_name(self):
        snapshot = create_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1, LOCATION)

        snapshot = self.client.snapshots.get(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1)
        self.assertEqual(snapshot.name, TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1+ '/' + TEST_SNAPSHOT_1)

        delete_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1)
        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_patch_volume(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual("Premium", volume.service_level);

        volume_patch = VolumePatch(service_level = "Standard")
        volume = self.client.volumes.update(volume_patch, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1);
        self.assertEqual("Standard", volume.service_level);

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
Beispiel #17
0
    def test_create_delete_snapshot(self):
        snapshot = create_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1, LOCATION)

        snapshot_list = self.client.snapshots.list(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(len(list(snapshot_list)), 1)

        self.client.snapshots.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1).wait()
        snapshot_list = self.client.snapshots.list(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(len(list(snapshot_list)), 0)

        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_list_volumes(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      LOCATION,
                      live=self.is_live)
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_2,
                      LOCATION,
                      volume_only=True,
                      live=self.is_live)
        volumes = [TEST_VOL_1, TEST_VOL_2]

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        assert len(list(volume_list)) == 2
        idx = 0
        for volume in volume_list:
            assert volume.name == volumes[idx]
            idx += 1

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_2,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #19
0
    def test_list_mount_target(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                               TEST_VOL_1)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        mount_target_list = self.client.mount_targets.list(
            TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(len(list(mount_target_list)), 1)

        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1,
                      TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_list_mount_target(self):
        volume = create_volume(self. client,TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(volume.name, TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        mount_target_list = self.client.mount_targets.list(
            TEST_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1
        )
        self.assertEqual(len(list(mount_target_list)), 1)

        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_list_snapshots(self):
        snapshot = create_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1, LOCATION)
        snapshot = create_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_2, LOCATION, snapshot_only=True)

        snapshot_list = self.client.snapshots.list(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        self.assertEqual(len(list(snapshot_list)), 2)
        idx = 0
        for snapshot in snapshot_list:
            self.assertEqual(snapshot.name, snapshots[idx])
            idx += 1

        delete_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_1)
        delete_snapshot(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, TEST_SNAPSHOT_2)
        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_list_volumes(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, LOCATION)
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_2, LOCATION, volume_only=True)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1, TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 2)
        idx = 0
        for volume in volume_list:
            self.assertEqual(volume.name, volumes[idx])
            idx += 1

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_2).wait()
        for volume in volumes:
            wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, volumes[idx])
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
Beispiel #23
0
    def test_list_volumes(self):
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, LOCATION, live=self.is_live)
        volume = create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_2, LOCATION, volume_only=True, live=self.is_live)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1, TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 2)
        idx = 0
        for volume in volume_list:
            self.assertEqual(volume.name, volumes[idx])
            idx += 1

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_2).wait()
        for volume in volumes:
            wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, volumes[idx], live=self.is_live)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_pool_change(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        pool2 = create_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_2,
                            LOCATION, True)
        if self.is_live:
            time.sleep(10)

        body = PoolChangeRequest(new_pool_resource_id=pool2.id)
        self.client.volumes.begin_pool_change(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                              TEST_VOL_1, body).wait()
        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_2,
                                         TEST_VOL_1)
        assert volume.name == TEST_ACC_1 + "/" + TEST_POOL_2 + "/" + TEST_VOL_1

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        assert len(list(volume_list)) == 0

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_2,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_2,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_create_delete_list_volume(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        assert volume.name == TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1
        # check default export policy and protocol
        assert volume.export_policy.rules[0].nfsv3
        assert not volume.export_policy.rules[0].nfsv41
        assert "0.0.0.0/0" == volume.export_policy.rules[0].allowed_clients
        assert volume.protocol_types[0] == "NFSv3"

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        assert len(list(volume_list)) == 1

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        assert len(list(volume_list)) == 0

        wait_for_no_volume(self.client,
                           TEST_RG,
                           TEST_ACC_1,
                           TEST_POOL_1,
                           TEST_VOL_1,
                           live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_list_volumes(self):
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      LOCATION,
                      live=self.is_live)
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_2,
                      LOCATION,
                      volume_only=True,
                      live=self.is_live)
        volumes = [TEST_VOL_1, TEST_VOL_2]

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 2)
        idx = 0
        for volume in volume_list:
            self.assertEqual(volume.name, volumes[idx])
            idx += 1

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_2,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_update_volume(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        volume = create_volume(self.client,
                               TEST_RG,
                               TEST_ACC_1,
                               TEST_POOL_1,
                               TEST_VOL_1,
                               live=self.is_live)
        assert "Premium" == volume.service_level
        assert 100 * GIGABYTE == volume.usage_threshold

        volume_body = Volume(
            usage_threshold=200 * GIGABYTE,
            creation_token=TEST_VOL_1,
            service_level="Premium",  # cannot differ from pool
            location=LOCATION,
            subnet_id="/subscriptions/" + SUBSID + "/resourceGroups/" +
            TEST_RG + "/providers/Microsoft.Network/virtualNetworks/" + VNET +
            "/subnets/default")

        volume = self.client.volumes.begin_create_or_update(
            TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1,
            volume_body).result()
        assert "Premium" == volume.service_level  # unchanged
        assert 200 * GIGABYTE == volume.usage_threshold

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_create_delete_list_volume(self):
        volume = create_volume(
            self.client,
            TEST_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1
        )
        self.assertEqual(volume.name, TEST_ACC_1 + '/' + TEST_POOL_1 + '/' + TEST_VOL_1)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1, TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 1)

        self.client.volumes.delete(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1, TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 0)

        wait_for_no_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1)
        delete_account(self.client, TEST_RG, TEST_ACC_1)
    def test_pool_change(self):
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        pool2 = create_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_2,
                            LOCATION, True)
        if self.is_live:
            time.sleep(10)

        body = PoolChangeRequest(new_pool_resource_id=pool2.id)
        self.client.volumes.begin_pool_change(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                              TEST_VOL_1, body).wait()
        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_2,
                                         TEST_VOL_1)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + "/" + TEST_POOL_2 + "/" + TEST_VOL_1)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 0)

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_2,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_2,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #30
0
    def test_assign_snapshot_policy_to_volume(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False, excluded_headers="Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        # create volume and snapshot policy
        create_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1)
        snapshot_policy = create_snapshot_policy(self.client, TEST_SNAPSHOT_POLICY_1)
        # assign the snapshot policy to the volume
        snapshot = VolumeSnapshotProperties(snapshot_policy_id=snapshot_policy.id)
        data_protection = VolumePatchPropertiesDataProtection(snapshot=snapshot)
        volume_patch = VolumePatch(data_protection=data_protection)
        volume = self.client.volumes.begin_update(TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, volume_patch).result()

        assert volume.data_protection.snapshot.snapshot_policy_id == snapshot_policy.id

        # cleanup
        delete_volume(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, live=self.is_live)
        delete_snapshot_policy(self.client, TEST_SNAPSHOT_POLICY_1, live=self.is_live)
        delete_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_1, live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
Beispiel #31
0
    def test_volume_replication(self):
        source_volume = create_volume(
            self.client,
            TEST_REPL_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1,
            vnet=REPL_VNET,
            live=self.is_live)

        if self.is_live:
            time.sleep(5)

        sourceVolume = self.client.volumes.get(
            TEST_REPL_RG,
            TEST_ACC_1,
            TEST_POOL_1,
            TEST_VOL_1);

        dp_volume = create_dp_volume(
            self.client,
            source_volume,
            TEST_REMOTE_RG,
            TEST_ACC_2,
            TEST_POOL_2,
            TEST_VOL_2,
            live=self.is_live)

        if self.is_live:
            time.sleep(30)

        # sync replication
        self.client.volumes.authorize_replication(TEST_REPL_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, dp_volume.id)
        wait_for_succeeded(self.client);
        wait_for_replication_status(self.client, "Mirrored");

        # break replication
        self.client.volumes.break_replication(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);
        wait_for_replication_status(self.client, "Broken");
        if self.is_live:
            time.sleep(30)
        wait_for_succeeded(self.client);

        # resync
        self.client.volumes.resync_replication(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);
        wait_for_replication_status(self.client, "Mirrored");
        if self.is_live:
            time.sleep(30)

        # break again
        self.client.volumes.break_replication(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);
        wait_for_replication_status(self.client, "Broken");
        if self.is_live:
            time.sleep(30)

        # delete the data protection object
        #  - initiate delete replication on destination, this then releases on source, both resulting in object deletion
        self.client.volumes.delete_replication(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);

        replication_found = True; # because it was previously present
        while replication_found:
            try:
                replication_status = self.client.volumes.replication_status_method(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);
            except:
                # an exception means the replication was not found
                # i.e. it has been deleted
                # ok without checking it could have been for another reason
                # but then the delete below will fail
                replication_found = False;

            time.sleep(1)

        # seems the volumes are not always in a terminal state here so check again
        # and ensure the replication objects are removed
        # python isn't good at do-while loops but loop until we get volumes in succeeded state
        while True:
            source_volume = self.client.volumes.get(TEST_REPL_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1);
            dp_volume = self.client.volumes.get(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2);
            if ((source_volume.provisioning_state == "Succeeded") and (dp_volume.provisioning_state == "Succeeded") and (source_volume.data_protection.replication is None) and (dp_volume.data_protection.replication is None)):
                break
            time.sleep(1)

        # now proceed with the delete of the volumes and tidy up resources

        # delete destination volume
        self.client.volumes.delete(TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2).wait()
        wait_for_no_volume(self.client, TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, TEST_VOL_2, live=self.is_live)
        delete_pool(self.client, TEST_REMOTE_RG, TEST_ACC_2, TEST_POOL_2, live=self.is_live)
        delete_account(self.client, TEST_REMOTE_RG, TEST_ACC_2, live=self.is_live)

        # delete source volume
        self.client.volumes.delete(TEST_REPL_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1).wait()
        wait_for_no_volume(self.client, TEST_REPL_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, live=self.is_live)
        delete_pool(self.client, TEST_REPL_RG, TEST_ACC_1, TEST_POOL_1, live=self.is_live)
        delete_account(self.client, TEST_REPL_RG, TEST_ACC_1, live=self.is_live)
    def test_volume_replication(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        source_volume = create_volume(self.client,
                                      TEST_RG,
                                      TEST_ACC_1,
                                      TEST_POOL_1,
                                      TEST_VOL_1,
                                      vnet=VNET,
                                      live=self.is_live)
        dp_volume = create_dp_volume(self.client,
                                     source_volume,
                                     TEST_REPL_REMOTE_RG,
                                     TEST_ACC_2,
                                     TEST_POOL_2,
                                     TEST_VOL_2,
                                     live=self.is_live)

        if self.is_live:
            time.sleep(30)

        # sync replication
        body = AuthorizeRequest(remote_volume_resource_id=dp_volume.id)
        self.client.volumes.begin_authorize_replication(
            TEST_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, body)
        wait_for_succeeded(self.client, self.is_live)
        if self.is_live:
            time.sleep(30)
        wait_for_replication_status(self.client, "Mirrored", self.is_live)

        # break replication
        self.client.volumes.begin_break_replication(TEST_REPL_REMOTE_RG,
                                                    TEST_ACC_2, TEST_POOL_2,
                                                    TEST_VOL_2)
        wait_for_replication_status(self.client, "Broken", self.is_live)
        if self.is_live:
            time.sleep(30)
        wait_for_succeeded(self.client, self.is_live)

        # resync
        self.client.volumes.begin_resync_replication(TEST_REPL_REMOTE_RG,
                                                     TEST_ACC_2, TEST_POOL_2,
                                                     TEST_VOL_2)
        wait_for_replication_status(self.client, "Mirrored", self.is_live)
        if self.is_live:
            time.sleep(30)

        # break again
        self.client.volumes.begin_break_replication(TEST_REPL_REMOTE_RG,
                                                    TEST_ACC_2, TEST_POOL_2,
                                                    TEST_VOL_2)
        wait_for_replication_status(self.client, "Broken", self.is_live)
        if self.is_live:
            time.sleep(30)

        # delete the data protection object
        #  - initiate delete replication on destination, this then releases on source, both resulting in object deletion
        self.client.volumes.begin_delete_replication(TEST_REPL_REMOTE_RG,
                                                     TEST_ACC_2, TEST_POOL_2,
                                                     TEST_VOL_2)

        replication_found = True  # because it was previously present
        while replication_found:
            try:
                self.client.volumes.replication_status(TEST_REPL_REMOTE_RG,
                                                       TEST_ACC_2, TEST_POOL_2,
                                                       TEST_VOL_2)
            except:
                # an exception means the replication was not found
                # i.e. it has been deleted
                # ok without checking it could have been for another reason
                # but then the delete below will fail
                replication_found = False

            if self.is_live:
                time.sleep(1)

        # seems the volumes are not always in a terminal state here so check again
        # and ensure the replication objects are removed
        # python isn't good at do-while loops but loop until we get volumes in succeeded state
        while True:
            source_volume = self.client.volumes.get(TEST_RG, TEST_ACC_1,
                                                    TEST_POOL_1, TEST_VOL_1)
            dp_volume = self.client.volumes.get(TEST_REPL_REMOTE_RG,
                                                TEST_ACC_2, TEST_POOL_2,
                                                TEST_VOL_2)
            if (source_volume.provisioning_state == "Succeeded") and (dp_volume.provisioning_state == "Succeeded") and \
                    (source_volume.data_protection.replication is None) and \
                    (dp_volume.data_protection.replication is None):
                break
            if self.is_live:
                time.sleep(1)

        # now proceed with the delete of the volumes and tidy up resources

        # delete destination volume
        delete_volume(self.client,
                      TEST_REPL_REMOTE_RG,
                      TEST_ACC_2,
                      TEST_POOL_2,
                      TEST_VOL_2,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_REPL_REMOTE_RG,
                    TEST_ACC_2,
                    TEST_POOL_2,
                    live=self.is_live)
        delete_account(self.client,
                       TEST_REPL_REMOTE_RG,
                       TEST_ACC_2,
                       live=self.is_live)

        # delete source volume
        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)