Ejemplo n.º 1
0
def setup():
    """
    Setup for Arakoon package, will be executed when any test in this package is being executed
    Make necessary changes before being able to run the tests
    :return: None
    """
    autotest_config = General.get_config()
    backend_name = autotest_config.get('backend', 'name')
    assert backend_name, 'Please fill out a backend name in the autotest.cfg file'
    backend = GeneralBackend.get_by_name(backend_name)
    if backend is not None:
        GeneralAlba.remove_alba_backend(backend.alba_backend)

    for storagerouter in GeneralStorageRouter.get_masters():
        root_client = SSHClient(storagerouter, username='******')
        if GeneralService.get_service_status(name='ovs-scheduled-tasks',
                                             client=root_client) is True:
            GeneralService.stop_service(name='ovs-scheduled-tasks',
                                        client=root_client)

    storagerouters = GeneralStorageRouter.get_storage_routers()
    for sr in storagerouters:
        root_client = SSHClient(sr, username='******')
        GeneralDisk.add_db_role(sr)

        for location in TEST_CLEANUP:
            root_client.run('rm -rf {0}'.format(location))

    GeneralAlba.add_alba_backend(backend_name)
    GeneralArakoon.voldrv_arakoon_checkup()
Ejemplo n.º 2
0
    def be_0005_add_remove_preset_no_compression_encryption_test():
        """
        Add and remove a preset without compression and with encryption
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            GeneralAlba.add_alba_backend(TestALBA.backend_name)

        name = 'be_preset_05'
        compression = 'none'
        encryption = 'aes-cbc-256'
        policies = [[1, 1, 1, 2]]
        TestALBA.add_validate_remove_preset(name, compression, encryption, policies)
Ejemplo n.º 3
0
def setup():
    """
    Setup for Backend package, will be executed when any test in this package is being executed
    Make necessary changes before being able to run the tests
    :return: None
    """
    General.validate_required_config_settings(settings={'backend': ['name']})
    my_sr = GeneralStorageRouter.get_local_storagerouter()
    if GeneralStorageRouter.has_roles(storagerouter=my_sr, roles='DB') is False:
        GeneralDisk.add_db_role(my_sr)

    alba_backend_name = General.get_config().get('backend', 'name')
    alba_backend = GeneralAlba.get_by_name(alba_backend_name)
    if alba_backend is None:
        GeneralAlba.add_alba_backend(alba_backend_name)
Ejemplo n.º 4
0
    def be_0004_validate_preset_with_replication_copies_test():
        """
        Validate a preset
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            GeneralAlba.add_alba_backend(TestALBA.backend_name)

        compression = 'none'
        encryption = 'none'
        name_prefix = 'be_preset_04'
        for nr in xrange(6):
            name = name_prefix + str(nr)
            policies = [[1, nr, 1, 1 + nr]]
            TestALBA.add_validate_remove_preset(name, compression, encryption, policies)
Ejemplo n.º 5
0
    def ovs_3188_verify_namespace_test():
        """
        Verify namespaces
        """
        nr_of_disks_to_create = 5
        namespace_prefix = 'ovs_3188-'
        compression = 'none'
        encryption = 'none'
        preset_name = 'be_preset_02'
        policies = [[1, 1, 1, 2]]

        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            backend = GeneralAlba.add_alba_backend(TestALBA.backend_name).backend
        GeneralAlba.add_preset(backend.alba_backend, preset_name, policies, compression, encryption)

        for x in range(nr_of_disks_to_create):
            namespace_name = namespace_prefix + str(x)
            GeneralAlba.execute_alba_cli_action(backend.alba_backend, 'create-namespace', [namespace_name, preset_name], False)
            GeneralAlba.upload_file(backend.alba_backend, namespace_name, 1024 * 1024 * 1)

        AlbaScheduledTaskController.verify_namespaces()

        GeneralAlba.remove_alba_namespaces(backend.alba_backend)
        GeneralAlba.remove_preset(backend.alba_backend, preset_name)
Ejemplo n.º 6
0
    def be_0001_add_and_remove_backend_test():
        """
        Create an ALBA backend and verify its status
        Validate services, etcd, arakoon without claiming disks
        Claim some disks and validate whether backend can be used for storing objects in namespaces
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is not None:
            raise ValueError('A backend has already been deployed, cannot execute test')

        alba_backend = GeneralAlba.add_alba_backend(TestALBA.backend_name)
        GeneralAlba.validate_alba_backend_sanity_without_claimed_disks(alba_backend=alba_backend)

        GeneralAlba.claim_asds(alba_backend, 3, 'SATA')
        GeneralAlba.validate_alba_backend_sanity_with_claimed_disks(alba_backend=alba_backend)

        guid = alba_backend.guid
        name = TestALBA.backend_name
        service_names = GeneralAlba.get_maintenance_services_for_alba_backend(alba_backend=alba_backend)

        GeneralAlba.unclaim_disks(alba_backend)
        GeneralAlba.remove_alba_backend(alba_backend)
        GeneralAlba.validate_alba_backend_removal(alba_backend_info={'name': name,
                                                                     'guid': guid,
                                                                     'maintenance_service_names': service_names})
Ejemplo n.º 7
0
    def be_0006_add_remove_preset_compression_encryption_test():
        """
        Add and remove a preset with compression and encryption
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            GeneralAlba.add_alba_backend(TestALBA.backend_name)

        name = 'be_preset_06a'
        compression = 'bz2'
        encryption = 'aes-cbc-256'
        policies = [[1, 1, 1, 2]]
        TestALBA.add_validate_remove_preset(name, compression, encryption, policies)

        name = 'be_preset_06b'
        compression = 'snappy'
        TestALBA.add_validate_remove_preset(name, compression, encryption, policies)
Ejemplo n.º 8
0
    def be_0007_add_update_remove_preset_test():
        """
        Add, update and remove a preset
        Validation for OVS-3187 - edit policy of preset
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            alba_backend = GeneralAlba.add_alba_backend(TestALBA.backend_name)
        else:
            alba_backend = backend.alba_backend

        GeneralAlba.claim_asds(alba_backend=alba_backend, nr_of_asds=3, disk_type='SATA')

        timeout = 300
        preset_name = 'be_preset_0007'
        namespace_name = 'be_0007_ns'
        compression = 'none'
        encryption = 'aes-cbc-256'
        org_policy = [[1, 1, 1, 2]]
        new_policy = [[2, 2, 3, 3]]

        TestALBA.add_validate_remove_preset(preset_name, compression, encryption, org_policy, remove_when_finished=False)
        result = GeneralAlba.list_alba_namespaces(alba_backend=alba_backend,
                                                  name=namespace_name)

        for namespace in result:
            GeneralAlba.execute_alba_cli_action(alba_backend, 'delete-namespace', [namespace['name']], False)
        GeneralAlba.execute_alba_cli_action(alba_backend, 'create-namespace', [namespace_name, preset_name], False)

        GeneralAlba.upload_file(alba_backend=alba_backend, namespace_name=namespace_name, file_size=1024 * 1024)

        result = GeneralAlba.execute_alba_cli_action(alba_backend, 'show-namespace', [namespace_name])['bucket_count']
        assert len(result) == 1, "Only one policy should be present, found: {0}".format(result)

        # update and verify policies for preset
        GeneralAlba.update_preset(alba_backend, preset_name, new_policy)

        result = GeneralAlba.execute_alba_cli_action(alba_backend, 'show-namespace', [namespace_name])['bucket_count']
        assert len(result) == 1, "Expected 1 policy, but got: {0}".format(result)

        object_has_new_policy = False
        for _ in xrange(timeout):
            if GeneralAlba.is_bucket_count_valid_with_policy(result, new_policy):
                object_has_new_policy = True
                break
            time.sleep(1)
            result = GeneralAlba.execute_alba_cli_action(alba_backend, 'show-namespace', [namespace_name])['bucket_count']

        assert object_has_new_policy is True, "Object was not rewritten within {0} seconds: {1}".format(timeout, result)

        # cleanup
        GeneralAlba.execute_alba_cli_action(alba_backend, 'delete-namespace', [namespace_name], False)
        GeneralAlba.remove_preset(alba_backend, preset_name)
Ejemplo n.º 9
0
    def ovs_3977_maintenance_agent_test():
        """
        Test maintenance agent processes
        """
        def _get_agent_distribution(agent_name):
            result = {}
            total = 0
            for ip in alba_node_ips:
                count = General.execute_command_on_node(ip, 'ls /etc/init/alba-maintenance_{0}-* | wc -l'.format(agent_name))
                if count:
                    count = int(count)
                else:
                    count = 0
                total += count
                result[ip] = count
            result['total'] = total

            print 'Maintenance agent distribution: {0}'.format(result)
            for ip in alba_node_ips:
                assert (result[ip] == total / len(alba_node_ips) or result[ip] == (total / len(alba_node_ips)) + 1),\
                    "Agents not equally distributed!"

            return result

        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            backend = GeneralAlba.add_alba_backend(TestALBA.backend_name).backend
        name = backend.alba_backend.name

        alba_node_ips = [node.ip for node in GeneralAlba.get_alba_nodes()]

        etcd_key = '/ovs/alba/backends/{0}/maintenance/nr_of_agents'.format(backend.alba_backend.guid)
        nr_of_agents = EtcdConfiguration.get(etcd_key)
        print '1. - nr of agents: {0}'.format(nr_of_agents)

        actual_nr_of_agents = _get_agent_distribution(name)['total']
        assert nr_of_agents == actual_nr_of_agents, \
            'Actual {0} and requested {1} nr of agents does not match'.format(nr_of_agents, actual_nr_of_agents)

        # set nr to zero
        EtcdConfiguration.set(etcd_key, 0)
        GeneralAlba.checkup_maintenance_agents()
        assert _get_agent_distribution(name)['total'] == 0, \
            'Actual {0} and requested {1} nr of agents does not match'.format(nr_of_agents, actual_nr_of_agents)
        print '2. - nr of agents: {0}'.format(nr_of_agents)

        # set nr to 10
        EtcdConfiguration.set(etcd_key, 10)
        GeneralAlba.checkup_maintenance_agents()
        assert _get_agent_distribution(name)['total'] == 10, \
            'Actual {0} and requested {1} nr of agents does not match'.format(nr_of_agents, actual_nr_of_agents)
        print '3. - nr of agents: {0}'.format(nr_of_agents)
Ejemplo n.º 10
0
    def ovs_3490_add_remove_preset_test():
        """
        Adds and removes a preset with encryption to an existing alba backend
        """
        backend = GeneralBackend.get_by_name(TestALBA.backend_name)
        if backend is None:
            backend = GeneralAlba.add_alba_backend(TestALBA.backend_name).backend

        name = 'ovs-3490'
        policies = [[1, 1, 1, 2]]
        compression = 'none'
        encryption = 'aes-cbc-256'
        status, message = GeneralAlba.add_preset(backend.alba_backend, name, policies, compression, encryption)
        assert status, "Add preset failed with: {0}".format(message)
        TestALBA.verify_policies_for_preset(name, policies, compression, encryption)
        status, message = GeneralAlba.remove_preset(backend.alba_backend, name)
        assert status, "Remove preset failed with: {0}".format(message)
        assert not TestALBA.is_preset_present(name), "Preset with name {0} is not present".format(name)