Пример #1
0
    def test_expose_unexpose_service(self, catalog_instance_nats):
        """
        <b>Description:</b>
        Expose and unexpose service instance

        <b>Input data:</b>
        - Container broker instance
        - Hostname
        - Port

        <b>Expected results:</b>
        It is possible to expose and unexpose service instance.

        <b>Steps:</b>
        - Verify hosts number of unexposed service instance.
        - Expose service instance.
        - Send request to exposed service instance.
        - Try to expose service instance again.
        - Verify that HTTP response status code is 409 with proper message.
        - Unexpose service instance.
        - Try to unexpose instance once again
        - Verify that HTTP response status code is 404 with proper message.
        """
        step("Verify hosts number of unexposed service instance")
        nats_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_nats.id)
        hosts = nats_instance.get_hosts()
        assert len(hosts) == 0
        step("Expose service instance")
        nats_instance.expose_service_instance(hostname=self.HOSTNAME,
                                              ports=[self.PORT])
        hosts = nats_instance.get_hosts()
        expected_host = "http://{}-{}.{}".format(self.HOSTNAME, self.PORT,
                                                 config.tap_domain)
        assert expected_host in hosts
        step("Send request to exposed service instance")
        response = self._send_request(url=expected_host)
        assert str(self.PORT) in str(response.text)
        step("Try to expose service instance again")
        expected_msg = ContainerBrokerHttpStatus.MSG_INGRESS_ALREADY_EXISTS.format(
            catalog_instance_nats.id)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_CONFLICT,
            expected_msg,
            nats_instance.expose_service_instance,
            hostname=self.HOSTNAME,
            ports=[self.PORT])
        step("Unexpose service instance")
        nats_instance.unexpose_service_instance()
        hosts = nats_instance.get_hosts()
        assert len(hosts) == 0
        step("Try to unexpose instance once again")
        expected_msg = ContainerBrokerHttpStatus.MSG_INGRESS_NOT_FOUND.format(
            catalog_instance_nats.id)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_NOT_FOUND, expected_msg,
            nats_instance.unexpose_service_instance)
Пример #2
0
    def test_expose_service_without_hostname(self, catalog_instance_nats):
        """
        <b>Description:</b>
        Try to expose service instance without hostname

        <b>Input data:</b>
        - Container broker instance.
        - Port.

        <b>Expected results:</b>
        It is not possible to expose service without hostname.

        <b>Steps:</b>
        - Try to expose service instance.
        - Verify that HTTP response status code is 400 with proper message.
        """
        nats_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_nats.id)
        body = {"ports": [self.PORT]}
        step("Try to expose service instance without hostname")
        expected_msg = ContainerBrokerHttpStatus.MSG_EMPTY_HOSTNAME.format(
            catalog_instance_nats.id, "-{}.{}".format(self.PORT,
                                                      config.tap_domain))
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_BAD_REQUEST,
            expected_msg,
            nats_instance.expose_service_instance,
            hostname=None,
            ports=None,
            body=body)
Пример #3
0
    def test_expose_service_invalid_port(self, catalog_instance_nats):
        """
        <b>Description:</b>
        Try to expose service instance with invalid port

        <b>Input data:</b>
        - Container broker instance.
        - Hostname
        - Invalid port.

        <b>Expected results:</b>
        It is not possible to expose service with invalid port.

        <b>Steps:</b>
        - Try to expose service instance.
        - Verify that HTTP response status code is 400 with proper message.
        """
        nats_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_nats.id)
        step("Try to expose service instance with invalid port")
        expected_msg = ContainerBrokerHttpStatus.MSG_CANNOT_EXPOSE.format(
            catalog_instance_nats.id, self.INVALID_PORT)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_BAD_REQUEST,
            expected_msg,
            nats_instance.expose_service_instance,
            hostname=self.HOSTNAME,
            ports=[self.INVALID_PORT])
Пример #4
0
    def test_get_instance_envs_in_container_broker(self, catalog_instance_a):
        """
        <b>Description:</b>
        Retrieve environment variables for instance from container broker

        <b>Input data:</b>
        Catalog broker instance

        <b>Expected results:</b>
        It's possible to retrieve all envs from instance

        <b>Steps:</b>
        - Create container broker instance
        - Retrieve the environment variables
        """
        step("CONTAINER-BROKER: Get instance envs")
        container_broker_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_a.id)
        response = container_broker_instance.get_envs()
        assert ContainerBrokerInstance.ENVS_KEY in response[0]
Пример #5
0
    def test_get_instance_logs_in_container_broker(self, catalog_instance_a):
        """
        <b>Description:</b>
        Retrieve service instance logs from container broker

        <b>Input data:</b>
        Catalog broker instance

        <b>Expected results:</b>
        It's possible to retrieve logs from container broker

        <b>Steps:</b>
        - Create container broker instance
        - Ask for logs for newly created instance from service broker
        """
        step("CONTAINER-BROKER: Get instance logs")
        container_broker_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_a.id)
        response = container_broker_instance.get_logs()
        assert isinstance(response, dict)
Пример #6
0
    def test_bind_and_unbind_instances(self, offering_a, catalog_instance_a,
                                       catalog_instance_b):
        """
        <b>Description:</b>
        Bind two container broker instances to each other

        <b>Input data:</b>
        Two instances

        <b>Expected results:</b>
        It's possible to bind two instances to each other

        <b>Steps:</b>
        - Create two instances
        - Bind them to each other and verify they have a bond
        - Unbind the instances and verify that the bond was lost
        """
        step("CONTAINER-BROKER: Bind two instances")
        src_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_a.id)
        dst_instance = ContainerBrokerInstance(
            instance_id=catalog_instance_b.id)
        src_instance.bind(bound_instance_id=dst_instance.id)
        catalog_instance_a.ensure_in_state(
            expected_state=TapEntityState.RUNNING)
        catalog_instance_b.ensure_in_state(
            expected_state=TapEntityState.RUNNING)

        step("CATALOG: Check that the instances are bound")
        # dst instance should have bindings, src instance should not
        dst_catalog_instance = CatalogServiceInstance.get(
            service_id=catalog_instance_b.class_id,
            instance_id=catalog_instance_b.id)
        dst_catalog_instance.ensure_bound(src_instance_id=src_instance.id)
        src_catalog_instance = CatalogServiceInstance.get(
            service_id=catalog_instance_a.class_id,
            instance_id=catalog_instance_a.id)
        assert src_catalog_instance.bound_instance_ids == []

        step("KUBERNETES: Check if dst pod has src instance info")
        self._assert_binding_in_pod_with_retry(
            instance_id=dst_catalog_instance.id,
            offering_label=offering_a.name)

        step("CONTAINER-BROKER: Unbind the instances")
        src_instance.unbind(bound_instance_id=dst_instance.id)

        step("CATALOG: Check that the instances are not bound")
        dst_catalog_instance = CatalogServiceInstance.get(
            service_id=catalog_instance_b.class_id,
            instance_id=catalog_instance_b.id)
        dst_catalog_instance.ensure_unbound(src_instance_id=src_instance.id)
        src_catalog_instance = CatalogServiceInstance.get(
            service_id=catalog_instance_a.class_id,
            instance_id=catalog_instance_a.id)
        assert src_catalog_instance.bound_instance_ids == []
Пример #7
0
    def test_get_specific_secret(self):
        """
        <b>Description:</b>
        Get specific secret.

        <b>Input data:</b>
        Container broker instance.

        <b>Expected results:</b>
        Information about specific secret.

        <b>Steps:</b>
        - Get information about specific secret.
        - Verify if information contains secret name.
        """
        step("Get specific secret")
        response = ContainerBrokerInstance.get_secret(secret_name="minio")
        assert response is not None
        assert response["metadata"]["name"] == "minio"
Пример #8
0
    def test_get_specific_configmap(self):
        """
        <b>Description:</b>
        Get specific configmap.

        <b>Input data:</b>
        Container broker instance.

        <b>Expected results:</b>
        Information about specific configmap.

        <b>Steps:</b>
        - Get information about specific configmap.
        - Verify if information contains configmap name.
        """
        step("Get specific configmap")
        response = ContainerBrokerInstance.get_configmap(
            configmap_name="minio")
        assert response is not None
        assert response["metadata"]["labels"]["app"] == "minio"
Пример #9
0
    def test_get_core_components_version(self):
        """
        <b>Description:</b>
        Get version information about core components.

        <b>Input data:</b>
        Container broker instance.

        <b>Expected results:</b>
        Information about core components.

        <b>Steps:</b>
        - Get version about core components.
        - Verify if core component is on the list.
        """
        step("Get version information about core components")
        response = ContainerBrokerInstance.get_version()
        assert response is not None
        components = [c["name"] for c in response]
        assert TAP.auth_gateway in components
Пример #10
0
    def test_cannot_get_envs_with_incorrect_instance_id(self):
        """
        <b>Description:</b>
        Retrieve envs from an non-existent instance

        <b>Input data:</b>
        Wrong instance id

        <b>Expected results:</b>
        It's not possible retrieve any environment variables

        <b>Steps:</b>
        - Create container broker instance with bad id
        - Retrieve the environment variables
        - Verify platform returned error
        """
        non_existing_instance = ContainerBrokerInstance(
            instance_id=Guid.NON_EXISTING_GUID)
        expected_msg = ContainerBrokerHttpStatus.MSG_SERVICES_NOT_FOUND.format(
            non_existing_instance.id)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_NOT_FOUND, expected_msg,
            non_existing_instance.get_envs)
Пример #11
0
    def test_get_custom_configmap_secret(self, open_tunnel,
                                         catalog_instance_nats):
        """
        <b>Description:</b>
        Get custom configmap and secret.

        <b>Input data:</b>
        - Container broker service instance

        <b>Expected results:</b>
        It is possible to get cucstom configmap and secret.

        <b>Steps:</b>
        - Get custom configmap name.
        - Get custom configmap details.
        - Get custom secret name.
        - Get custom secret details.
        - Delete service instance.
        - Verify if custom configmap exists - HTTP response status code is 404 with proper message.
        - Verify if custom secret exists - HTTP response status code is 404 with proper message
        """
        step("Get custom configmap name")
        short_instance_id = catalog_instance_nats.id.replace("-", "")[:13]
        short_instance_id = "x{}".format(short_instance_id)
        configmap_name_suffix = "-nats-credentials"
        configmap_name = "{}{}".format(short_instance_id,
                                       configmap_name_suffix)
        step("Get custom configmap details")
        response = ContainerBrokerInstance.get_configmap(
            configmap_name=configmap_name)
        assert configmap_name == response["metadata"]["name"]
        assert response["metadata"]["labels"][
            "instance_id"] == catalog_instance_nats.id

        step("Get custom secret name")
        secret_name_suffix = "-nats-credentials"
        secret_name = "{}{}".format(short_instance_id, secret_name_suffix)
        step("Get custom secret details")
        response = ContainerBrokerInstance.get_secret(secret_name=secret_name)
        assert secret_name == response["metadata"]["name"]
        assert response["metadata"]["labels"][
            "instance_id"] == catalog_instance_nats.id

        step("Delete service instance")
        catalog_instance_nats.stop()
        catalog_instance_nats.destroy()
        catalog_instance_nats.ensure_deleted()
        step("Verify if custom configmap exists")
        expected_msg = ContainerBrokerHttpStatus.MSG_CONFIGMAPS_NOT_FOUND.format(
            configmap_name)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_NOT_FOUND,
            expected_msg,
            ContainerBrokerInstance.get_configmap,
            configmap_name=configmap_name)
        step("Verify if custom secret exists")
        expected_msg = ContainerBrokerHttpStatus.MSG_SECRET_NOT_FOUND.format(
            secret_name)
        assertions.assert_raises_http_exception(
            ContainerBrokerHttpStatus.CODE_NOT_FOUND,
            expected_msg,
            ContainerBrokerInstance.get_secret,
            secret_name=secret_name)