def test_6_delete_dynamic_service(self):
     step("Delete created dynamic service")
     ServiceType.k8s_broker_delete_dynamic_service(service_name=self.service_name)
     step("Check that deleted service is not in kubernetes-broker catalog")
     catalog = ServiceType.k8s_broker_get_catalog()
     kubernetes_service = next((s for s in catalog if s.label == self.service_name), None)
     assert kubernetes_service is None
 def test_1_create_dynamic_service(self, core_org, core_space):
     step("Create new service offering in kubernetes broker")
     service_name = ServiceType.k8s_broker_create_dynamic_service(core_org.guid, core_space.guid,
                                                                  service_name=self.service_name)
     step("Check the new offering is in kubernetes-broker catalog")
     catalog = ServiceType.k8s_broker_get_catalog()
     kubernetes_service = next((s for s in catalog if s.label == service_name), None)
     assert kubernetes_service is not None
Exemplo n.º 3
0
 def test_app_register_in_marketplace(self, test_org, test_space,
                                      sample_java_app):
     register_service = ServiceType.register_app_in_marketplace(
         sample_java_app.name, sample_java_app.guid, test_org.guid,
         test_space.guid)
     services = ServiceType.cf_api_get_list_from_marketplace_by_space(
         test_space.guid)
     assert register_service in services
    def test_2_enable_service_access(self, core_space):
        step("Check service is available in cloud foundry")
        cf_services = ServiceType.cf_api_get_list(name=self.service_name, get_plans=True)
        assert len(cf_services) == 1
        self.__class__.test_service = cf_services[0]

        step("Enable service access")
        self.test_service.cf_api_enable_service_access()
        self.test_service.space_guid = core_space.guid

        step("Check the service is visible in marketplace")
        marketplace = ServiceType.api_get_list_from_marketplace(space_guid=core_space.guid)
        assert self.test_service in marketplace
Exemplo n.º 5
0
    def test_1_create_service_instance(self):
        step("Get list of services to retrieve a {} service".format(
            ServiceTag.K8S))
        services = ServiceType.api_get_list_from_marketplace(
            space_guid=self.test_space.guid)
        service = next((s for s in services if ServiceTag.K8S in s.tags), None)
        if service is None:
            raise AssertionError("No {} service available".format(
                ServiceTag.K8S))

        step("Create instance")
        self.__class__.test_instance = ServiceInstance.api_create(
            org_guid=self.test_org.guid,
            space_guid=self.test_space.guid,
            name=test_names.generate_test_object_name(short=True),
            service_label=service.label,
            service_plan_guid=service.service_plans[0]["guid"])

        step("Check that the instance is on the list")
        instances = ServiceInstance.api_get_list(
            space_guid=self.test_space.guid)
        assert self.test_instance in instances

        step("Check that new cluster is created")
        self.__class__.cluster = KubernetesCluster.demiurge_api_get(
            name=self.test_org.guid)
 def __init__(self):
     self.apps = len(Application.cf_api_get_list())
     self.service_instances = len(ServiceInstance.cf_api_get_list())
     self.services = len(ServiceType.cf_api_get_list())
     self.buildpacks = len(Buildpack.cf_api_get_list())
     self.orgs = len(Organization.cf_api_get_list())
     self.spaces = len(Space.cf_api_get_list())
     self.users = len(User.cf_api_get_all_users())
Exemplo n.º 7
0
 def test_1_register_service(self, sample_python_app):
     step("Registering new service.")
     self.__class__.cf_service = ServiceType.app_broker_create_service_in_catalog(
         self.service_name, "Example description", sample_python_app.guid)
     assert self.cf_service is not None
     assert self.cf_service.label == self.service_name
     response = broker_client.app_broker_get_catalog()
     services = [service['name'] for service in response["services"]]
     assert self.service_name in services
Exemplo n.º 8
0
def psql_instance(test_org, test_space):
    log_fixture("create_postgres_instance")
    marketplace = ServiceType.api_get_list_from_marketplace(test_space.guid)
    psql = next(service for service in marketplace
                if service.label == ServiceLabels.PSQL)
    TestData.psql_instance = ServiceInstance.api_create(
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        service_label=ServiceLabels.PSQL,
        service_plan_guid=psql.service_plan_guids[0])
    return TestData.psql_instance
Exemplo n.º 9
0
 def postgres_instance(self, request, test_org, test_space):
     step("Create postgres service instance")
     marketplace = ServiceType.api_get_list_from_marketplace(
         test_space.guid)
     psql = next(service for service in marketplace
                 if service.label == ServiceLabels.PSQL)
     instance_name = generate_test_object_name()
     psql_instance = ServiceInstance.api_create(
         org_guid=test_org.guid,
         space_guid=test_space.guid,
         service_label=ServiceLabels.PSQL,
         name=instance_name,
         service_plan_guid=psql.service_plan_guids[0])
     request.addfinalizer(lambda: psql_instance.cleanup())
     return psql_instance
Exemplo n.º 10
0
 def orientdb_service(self, test_org, test_space):
     """SetUp: OrientDB service creation."""
     step("Create OrientDB service instance.")
     marketplace = ServiceType.api_get_list_from_marketplace(
         test_space.guid)
     orient_db = next((service for service in marketplace
                       if service.label == ServiceLabels.ORIENT_DB), None)
     assert orient_db is not None, "{} service is not available in Marketplace".format(
         ServiceLabels.ORIENT_DB)
     instance_name = generate_test_object_name()
     return ServiceInstance.api_create(
         org_guid=test_org.guid,
         space_guid=test_space.guid,
         service_label=ServiceLabels.ORIENT_DB,
         name=instance_name,
         service_plan_guid=orient_db.service_plan_guids[0])
Exemplo n.º 11
0
def test_create_service_with_icon(test_org, test_space, sample_python_app,
                                  example_image):
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        image=example_image)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that images are the same")
    assert example_image == bytes(service.image, "utf8")
    step("Delete service")
    service.api_delete()
Exemplo n.º 12
0
def test_create_and_delete_service(test_org, test_space, sample_python_app):
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Delete service")
    service.api_delete()
    step("Check that service isn't in marketplace")
    assert_not_in_with_retry(service,
                             ServiceType.api_get_list_from_marketplace,
                             test_space.guid)
Exemplo n.º 13
0
def test_create_service_with_tag(test_org, test_space, sample_python_app):
    tags = [generate_test_object_name(short=True)]
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        tags=tags)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that tags names are the same")
    assert tags == service.tags
    step("Delete service")
    service.api_delete()
Exemplo n.º 14
0
def test_create_service_with_display_name(test_org, test_space,
                                          sample_python_app):
    display_name = generate_test_object_name()
    step("Register in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid,
        display_name=display_name)
    step("Check that service is in marketplace")
    assert_in_with_retry(service, ServiceType.api_get_list_from_marketplace,
                         test_space.guid)
    step("Check that display names are the same")
    assert display_name == service.display_name
    step("Delete service")
    service.api_delete()
Exemplo n.º 15
0
def sample_service(request, test_org, test_space, sample_python_app):
    log_fixture("sample_service: Register sample app in marketplace")
    service = ServiceType.register_app_in_marketplace(
        app_name=sample_python_app.name,
        app_guid=sample_python_app.guid,
        org_guid=test_org.guid,
        space_guid=test_space.guid)
    log_fixture("sample_service: Get service plans")
    service.api_get_service_plans()

    def fin():
        log_fixture("sample_service: Delete service")
        service.api_delete()

    request.addfinalizer(fin)

    return service
Exemplo n.º 16
0
def pytest_generate_tests(metafunc):
    """Parametrize marketplace fixture with tuples of ServiceType and plan dict."""
    if "non_parametrized_marketplace_services" in metafunc.funcargnames:
        core_space = fixtures.core_space()
        marketplace = ServiceType.api_get_list_from_marketplace(
            space_guid=core_space.guid)
        test_cases = []
        ids = []
        for service_type in marketplace:
            for plan in service_type.service_plans:
                if not ParametrizedService.is_parametrized(
                        label=service_type.label, plan_name=plan["name"]):
                    test_cases.append((service_type, plan))
                    ids.append("{}_{}".format(service_type.label,
                                              plan["name"]))
        metafunc.parametrize("non_parametrized_marketplace_services",
                             test_cases,
                             ids=ids)
Exemplo n.º 17
0
    def test_0_create_atk_instance(self, test_org, test_space, add_admin_to_test_org):
        step("Check that atk service is available in Marketplace")
        marketplace = ServiceType.api_get_list_from_marketplace(test_space.guid)
        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(
            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]
Exemplo n.º 18
0
 def test_0_create_instance_of_kubernetes_service(self, test_org, test_space):
     step("Retrieve example kubernetes service from marketplace")
     marketplace = ServiceType.api_get_list_from_marketplace(space_guid=test_space.guid)
     k8s_service = next((s for s in marketplace if s.label == self.service_label), None)
     assert k8s_service is not None, "{} not available".format(self.service_label)
     plan_guid = next((p["guid"] for p in k8s_service.service_plans if p["name"] == self.plan_name), None)
     assert plan_guid is not None, "Plan {} not available".format(self.plan_name)
     step("Create instance of the k8s service")
     self.__class__.test_instance = ServiceInstance.api_create(
         org_guid=test_org.guid,
         space_guid=test_space.guid,
         service_label=self.service_label,
         service_plan_guid=plan_guid
     )
     step("Wait until the instance is running")
     self.__class__.k8s_instance = KubernetesInstance.from_service_instance(
         guid=self.test_instance.guid,
         plan_guid=plan_guid,
         space_guid=test_space.guid,
         org_guid=test_org.guid
     )
     self.k8s_instance.ensure_running_in_cluster()
     step("Check instance has correct status on TAP")
     self.test_instance.ensure_created()
Exemplo n.º 19
0
 def test_check_marketplace_services_list_vs_cloudfoundry(self):
     self.step("Check that services in cf are the same as in Marketplace")
     cf_marketplace = ServiceType.cf_api_get_list_from_marketplace_by_space(
         TestData.test_space.guid)
     self.assertUnorderedListEqual(self.marketplace, cf_marketplace)
Exemplo n.º 20
0
 def marketplace(cls, test_org, test_space):
     cls.marketplace = ServiceType.api_get_list_from_marketplace(test_space.guid)
 def marketplace_services(cls, test_org, test_space):
     step("Get marketplace services")
     cls.marketplace = ServiceType.api_get_list_from_marketplace(
         test_space.guid)
 def test_5_disable_service_access(self, core_space):
     step("Disable service access")
     self.test_service.cf_api_disable_service_access()
     step("Check the service is not visible in marketplace")
     marketplace = ServiceType.api_get_list_from_marketplace(space_guid=core_space.guid)
     assert self.test_service not in marketplace
Exemplo n.º 23
0
 def marketplace_services(cls, test_org, test_space):
     cls.test_org = test_org
     cls.step("Get list of available services from Marketplace")
     cls.marketplace_services = ServiceType.api_get_list_from_marketplace(test_space.guid)
Exemplo n.º 24
0
def test_marketplace(test_space):
    log_finalizer(
        "test_marketplace: Get list of marketplace services in test space")
    return ServiceType.api_get_list_from_marketplace(
        space_guid=test_space.guid)