示例#1
0
    def test_positive_update_username(self):
        """Create an external docker registry and update its username

        :id: 9cb24a5a-e383-446e-9b1a-3bf02e0ef439

        :expectedresults: the external registry is updated with the new
            username

        :CaseImportance: Critical
        """
        with Session(self) as session:
            name = gen_string('utf8')
            make_registry(
                session,
                name=name,
                url=self.url,
                username=gen_string('alphanumeric'),
            )
            try:
                registry_entity = entities.Registry(name=name).search()[0]
                self.assertIsNotNone(self.registry.search(name))
                new_username = gen_string('utf8')
                self.registry.update(name, new_username=new_username)
                self.registry.search_and_click(name)
                self.assertIsNotNone(
                    self.registry.wait_until_element(
                        locators['registry.username']).text, new_username)
            finally:
                registry_entity.delete()
示例#2
0
    def test_positive_update_url(self):
        """Create an external docker registry and update its URL

        :id: cf477436-085d-4517-ad86-23e3d254ad70

        :expectedresults: the external registry is updated with the new URL

        :CaseImportance: Critical
        """
        with Session(self) as session:
            name = gen_string('utf8')
            make_registry(
                session,
                name=name,
                url=self.url,
            )
            try:
                registry_entity = entities.Registry(name=name).search()[0]
                self.assertIsNotNone(self.registry.search(name))
                new_url = settings.docker.external_registry_2
                self.registry.update(name, new_url=new_url)
                self.registry.search_and_click(name)
                self.assertEqual(
                    self.registry.get_element_value(locators['registry.url']),
                    new_url)
            finally:
                registry_entity.delete()
示例#3
0
    def test_positive_update_description(self):
        """Create an external docker registry and update its description

        :id: 0ca5e992-b28e-452e-a2be-fca57b4b5195

        :expectedresults: the external registry is updated with the new
            description

        :CaseImportance: Critical
        """
        with Session(self) as session:
            name = gen_string('utf8')
            make_registry(
                session,
                name=name,
                url=self.url,
                description=gen_string('alphanumeric'),
            )
            try:
                registry_entity = entities.Registry(name=name).search()[0]
                self.assertIsNotNone(self.registry.search(name))
                new_description = gen_string('utf8')
                self.registry.update(name, new_desc=new_description)
                self.registry.search_and_click(name)
                self.assertIsNotNone(
                    self.registry.wait_until_element(
                        locators['registry.description']).text,
                    new_description)
            finally:
                registry_entity.delete()
示例#4
0
    def test_positive_update_name(self):
        """Create an external docker registry and update its name

        :id: 2b59f929-4a47-4216-b8b3-7f923d8e7de9

        :expectedresults: the external registry is updated with the new name

        :CaseImportance: Critical
        """
        with Session(self) as session:
            name = gen_string('utf8')
            make_registry(
                session,
                name=name,
                url=self.url,
                description=gen_string('utf8'),
            )
            try:
                registry_entity = entities.Registry(name=name).search()[0]
                self.assertIsNotNone(self.registry.search(name))
                for new_name in valid_data_list():
                    with self.subTest(new_name):
                        self.registry.update(name, new_name=new_name)
                        self.assertIsNotNone(self.registry.search(new_name))
                        name = new_name
            finally:
                registry_entity.delete()
示例#5
0
    def test_positive_update_description(self):
        """Create an external docker registry and update its description

        @Feature: Docker

        @Assert: the external registry is updated with the new description
        """
        registry = entities.Registry().create()
        for new_desc in valid_data_list():
            with self.subTest(new_desc):
                registry.description = new_desc
                registry = registry.update()
                self.assertEqual(registry.description, new_desc)
示例#6
0
    def test_positive_delete(self):
        """Create an external docker registry and then delete it

        @Feature: Docker

        @Assert: The external registry is deleted successfully
        """
        for name in valid_data_list():
            with self.subTest(name):
                registry = entities.Registry(name=name).create()
                registry.delete()
                with self.assertRaises(HTTPError):
                    registry.read()
示例#7
0
    def test_positive_update_name(self):
        """Create an external docker registry and update its name

        @Feature: Docker

        @Assert: the external registry is updated with the new name
        """
        registry = entities.Registry(name=gen_string('alpha')).create()
        for new_name in valid_data_list():
            with self.subTest(new_name):
                registry.name = new_name
                registry = registry.update()
                self.assertEqual(registry.name, new_name)
示例#8
0
    def test_positive_update_url(self):
        """Create an external docker registry and update its URL

        @Feature: Docker

        @Assert: the external registry is updated with the new URL
        """
        url = gen_url(subdomain=gen_string('alpha'))
        new_url = gen_url(subdomain=gen_string('alpha'))
        registry = entities.Registry(url=url).create()
        self.assertEqual(registry.url, url)
        registry.url = new_url
        registry = registry.update()
        self.assertEqual(registry.url, new_url)
示例#9
0
    def test_negative_create_with_name(self):
        """Create an external docker registry with not supported api calls

        :id: f3542272-13db-4a49-bc27-d948f5d6df41

        :expectedresults: External registry is not created successfully
        """
        for name in valid_data_list():
            with self.subTest(name):
                description = gen_string('alphanumeric')
                with self.assertRaises(HTTPError):
                    entities.Registry(
                        description=description,
                        name=name,
                        url=self.url,
                    ).create()
示例#10
0
    def test_positive_update_username(self):
        """Create an external docker registry and update its username

        @Feature: Docker

        @Assert: the external registry is updated with the new username
        """
        username = gen_string('alpha')
        new_username = gen_string('alpha')
        registry = entities.Registry(
            username=username,
            password=gen_string('alpha'),
        ).create()
        self.assertEqual(registry.username, username)
        registry.username = new_username
        registry = registry.update()
        self.assertEqual(registry.username, new_username)
示例#11
0
    def test_positive_create_with_name(self):
        """Create an external docker registry

        @Feature: Docker

        @Assert: External registry is created successfully
        """
        for name in valid_data_list():
            with self.subTest(name):
                url = gen_url(subdomain=gen_string('alpha'))
                description = gen_string('alphanumeric')
                registry = entities.Registry(
                    description=description,
                    name=name,
                    url=url,
                ).create()
                self.assertEqual(registry.name, name)
                self.assertEqual(registry.url, url)
                self.assertEqual(registry.description, description)
示例#12
0
    def test_positive_create_with_name(self):
        """Create an external docker registry

        :id: 7d2a2271-801e-454b-af0e-fedf1d96a7d5

        :expectedresults: the external registry is created

        :CaseImportance: Critical
        """
        with Session(self) as session:
            for name in valid_data_list():
                with self.subTest(name):
                    make_registry(
                        session,
                        name=name,
                        url=self.url,
                        description=gen_string('utf8'),
                    )
                    try:
                        self.assertIsNotNone(self.registry.search(name))
                    finally:
                        entities.Registry(name=name).search()[0].delete()
    def test_pre_scenario_containers_support_removal(self):
        """Pre-upgrade scenario test to verify containers created and run
        before upgrade

        :id: preupgrade-f6de07ae-14c7-4452-9cb1-cafe2aa648ae

        :steps:

            1. Create docker host
            2. Create and run container from dockerhub
            3. Create and run container from external registry

        :expectedresults:

            1. Docker host is created
            2. Container from dockerhub is created and running
            3. Container from external registry is created and running

        """
        rh_registry_available = not bz_bug_is_open(1703397)
        repo_name = 'rhel'
        compute_resource_name = gen_string('alpha')
        registry_url = settings.docker.external_registry_1

        org = entities.Organization().create()

        docker_host = VirtualMachine(source_image=settings.docker.docker_image,
                                     tag=u'docker')
        docker_host.create()
        try:
            docker_host.install_katello_ca()

            compute_resource = entities.DockerComputeResource(
                name=compute_resource_name,
                organization=[org],
                url='http://{0}:2375'.format(docker_host.ip_addr),
            ).create()

            # Only one registry with given URL can exist on Satellite,
            # so search for it first and create it only if necessary
            try:
                registry = entities.Registry().search(
                    filters={'url': registry_url})[0]
            except IndexError:
                registry = entities.Registry(
                    url=registry_url,
                    organization=[org],
                ).create()

            # container from dockerhub
            dockerhub_container = entities.DockerHubContainer(
                command='sleep inf',
                compute_resource=compute_resource,
                organization=[org],
            ).create()
            self.assertEqual(dockerhub_container.compute_resource.id,
                             compute_resource.id)

            # container from external registry
            if rh_registry_available:
                external_container = entities.DockerRegistryContainer(
                    command='sleep inf',
                    compute_resource=compute_resource,
                    organization=[org],
                    registry=registry,
                    repository_name=repo_name,
                ).create()
                self.assertEqual(external_container.compute_resource.id,
                                 compute_resource.id)
                self.assertEqual(external_container.registry.id, registry.id)
                self.assertEqual(external_container.repository_name, repo_name)

            running_containers = docker_host.run('docker ps')
            self.assertEqual(running_containers.return_code, 0)

            self.assertTrue(
                any(dockerhub_container.name in line
                    for line in running_containers.stdout))
            if rh_registry_available:
                self.assertTrue(
                    any(external_container.name in line
                        for line in running_containers.stdout))

            ext_container_name = external_container.name if rh_registry_available else ''

            scenario_dict = {
                self.__class__.__name__: {
                    'rh_registry_available': rh_registry_available,
                    'docker_host': docker_host.hostname,
                    'dockerhub_container': dockerhub_container.name,
                    'external_container': ext_container_name,
                }
            }
            create_dict(scenario_dict)
        except Exception as exp:
            self._vm_cleanup(hostname=docker_host.hostname)
            raise Exception(exp)