Exemplo n.º 1
0
    def test_delete_account_backups(self):
        create_backup(self.client,
                      backup_name=TEST_BACKUP_1,
                      live=self.is_live)

        account_backup_list = self.client.account_backups.list(
            BACKUP_RG, TEST_ACC_1)
        self.assertGreaterEqual(len(list(account_backup_list)), 1)

        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        self.client.account_backups.begin_delete(BACKUP_RG, TEST_ACC_1,
                                                 TEST_BACKUP_1).wait()

        account_backup_list = self.client.account_backups.list(
            BACKUP_RG, TEST_ACC_1)
        for backup in account_backup_list:
            self.assertNotEqual(backup.name, TEST_ACC_1 + "/" + TEST_BACKUP_1)

        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
Exemplo n.º 2
0
    def test_get_account_backups(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_backup(self.client,
                      backup_name=TEST_BACKUP_1,
                      live=self.is_live)

        account_backup = self.client.account_backups.get(
            TEST_RG, TEST_ACC_1, TEST_BACKUP_1)
        assert account_backup.name == TEST_ACC_1 + "/" + TEST_BACKUP_1

        disable_backup(self.client, TEST_BACKUP_1, live=self.is_live)
        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_vault(self):
        create_volume(self.client,
                      CBS_RESOURCE_GROUP,
                      CBS_ACCOUNT,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      location=CBS_LOCATION,
                      vnet=CBS_VNET)
        vaults = self.client.vaults.list(CBS_RESOURCE_GROUP, CBS_ACCOUNT)
        self.assertEqual(len(list(vaults)), 1)

        # clean up
        delete_volume(self.client,
                      CBS_RESOURCE_GROUP,
                      CBS_ACCOUNT,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    CBS_RESOURCE_GROUP,
                    CBS_ACCOUNT,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client,
                       CBS_RESOURCE_GROUP,
                       CBS_ACCOUNT,
                       live=self.is_live)
    def test_update_backup(self):
        create_backup(self.client, live=self.is_live)

        tag = {'Tag1': 'Value1'}
        backup_body = BackupPatch(location=BACKUP_LOCATION, tags=tag)
        self.client.backups.begin_update(BACKUP_RG, TEST_ACC_1, TEST_POOL_1,
                                         TEST_VOL_1, TEST_BACKUP_1,
                                         backup_body).wait()

        backup = get_backup(self.client)
        self.assertTrue(backup.tags['Tag1'] == 'Value1')

        disable_backup(self.client, live=self.is_live)
        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
    def test_list_backup(self):
        create_backup(self.client, live=self.is_live)
        create_backup(self.client,
                      backup_name=TEST_BACKUP_2,
                      backup_only=True,
                      live=self.is_live)

        backup_list = get_backup_list(self.client)
        self.assertEqual(len(list(backup_list)), 2)
        idx = 0
        for backup in backup_list:
            self.assertEqual(backup.name, backups[idx])
            idx += 1

        disable_backup(self.client, live=self.is_live)
        disable_backup(self.client,
                       backup_name=TEST_BACKUP_2,
                       live=self.is_live)

        backup_list = get_backup_list(self.client)
        self.assertEqual(len(list(backup_list)), 0)

        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
    def test_get_vault(self):
        create_volume(self.client)
        vaults = self.client.vaults.list(TEST_RG, TEST_ACC_1)
        self.assertEqual(len(list(vaults)), 1)

        # clean up
        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 clean_up(client, disable_bp=True, live=False):
    if disable_bp:
        disable_backup(client, live=live)

    delete_volume(client,
                  TEST_RG,
                  TEST_ACC_1,
                  TEST_POOL_1,
                  TEST_VOL_1,
                  live=live)
    delete_pool(client, TEST_RG, TEST_ACC_1, TEST_POOL_1, live=live)
    delete_account(client, TEST_RG, TEST_ACC_1, live=live)
Exemplo n.º 8
0
    def test_list_account_backups(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_backup(self.client,
                      backup_name=TEST_BACKUP_1,
                      live=self.is_live)
        create_backup(self.client,
                      backup_name=TEST_BACKUP_2,
                      backup_only=True,
                      live=self.is_live)

        account_backup_list = self.client.account_backups.list(
            TEST_RG, TEST_ACC_1)
        backup_count = 0
        for backup in account_backup_list:
            if TEST_BACKUP_1 in backup.name or TEST_BACKUP_2 in backup.name:
                backup_count += 1

        assert backup_count == 2

        disable_backup(self.client, live=self.is_live)
        disable_backup(self.client,
                       backup_name=TEST_BACKUP_2,
                       live=self.is_live)

        account_backup_list = self.client.account_backups.list(
            TEST_RG, TEST_ACC_1)
        backup_count = 0
        for backup in account_backup_list:
            if TEST_BACKUP_1 in backup.name or TEST_BACKUP_2 in backup.name:
                backup_count += 1

        assert backup_count == 0

        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)
Exemplo n.º 9
0
    def test_list_account_backups(self):
        create_backup(self.client,
                      backup_name=TEST_BACKUP_1,
                      live=self.is_live)
        create_backup(self.client,
                      backup_name=TEST_BACKUP_2,
                      backup_only=True,
                      live=self.is_live)

        account_backup_list = self.client.account_backups.list(
            BACKUP_RG, TEST_ACC_1)
        backup_count = 0
        for backup in account_backup_list:
            if TEST_BACKUP_1 in backup.name or TEST_BACKUP_2 in backup.name:
                backup_count += 1

        self.assertEqual(backup_count, 2)

        disable_backup(self.client, live=self.is_live)
        disable_backup(self.client,
                       backup_name=TEST_BACKUP_2,
                       live=self.is_live)

        account_backup_list = self.client.account_backups.list(
            BACKUP_RG, TEST_ACC_1)
        backup_count = 0
        for backup in account_backup_list:
            if TEST_BACKUP_1 in backup.name or TEST_BACKUP_2 in backup.name:
                backup_count += 1

        self.assertEqual(backup_count, 0)

        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
    def test_get_backup_status(self):
        create_backup(self.client, live=self.is_live)

        backup_status = self.client.backups.get_status(BACKUP_RG, TEST_ACC_1,
                                                       TEST_POOL_1, TEST_VOL_1)
        self.assertTrue(backup_status.healthy)
        self.assertEqual(backup_status.mirrorState, "Mirrored")

        disable_backup(self.client, live=self.is_live)
        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
    def test_get_backup_by_name(self):
        create_backup(self.client, live=self.is_live)

        backup = get_backup(self.client, TEST_BACKUP_1)
        self.assertEqual(
            backup.name, TEST_ACC_1 + "/" + TEST_POOL_1 + "/" + TEST_VOL_1 +
            "/" + TEST_BACKUP_1)

        disable_backup(self.client, TEST_BACKUP_1, live=self.is_live)
        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
    def test_get_account_backups(self):
        create_backup(self.client,
                      backup_name=TEST_BACKUP_1,
                      live=self.is_live)

        account_backup = self.client.account_backups.get(
            TEST_RG, TEST_ACC_1, TEST_BACKUP_1)
        self.assertEqual(account_backup.name, TEST_ACC_1 + "/" + TEST_BACKUP_1)

        disable_backup(self.client, TEST_BACKUP_1, live=self.is_live)
        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_backup(self):
        # Create 2 backups since delete backups can only be used when volume has multiple backups
        create_backup(self.client, live=self.is_live)

        create_backup(self.client,
                      backup_name=TEST_BACKUP_2,
                      backup_only=True,
                      live=self.is_live)
        backup_list = get_backup_list(self.client)
        self.assertEqual(len(list(backup_list)), 2)

        # delete the older backup since we are not able to delete the newest one with delete backup service
        delete_backup(self.client, live=self.is_live)

        # check if backup was deleted
        backup_list = get_backup_list(self.client)
        self.assertEqual(len(list(backup_list)), 1)

        # automaticaly delete the second backup by disable backups on volume
        disable_backup(self.client, live=self.is_live)

        backup_list = get_backup_list(self.client)
        self.assertEqual(len(list(backup_list)), 0)

        delete_volume(self.client,
                      BACKUP_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    BACKUP_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_account(self.client, BACKUP_RG, TEST_ACC_1, live=self.is_live)
Exemplo n.º 14
0
    def test_get_vault(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)
        vaults = self.client.vaults.list(TEST_RG, TEST_ACC_1)
        assert len(list(vaults)) == 1

        # clean up
        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)