コード例 #1
0
    def test_cannot_create_the_same_offering_twice(self, context,
                                                   api_service_admin_client):
        """
        <b>Description:</b>
        Attempts to create offering twice via api service

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        - It's not possible to create the same offering twice

        <b>Steps:</b>
        - Create the offering via api service and verify it's on the list
        - Try to create that offering again
        - Verify that catalog has not changed
        """
        step("Create new offering")
        test_offering = ServiceOffering.create(context,
                                               client=api_service_admin_client)
        step("Check that the offering exists")
        catalog = ServiceOffering.get_list(client=api_service_admin_client)
        assert test_offering in catalog
        step("Try creating offering with name of an already existing offering")
        assert_raises_http_exception(
            ApiServiceHttpStatus.CODE_CONFLICT,
            ApiServiceHttpStatus.MSG_SERVICE_ALREADY_EXISTS.format(
                test_offering.label),
            ServiceOffering.create,
            context,
            label=test_offering.label,
            client=api_service_admin_client)
        step("Check that catalog has not changed")
        assert sorted(ServiceOffering.get_list(
            client=api_service_admin_client)) == sorted(catalog)
コード例 #2
0
    def test_0_create_mysql_clustered_service(self, class_context, test_org,
                                              test_space):
        """
        <b>Description:</b>
        Check that mysql service instance can be created with plan clustered.

        <b>Input data:</b>
        1. test organization

        <b>Expected results:</b>
        Test passes if mysql service instance is successfully created and in state running.

        <b>Steps:</b>
        1. Get marketplace offering list.
        2. Check that mysql offering is present in marketplace.
        3. Create mysql service instance.
        4. Check that created mysql service instance is in state running.
        """
        marketplace = ServiceOffering.get_list()
        self.__class__.k8s_service = next(
            (s for s in marketplace if s.label == self.service_label), None)
        assert self.k8s_service is not None, "{} not available".format(
            self.service_label)
        self.__class__.instance = ServiceInstance.api_create_with_plan_name(
            class_context,
            test_org.guid,
            test_space.guid,
            self.service_label,
            service_plan_name=ServicePlan.CLUSTERED)
        self.instance.ensure_running()
コード例 #3
0
 def offering(cls, api_service_admin_client):
     marketplace = ServiceOffering.get_list(client=api_service_admin_client)
     usable_offerings = (
         o for o in marketplace
         if o.state == TapEntityState.READY and len(o.service_plans) > 0)
     reliable_offerings = (o for o in usable_offerings
                           if o.label in RELIABLE_OFFERINGS)
     offering = next(reliable_offerings, None)
     assert offering is not None, "No available offerings in marketplace"
     return offering
コード例 #4
0
    def test_create_and_delete_new_offering(self, context,
                                            api_service_admin_client):
        """
        <b>Description:</b>
        Create and later remove offering via api service

        <b>Input data:</b>
        - Admin credentials

        <b>Expected results:</b>
        - It's possible to create offering
        - It's possible to remove the offering

        <b>Steps:</b>
        - Create the offering via api service
        - Verify the offering is on list
        - Verify it's possible to retrieve offering via id
        - Remove the offering
        - Verify the offering was removed
        """
        step("Create new offering")
        test_offering = ServiceOffering.create(context,
                                               client=api_service_admin_client)
        step("Check that the new offering is in catalog")
        catalog = ServiceOffering.get_list(client=api_service_admin_client)
        assert test_offering in catalog
        step("Get the offering")
        offering = ServiceOffering.get(offering_id=test_offering.id,
                                       client=api_service_admin_client)
        assert test_offering == offering
        step("Delete the offering")
        test_offering.delete(client=api_service_admin_client)
        step("Check that the offering is no longer in catalog")
        catalog = ServiceOffering.get_list(client=api_service_admin_client)
        assert test_offering not in catalog
        step("Check that requesting the deleted offering returns an error")
        assert_raises_http_exception(ApiServiceHttpStatus.CODE_NOT_FOUND,
                                     ApiServiceHttpStatus.MSG_KEY_NOT_FOUND,
                                     test_offering.delete,
                                     client=api_service_admin_client,
                                     force=True)
コード例 #5
0
def pytest_generate_tests(metafunc):
    """Parametrize marketplace fixture with tuples of ServiceOffering and plan dict."""
    if "non_parametrized_marketplace_services" in metafunc.funcargnames:
        marketplace = ServiceOffering.get_list()
        test_cases = []
        ids = []
        for offering in marketplace:
            if offering.service_plans is not None:
                for plan in offering.service_plans:
                    if not ParametrizedService.is_parametrized(label=offering.label, plan_name=plan.name):
                        test_cases.append((offering, plan))
                        ids.append("{}_{}".format(offering.label, plan.name))
        metafunc.parametrize("non_parametrized_marketplace_services", test_cases, ids=ids)
コード例 #6
0
def cleanup_test_data():
    core_org_guid = core_org().guid
    test_object_models = [
        {'name': 'data set', 'objects_list': DataSet.api_get_list(), 'name_attribute': 'title'},
        {'name': 'transfer', 'objects_list': Transfer.api_get_list(), 'name_attribute': 'title'},
        {'name': 'user', 'objects_list': User.get_list_in_organization(org_guid=core_org_guid), 'name_attribute': 'username'},
        {'name': 'invitation', 'objects_list': Invitation.api_get_list(), 'name_attribute': 'username'},
        {'name': 'application', 'objects_list': Application.get_list(), 'name_attribute': 'name'},
        {'name': 'service', 'objects_list': ServiceInstance.get_list(), 'name_attribute': 'name'},
        {'name': 'offering', 'objects_list': ServiceOffering.get_list(), 'name_attribute': 'label'},
        {'name': 'scoring engine model', 'objects_list': ScoringEngineModel.get_list(org_guid=core_org_guid),
         'name_attribute': 'name'}
    ]
    for model in test_object_models:
        _cleanup_test_data(**model)
コード例 #7
0
    def from_reference(cls, org_guid):
        from modules.tap_object_model import Application, User, Organization, ServiceOffering, ServiceInstance, DataSet
        metrics = []
        app_down_states = [TapEntityState.FAILURE, TapEntityState.STOPPED]

        apps = Application.get_list()
        apps_count = len(apps)
        apps_running_count = len(
            [app for app in apps if app.state == TapEntityState.RUNNING])
        apps_down_count = len(
            [app for app in apps if app.state in app_down_states])
        user_count = len(User.get_all_users(org_guid))
        orgs_count = len(Organization.get_list())
        services_count = len(ServiceOffering.get_list())
        services_inst = len([
            instance for instance in ServiceInstance.get_list()
            if instance.state == TapEntityState.RUNNING
        ])

        nodes = KubernetesNode.get_list()
        for node in nodes:
            metrics.append(node.get_metrics())

        cpu_usage_org = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF *
                                                  cls.NODE)
        cpu_usage_platform = cls.parse_cpu(metrics) / (cls.CPU_RATE_FOR_REF *
                                                       cls.NODE)
        memory_usage_org = cls.parse_memory(metrics)
        memory_usage_platform = cls.parse_memory(metrics)

        datasets = DataSet.api_get_list(org_guid_list=[org_guid])

        return cls(apps=apps_count,
                   apps_running=apps_running_count,
                   apps_down=apps_down_count,
                   users_org=user_count,
                   users_platform=user_count,
                   orgs=orgs_count,
                   services=services_count,
                   service_instances=services_inst,
                   service_usage=services_inst,
                   cpu_usage_org=cpu_usage_org,
                   memory_usage_org=memory_usage_org,
                   cpu_usage_platform=cpu_usage_platform,
                   memory_usage_platform=memory_usage_platform,
                   datasets=datasets)
コード例 #8
0
    def test_0_check_mongodb_in_marketplace(self, test_space):
        """
        <b>Description:</b>
        Check that mongodb offering is present in marketplace.

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

        <b>Expected results:</b>
        Test passes if mongodb offering is present in marketplace.

        <b>Steps:</b>
        1. Get list of all service offerings from marketplace.
        2. Check that mongodb offering is present in retrieved list.
        """
        step("Check if mongodb clustered service is in marketplace")
        marketplace = ServiceOffering.get_list()
        mongodb = next((service for service in marketplace if service.label == self.MONGODB_SERVICE_LABEL), None)
        assert mongodb is not None, "{} not available".format(self.MONGODB_SERVICE_LABEL)
コード例 #9
0
    def test_0_create_atk_instance(self, class_context, test_org, test_space, add_admin_to_test_org):
        step("Check that atk service is available in Marketplace")
        marketplace = ServiceOffering.get_list()
        atk_service = next((s for s in marketplace if s.label == ServiceLabels.ATK), None)
        assert atk_service is not None, "No atk service found in marketplace."
        step("Create atk service instance")

        atk_instance_name = generate_test_object_name()
        atk_instance = ServiceInstance.api_create_with_plan_name(
            context=class_context,
            org_guid=test_org.guid,
            space_guid=test_space.guid,
            service_label=ServiceLabels.ATK,
            name=atk_instance_name,
            service_plan_name=ServicePlan.SIMPLE_ATK
        )

        validator = ApplicationStackValidator(atk_instance)
        validator.validate()
        self.__class__.atk_url = validator.application.urls[0]
コード例 #10
0
 def test_0_create_kerberos_instance(self, class_context, test_org,
                                     test_space):
     step("Check kerberos in marketplace")
     service_label = ServiceLabels.KERBEROS
     marketplace = ServiceOffering.get_list()
     kerberos = next(
         (service
          for service in marketplace if service.label == service_label),
         None)
     assert kerberos is not None, "{} not available".format(service_label)
     step("Create instance of kerberos")
     self.__class__.kerberos_instance = ServiceInstance.api_create_with_plan_name(
         context=class_context,
         org_guid=test_org.guid,
         space_guid=test_space.guid,
         service_label=service_label,
         service_plan_name=ServicePlan.SHARED)
     self.kerberos_instance.ensure_created()
     step("Check that the kerberos is on the instances list")
     instances = ServiceInstance.api_get_list(space_guid=test_space.guid)
     assert self.kerberos_instance in instances
コード例 #11
0
 def etcd_offering(cls, api_service_admin_client):
     offerings = ServiceOffering.get_list(client=api_service_admin_client)
     offering = next(
         (o for o in offerings if o.label == ServiceLabels.KAFKA), None)
     assert offering is not None, "{} not found".format(ServiceLabels.KAFKA)
     return offering
コード例 #12
0
 def public_service(self):
     services = ServiceOffering.get_list()
     return next(s for s in services if s.label == ServiceLabels.ZOOKEEPER)
コード例 #13
0
 def marketplace_services(cls, test_space):
     log_fixture("Get list of available services from Marketplace")
     return ServiceOffering.get_list()
コード例 #14
0
def test_marketplace():
    log_finalizer("test_marketplace: Get list of marketplace services.")
    return ServiceOffering.get_list()
コード例 #15
0
def marketplace_offerings():
    log_fixture("Get list of available services from Marketplace")
    return ServiceOffering.get_list()
コード例 #16
0
 def marketplace(cls, test_org, test_space):
     cls.marketplace = ServiceOffering.get_list()