Exemple #1
0
    def test_generator_with_app_name_bad_chars(self):
        app_name_with_underscores = "test_app"
        spinnaker_tags = {}
        raw_tags = {}

        http_client = _given_config_url_response_content_is(
            VALID_DEPLOY_CONFIG_V3)
        generator = ApplicationGenerator(
            http_client, create_deployment_id=lambda: DEPLOYMENT_ID)
        deployment_id, returned_application = generator.generate_application(
            target_namespace=ANY_NAMESPACE,
            release=Release(VALID_IMAGE_NAME, VALID_DEPLOY_CONFIG_URL,
                            make_safe_name(app_name_with_underscores),
                            app_name_with_underscores, spinnaker_tags,
                            raw_tags))

        returned_metadata = returned_application.metadata
        assert returned_metadata.name == make_safe_name(
            app_name_with_underscores)
        assert returned_metadata.labels["app"] == make_safe_name(
            app_name_with_underscores)
        returned_spec = returned_application.spec
        assert returned_spec.application == make_safe_name(
            app_name_with_underscores)
        assert returned_spec.config["annotations"]["mast"][
            "originalApplicationName"] == app_name_with_underscores
Exemple #2
0
    def test_generator_annotates_moniker_application(self, config,
                                                     target_namespace,
                                                     expected_namespace):
        spinnaker_tags = {}
        raw_tags = {}
        metadata_annotation = {
            "moniker.spinnaker.io/application": "unicorn",
            "this_is_a_number": 3,
            "this_is_a_floating_point_number": 3.14,
            "this_is_a_bool": True,
        }

        expected_metadata_annotations = {
            "moniker.spinnaker.io/application": "unicorn",
            "this_is_a_number": "3",
            "this_is_a_floating_point_number": "3.14",
            "this_is_a_bool": "True",
        }

        http_client = _given_config_url_response_content_is(config)
        generator = ApplicationGenerator(
            http_client, create_deployment_id=lambda: DEPLOYMENT_ID)
        deployment_id, returned_application = generator.generate_application(
            target_namespace=target_namespace,
            release=Release(VALID_IMAGE_NAME, VALID_DEPLOY_CONFIG_URL,
                            make_safe_name(APPLICATION_NAME), APPLICATION_NAME,
                            spinnaker_tags, raw_tags, metadata_annotation))
        expected_application = BASE_PAASBETA_APPLICATION
        expected_application["metadata"]["namespace"] = expected_namespace
        expected_application["metadata"][
            "annotations"] = expected_metadata_annotations

        assert returned_application.as_dict() == expected_application
Exemple #3
0
 def _annotations_verification(self, spinnaker_tags, raw_tags,
                               exptected_paasbeta_result, deploy_config):
     http_client = _given_config_url_response_content_is(deploy_config)
     generator = ApplicationGenerator(
         http_client, create_deployment_id=lambda: DEPLOYMENT_ID)
     deployment_id, returned_paasbeta_application = generator.generate_application(
         target_namespace=ANY_NAMESPACE,
         release=Release(VALID_IMAGE_NAME, VALID_DEPLOY_CONFIG_URL,
                         make_safe_name(APPLICATION_NAME), APPLICATION_NAME,
                         spinnaker_tags, raw_tags))
     returned_annotations = returned_paasbeta_application.spec.config[
         "annotations"]
     assert returned_annotations == exptected_paasbeta_result
Exemple #4
0
    def test_generator_without_annotations(self):
        spinnaker_tags = {}
        raw_tags = {}

        http_client = _given_config_url_response_content_is(
            VALID_DEPLOY_CONFIG_V3)
        generator = ApplicationGenerator(
            http_client, create_deployment_id=lambda: DEPLOYMENT_ID)
        deployment_id, returned_paasbeta_application = generator.generate_application(
            target_namespace=ANY_NAMESPACE,
            release=Release(VALID_IMAGE_NAME, VALID_DEPLOY_CONFIG_URL,
                            make_safe_name(APPLICATION_NAME), APPLICATION_NAME,
                            spinnaker_tags, raw_tags))
        assert "annotations" not in returned_paasbeta_application.spec.config
Exemple #5
0
    def test_generator_creates_object_of_given_type(self, config,
                                                    target_namespace,
                                                    expected_namespace):
        spinnaker_tags = {}
        raw_tags = {}

        http_client = _given_config_url_response_content_is(config)
        generator = ApplicationGenerator(
            http_client, create_deployment_id=lambda: DEPLOYMENT_ID)
        deployment_id, returned_paasbeta_application = generator.generate_application(
            target_namespace=target_namespace,
            release=Release(VALID_IMAGE_NAME, VALID_DEPLOY_CONFIG_URL,
                            make_safe_name(APPLICATION_NAME), APPLICATION_NAME,
                            spinnaker_tags, raw_tags))
        expected_paasbeta_application = BASE_PAASBETA_APPLICATION
        expected_paasbeta_application["metadata"][
            "namespace"] = expected_namespace
        assert returned_paasbeta_application.as_dict(
        ) == expected_paasbeta_application