Beispiel #1
0
    def test_cannot_create_service_instance_with_name_of_an_existing_instance(
            self, context):
        """
        <b>Description:</b>
        Check that it's impossible to create a service instance
        with name that is already used by another instance.

        <b>Input data:</b>
        1. Rabbit mq offering
        2. Redis offering

        <b>Expected results:</b>
        Test passes if platform returns 409 http code.

        <b>Steps:</b>
        1. Create rabbit mq service instance.
        2. Check that instance is running.
        3. Try to create redis service insance with same name as rabbit mq instance.
        4. Check that platform returns 409 http code.
        """
        step("Create service instance")
        instance = ServiceInstance.create_with_name(
            context,
            offering_label=ServiceLabels.RABBIT_MQ,
            plan_name=ServicePlan.SINGLE_SMALL)
        step("Ensure that instance is running")
        instance.ensure_running()
        step("Try to create service instance with already taken name")
        with pytest.raises(UnexpectedResponseError) as e:
            ServiceInstance.create_with_name(
                context,
                offering_label=ServiceLabels.REDIS,
                plan_name=ServicePlan.SINGLE_SMALL,
                name=instance.name)
        assert e.value.status == HttpStatus.CODE_CONFLICT, "Created service instance with already taken name"
Beispiel #2
0
def kerberos_instance(session_context, api_service_admin_client):
    log_fixture("create_kerberos_instance")
    kerberos = ServiceInstance.create_with_name(context=session_context, offering_label=ServiceLabels.KERBEROS,
                                     plan_name=ServicePlan.SHARED, client=api_service_admin_client)
    log_fixture("Check the service instance is running")
    kerberos.ensure_running()
    return kerberos
Beispiel #3
0
def hdfs_instance(session_context, api_service_admin_client):
    log_fixture("create_hdfs_instance")
    hdfs = ServiceInstance.create_with_name(context=session_context, offering_label=ServiceLabels.HDFS,
                                            plan_name=ServicePlan.ENCRYPTED_DIR, client=api_service_admin_client)
    log_fixture("Check the service instance is running")
    hdfs.ensure_running()
    return hdfs
Beispiel #4
0
def mysql_instance(session_context, api_service_admin_client):
    log_fixture("create_mysql_instance")
    mysql = ServiceInstance.create_with_name(context=session_context, client=api_service_admin_client,
                                             offering_label=ServiceLabels.MYSQL, plan_name=ServicePlan.SINGLE_SMALL)
    log_fixture("Check the service instance is running")
    mysql.ensure_running()
    return mysql
Beispiel #5
0
def test_create_and_delete_marketplace_service_instances(
        context, service_label, plan_name):
    """
    <b>Description:</b>
    Checks if a service instance can be created and deleted from the platform.

    <b>Input data:</b>
    1. Offering names.

    <b>Expected results:</b>
    Test passes when a service instance was successfully created and removed from the platform for every marketplace
    official offering and its plans.

    <b>Steps:</b>
    1. Create service instance of every offering and its plans.
    2. Verify that the service instance is in state RUNNING.
    3. Delete the service instance of an offering.
    4. Verify the service instance was deleted from the platform.
    """
    step("Create instance {} {}".format(service_label, plan_name))
    instance = ServiceInstance.create_with_name(context,
                                                offering_label=service_label,
                                                plan_name=plan_name)
    step("Check that the instance is running")
    instance.ensure_running()
    step("Stop service instance")
    instance.stop()
    instance.ensure_stopped()
    step("Delete the instance")
    instance.delete()
    step("Check that the instance was deleted")
    instance.ensure_deleted()
    def test_0_create_gateway_instance(self, class_context,
                                       test_org_user_client):
        """
        <b>Description:</b>
        Check that by creating a gateway instance the gateway application is created.

        <b>Input data:</b>
        1. user client

        <b>Expected results:</b>
        Test passes when gateway instance is successfully created.

        <b>Steps:</b>
        1. Create gateway instance with plan single.
        2. Check that gateway instance is running.
        3. Check that gateway application was created.
        """
        step("Create gateway instance")
        gateway_instance = ServiceInstance.create_with_name(
            class_context,
            name=test_names.generate_test_object_name(separator="",
                                                      short=True),
            offering_label=ServiceLabels.GATEWAY,
            plan_name=ServicePlan.SINGLE,
            client=test_org_user_client)
        gateway_instance.ensure_running()
        validator = ApplicationStackValidator(gateway_instance)
        self.__class__.gateway_instance = gateway_instance
        self.__class__.gateway_app = validator.application
    def test_get_stable_state(self, class_context):
        """
        <b>Description:</b>
        Checks catalog stable state

        <b>Input data:</b>
        No input data.

        <b>Expected results:</b>
        Test checks if catalog state is stable or unstable.

        <b>Steps:</b>
        1. Get catalog state.
        2. If catalog is stable, add unstable instance and check if state is unstable.
        3. If catalog is unstable, skip test.
        """
        step("Get catalog stable state")
        response = CatalogState.get_stable_state()
        stable = response["stable"]
        message = response["message"]
        if stable is True:
            step("Stable is true, add unstable instance")
            instance = ServiceInstance.create_with_name(
                class_context,
                offering_label=ServiceLabels.RABBIT_MQ,
                plan_name=ServicePlan.SINGLE_SMALL)
            response = CatalogState.get_stable_state()
            stable = response["stable"]
            assert stable is False
            instance.ensure_running()
        else:
            pytest.skip("Instances are unstable:{}".format(message))
 def instance(self, context):
     instance = ServiceInstance.create_with_name(
         context=context,
         offering_label=ServiceLabels.KAFKA,
         plan_name=ServicePlan.SHARED)
     instance.ensure_running()
     return instance
 def instance(cls, class_context, api_service_admin_client):
     instance = ServiceInstance.create_with_name(
         context=class_context,
         offering_label=ServiceLabels.KAFKA,
         plan_name=ServicePlan.SHARED,
         client=api_service_admin_client)
     instance.ensure_running(client=api_service_admin_client)
     return instance
 def service_instance(self, class_context):
     log_fixture("Create sample service instance")
     instance = ServiceInstance.create_with_name(
         class_context,
         offering_label=ServiceLabels.RABBIT_MQ,
         plan_name=ServicePlan.SINGLE_SMALL)
     step("Ensure that instance is running")
     instance.ensure_running()
     return instance
Beispiel #11
0
def orientdb_instance(session_context, api_service_admin_client):
    log_fixture("orientdb_instance: create")
    orientdb = ServiceInstance.create_with_name(context=session_context,
                                                client=api_service_admin_client,
                                                offering_label=ServiceLabels.ORIENT_DB,
                                                plan_name=ServicePlan.SINGLE_SMALL)
    log_fixture("orientdb_instance: ensure instance is running")
    orientdb.ensure_running()
    return orientdb
Beispiel #12
0
 def se_instance(self, class_context):
     step("Create scoring engine instance")
     instance = ServiceInstance.create_with_name(
         context=class_context,
         offering_label=ServiceLabels.SCORING_ENGINE,
         plan_name=ServicePlan.SINGLE)
     step("Check that scoring engine instance is runnning")
     instance.ensure_running()
     return instance
Beispiel #13
0
    def test_create_and_delete_service_offering_admin(
            self, context, app_jar, offering_json, manifest_json,
            api_service_admin_client):
        """
        <b>Description:</b>
        Create service offering, create an instance of it, delete instance and delete offering.

        <b>Input data:</b>
        1. application jar file
        2. manifest.json file
        3. offering.json file
        4. admin client

        <b>Expected results:</b>
        Test passes when:
        - New offering is created from application jar file.
        - Instance of newly created offering is created.
        - Instance can be deleted.
        - New offering can be deleted from marketplace.

        <b>Steps:</b>
        1. Create service offering from a application jar file.
        2. Create service instance.
        3. Stop service instance.
        4. Delete service instance.
        5. Delete service offering.
        """
        step("Register in marketplace")
        service = ServiceOffering.create_from_binary(
            context,
            jar_path=app_jar,
            manifest_path=manifest_json,
            offering_path=offering_json,
            client=api_service_admin_client)
        step("Check that service is in marketplace")
        assert_in_with_retry(service, ServiceOffering.get_list)
        step("Check that service is in state 'READY'")
        service.ensure_ready()
        step("Create service instance")
        instance = ServiceInstance.create_with_name(
            context, offering_label=service.label, plan_name=ServicePlan.FREE)
        step("Check created instance")
        instance.ensure_running()
        assert instance.offering_id == service.id
        assert instance.offering_label == service.label
        step("Stop service instance")
        instance.stop()
        instance.ensure_stopped()
        step("Delete service instance")
        instance.delete()
        instance.ensure_deleted()
        step("Delete service")
        service.delete(client=api_service_admin_client)
        step("Check that service isn't in marketplace")
        assert_not_in_with_retry(service, ServiceOffering.get_list)
 def offering_from_python_app(self, context, api_service_admin_client, sample_python_app):
     app = sample_python_app
     image = Application.get_image(app_inst_id=app.id, client=api_service_admin_client)
     offering_json = template_example.sample_python_app_offering
     offering_json['body'][0]['deployments'][0]['spec']['template']['spec']['containers'][0]['image'] = image
     offering = ServiceOffering.create(context, client=api_service_admin_client,
                                       template_body=offering_json['body'])
     service = ServiceInstance.create_with_name(context, offering_label=offering.label,
                                                plan_name=offering.service_plans[0].name)
     ServiceInstance.ensure_running(service, client=api_service_admin_client)
     return service
Beispiel #15
0
 def __init__(self,
              context,
              service_plan_name,
              instance_name=None,
              params=None):
     self.instance = ServiceInstance.create_with_name(
         context=context,
         offering_label=ServiceLabels.GEARPUMP,
         name=instance_name,
         plan_name=service_plan_name,
         params=params)
     self.yarn_app_id = None
     self.client = HttpClientFactory.get(ConsoleConfigurationProvider.get())
     self.ssh_client = None
     self._gearpump_url = None
 def test_service_instance_dashboard(self, context, offering_name,
                                     plan_name):
     name = generate_test_object_name(separator="")
     step('Create {} service instance'.format(offering_name))
     instance = ServiceInstance.create_with_name(
         context,
         offering_label=offering_name,
         plan_name=plan_name,
         name=name)
     instance.ensure_running()
     self._go_to_dashboard(instance, offering_name)
     step("Stop {} service instance".format(offering_name))
     instance.stop()
     instance.ensure_stopped()
     step("Delete {} service instance".format(offering_name))
     instance.delete()
Beispiel #17
0
    def test_create_and_delete_service_instance(self, context,
                                                test_org_user_client,
                                                offering_name, plan_name,
                                                open_tunnel):
        """
        <b>Description:</b>
        Check service instance creation and deletion.

        <b>Input data:</b>
        1. non parametized marketplace services

        <b>Expected results:</b>
        Test passes when service instance is created and deleted successfully.

        <b>Steps:</b>
        1. Create service instance.
        2. Ensure that instance is running.
        3. Check that service instance is present on instances list.
        4. Stop service instance.
        5. Delete service instance.
        """
        step("Create an instance")
        instance = ServiceInstance.create_with_name(
            context,
            offering_label=offering_name,
            plan_name=plan_name,
            client=test_org_user_client)
        step("Ensure that instance is running")
        instance.ensure_running()
        step("Check that service instance is present")
        assert_in_with_retry(instance,
                             ServiceInstance.get_list,
                             name=instance.name)
        step("Validate resources")
        self.validate_resources(instance, offering_name, plan_name,
                                open_tunnel)
        step("Stop service instance")
        instance.stop()
        instance.ensure_stopped()
        step("Delete an instance")
        instance.delete()
        instance.ensure_deleted()
 def test_create_and_delete_service_instances(self, context, service_label,
                                              marketplace_offerings):
     service_type = next(
         (s for s in marketplace_offerings if s.label == service_label),
         None)
     assert service_type is not None, "{} service is not available in Marketplace".format(
         service_label)
     plan = next(iter(service_type.service_plans))
     step("Create service instance")
     instance = ServiceInstance.create_with_name(
         context=context,
         offering_label=service_type.label,
         plan_name=plan.name)
     instance.ensure_running()
     validator = ApplicationStackValidator(instance)
     validator.validate(validate_application=False)
     step("Stop service instance")
     instance.stop()
     instance.ensure_stopped()
     step("Delete service instance")
     instance.delete()
     instance.ensure_deleted()
Beispiel #19
0
    def test_0_hdfs_plain_dir(self, class_context):
        """
        <b>Description:</b>
        Verify if is it possible to create instance of HDFS in plan Plain-Dir.

        Test create HDFS instance with plan Plain-Dir and check that instance running.

        <b>Input data:</b>
            HDFS instance

        <b>Expected results:</b>
            HDFS instance with plan Plain-Dir is created and running.

        <b>Steps:</b>
            1. Create HDFS instance with plan Plain-Dir
            2. Check that instance is running
        """
        step("Create HDFS instance in plan Plain-Dir")
        self.__class__.instance_hdfs = ServiceInstance.create_with_name(
            class_context,
            offering_label=ServiceLabels.HDFS,
            plan_name=ServicePlan.PLAIN_DIR)
        step("Ensure instance is in RUNNING state")
        self.instance_hdfs.ensure_running()
    def test_elasticsearch(self, context, api_service_admin_client, plan):
        """
        <b>Description:</b>
        Verify if it is possible to create instance of Elasticsearch-24 and do some operations on search engine.

        Test creates Elasticsearch-24 instance, expose URLs and check cluster health, insert some data, search in data,
        count inserted data using Elasticsearch-24 REST Api.

        <b>Input data:</b>
        1. Elasticsearch-24 instance
        2. Sample json data

        <b>Expected results:</b>
        It is possible to create Elasticsearch-24 instance, expose its URLs and operations like insert data, search in
        data, count data work properly.

        <b>Steps:</b>
        1. Create Elasticsearch-24 instance
        2. Check Elasticsearch-24 cluster health
        3. Insert sample data
        4. Get inserted data
        5. Search in inserted data
        6. Count inserted data
        7. Insert new data
        8. Count inserted data
        """
        sample_data_1 = {
            "user": "******",
            "post_date": "2009-11-15T14:12:12",
            "message": "trying out Elasticsearch"
        }
        sample_data_2 = {
            "user": "******",
            "post_date": "2009-12-11T22:22:22",
            "message": "inserting new data to Elasticsearch"
        }
        add_data_msg = "\"total\":1,\"successful\":1,\"failed\":0"
        step("Create elasticsearch instance")
        elasticsearch = ServiceInstance.create_with_name(
            context=context,
            offering_label=ServiceLabels.ELASTICSEARCH24,
            plan_name=plan)
        elasticsearch.ensure_running(client=api_service_admin_client)
        urls = ServiceInstance.expose_urls(service_id=elasticsearch.id,
                                           client=api_service_admin_client)
        ServiceInstance.ensure_responding(url=urls[0])
        step("Check cluster health")
        response = requests.get(url="{}/_cluster/health".format(urls[0]))
        assert "\"status\":\"green\"", "\"number_of_nodes\":1" in str(
            response.content)
        step("Insert sample data")
        response = requests.put(url="{}/twitter/tweet/1".format(urls[0]),
                                data=json.dumps(sample_data_1),
                                headers={'Content-Type': 'application/json'})
        assert add_data_msg in str(response.content)
        step("Get inserted data")
        requests.get(url="{}/twitter/_refresh".format(urls[0]))
        response = requests.get(url="{}/twitter/tweet/1".format(urls[0]))
        step("Search in data")
        response_search = requests.get(
            url="{}/twitter/_search?q=user:kimchy".format(urls[0]))
        for value in sample_data_1.values():
            assert value in str(response.content)
            assert value in str(response_search.content)
        step("Count inserted data")
        response = requests.get(url="{}/twitter/_count".format(urls[0]))
        assert "\"count\":1" in str(response.content)
        step("Insert new data")
        requests.put(url="{}/twitter/tweet/2".format(urls[0]),
                     data=json.dumps(sample_data_2),
                     headers={'Content-Type': 'application/json'})
        requests.get(url="{}/twitter/_refresh".format(urls[0]))
        step("Count inserted data")
        response = requests.get(url="{}/twitter/_count".format(urls[0]))
        assert "\"count\":2" in str(response.content)