def test_signals_start_of_deploy(self, app_spec, lifecycle,
                                     lifecycle_subject, deployer, annotations,
                                     repository):
        if annotations:
            app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(
                *[annotations] * 6))
        deployer._queue = [
            DeployerEvent("UPDATE", app_spec, lifecycle_subject)
        ]
        deployer()

        lifecycle.state_change_signal.send.assert_called_with(
            status=STATUS_STARTED, subject=lifecycle_subject)
Пример #2
0
    def test_signals_start_of_deploy(self, app_spec, lifecycle, deployer,
                                     annotations, repository):
        if annotations:
            app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(
                *[annotations] * 5))
        deployer._queue = [DeployerEvent("UPDATE", app_spec)]
        deployer()

        lifecycle.deploy_signal.send.assert_called_with(
            app_name=app_spec.name,
            namespace=app_spec.namespace,
            deployment_id=app_spec.deployment_id,
            repository=repository)
    def test_signals_failure_on_exception(self, app_spec, lifecycle,
                                          lifecycle_subject, deployer, adapter,
                                          annotations, repository):
        if annotations:
            app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(
                *[annotations] * 6))
        deployer._queue = [
            DeployerEvent("UPDATE", app_spec, lifecycle_subject)
        ]
        adapter.deploy.side_effect = Exception("message")

        deployer()

        lifecycle.state_change_signal.send.assert_called_with(
            status=STATUS_FAILED, subject=lifecycle_subject)
Пример #4
0
def app_spec(**kwargs):
    default_app_spec = AppSpec(
        uid="c1f34517-6f54-11ea-8eaf-0ad3d9992c8c",
        name="testapp",
        namespace="default",
        image="finntech/testimage:version",
        replicas=3,
        autoscaler=AutoscalerSpec(enabled=False, min_replicas=2, cpu_threshold_percentage=50),
        resources=ResourcesSpec(requests=ResourceRequirementSpec(cpu=None, memory=None),
                                limits=ResourceRequirementSpec(cpu=None, memory=None)),
        admin_access=False,
        secrets_in_environment=False,
        prometheus=PrometheusSpec(enabled=True, port='http', path='/internal-backstage/prometheus'),
        datadog=DatadogSpec(enabled=False, tags={}),
        ports=[
            PortSpec(protocol="http", name="http", port=80, target_port=8080),
        ],
        health_checks=HealthCheckSpec(
            liveness=CheckSpec(tcp=TcpCheckSpec(port=8080), http=None, execute=None, initial_delay_seconds=10,
                               period_seconds=10, success_threshold=1, failure_threshold=3, timeout_seconds=1),
            readiness=CheckSpec(http=HttpCheckSpec(path="/", port=8080, http_headers={}), tcp=None, execute=None,
                                initial_delay_seconds=10, period_seconds=10, success_threshold=1,
                                failure_threshold=3, timeout_seconds=1)),
        teams=[u'foo'],
        tags=[u'bar'],
        deployment_id="test_app_deployment_id",
        labels=LabelAndAnnotationSpec({}, {}, {}, {}, {}, {}),
        annotations=LabelAndAnnotationSpec({}, {}, ANNOTATIONS.copy(), {}, {}, {}),
        ingresses=[IngressItemSpec(host=None, pathmappings=[IngressPathMappingSpec(path="/", port=80)], annotations={})],
        strongbox=StrongboxSpec(enabled=False, iam_role=None, aws_region="eu-west-1", groups=None),
        singleton=False,
        ingress_tls=IngressTlsSpec(enabled=False, certificate_issuer=None),
        secrets=[]
    )

    return default_app_spec._replace(**kwargs)
Пример #5
0
 def test_transformation(self, transformer, app_spec, statuses, timestamps,
                         expected, annotations):
     if annotations:
         app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(
             *[annotations] * 6))
     with mock.patch(
             "fiaas_deploy_daemon.usage_reporting.transformer._timestamp"
     ) as timestamp:
         timestamp.side_effect = timestamps
         for status in statuses:
             transformed = transformer(status, app_spec.name,
                                       app_spec.namespace,
                                       app_spec.deployment_id,
                                       _repository(app_spec))
         assert expected == transformed
Пример #6
0
    def test_signals_failure_on_exception(self, app_spec, lifecycle, deployer,
                                          adapter, annotations, repository):
        if annotations:
            app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(
                *[annotations] * 5))
        deployer._queue = [DeployerEvent("UPDATE", app_spec)]
        adapter.deploy.side_effect = Exception("message")

        deployer()

        lifecycle.success_signal.send.assert_not_called()
        lifecycle.error_signal.send.assert_called_with(
            app_name=app_spec.name,
            namespace=app_spec.namespace,
            deployment_id=app_spec.deployment_id,
            repository=repository)
    def test_deployment_failed(self, get, app_spec, bookkeeper, requested, replicas, available, updated,
                               lifecycle, annotations, repository):
        if annotations:
            app_spec = app_spec._replace(annotations=LabelAndAnnotationSpec(*[annotations] * 5))

        self._create_response(get, requested, replicas, available, updated)

        ready = ReadyCheck(app_spec, bookkeeper, lifecycle)
        ready._fail_after = time_monotonic()

        assert ready() is False
        bookkeeper.success.assert_not_called()
        bookkeeper.failed.assert_called_with(app_spec)
        lifecycle.success.assert_not_called()
        lifecycle.failed.assert_called_with(app_name=app_spec.name, namespace=app_spec.namespace,
                                            deployment_id=app_spec.deployment_id, repository=repository)
Пример #8
0
              'http': {
                  'paths': [{
                      'path': '/',
                      'backend': {
                          'serviceName': 'testapp',
                          'servicePort': 80,
                      }
                  }]
              }
          }])),
 ("custom_labels_and_annotations",
  app_spec(
      labels=LabelAndAnnotationSpec(deployment={},
                                    horizontal_pod_autoscaler={},
                                    ingress={
                                        "ingress_deployer": "pass through",
                                        "custom": "label"
                                    },
                                    service={},
                                    pod={}),
      annotations=LabelAndAnnotationSpec(deployment={},
                                         horizontal_pod_autoscaler={},
                                         ingress={"custom": "annotation"},
                                         service={},
                                         pod={})),
  ingress(metadata=pytest.helpers.create_metadata(
      'testapp',
      external=False,
      labels={
          "ingress_deployer": "pass through",
          "custom": "label"
      },