Exemple #1
0
 def test_enrich_with_ingress_never(self, db: Session, client: TestClient):
     """
     Expect no ingress to be created automatically as the configuration templated ingress mode is "never"
     """
     function = self._generate_runtime("nuclio")
     function_name, project_name, config = compile_function_config(function)
     service_type = "DoesNotMatter"
     enrich_function_with_ingress(
         config, NuclioIngressAddTemplatedIngressModes.never, service_type)
     ingresses = resolve_function_ingresses(config["spec"])
     assert ingresses == []
Exemple #2
0
 def test_enrich_with_ingress_always(self, db: Session, client: TestClient):
     """
     Expect ingress template to be created as the configuration templated ingress mode is "always"
     """
     function = self._generate_runtime("nuclio")
     function_name, project_name, config = compile_function_config(function)
     service_type = "NodePort"
     enrich_function_with_ingress(
         config, NuclioIngressAddTemplatedIngressModes.always, service_type)
     ingresses = resolve_function_ingresses(config["spec"])
     assert ingresses[0]["hostTemplate"] != ""
Exemple #3
0
 def test_enrich_with_ingress_on_cluster_ip(self, db: Session, client: TestClient):
     """
     Expect ingress template to be created as the configuration templated ingress mode is "onClusterIP" while the
     function service type is ClusterIP
     """
     function = self._generate_runtime(self.runtime_kind)
     function_name, project_name, config = compile_function_config(function)
     service_type = "ClusterIP"
     enrich_function_with_ingress(
         config, NuclioIngressAddTemplatedIngressModes.on_cluster_ip, service_type,
     )
     ingresses = resolve_function_ingresses(config["spec"])
     assert ingresses[0]["hostTemplate"] != ""
Exemple #4
0
    def test_enrich_with_ingress_no_overriding(self, db: Session, client: TestClient):
        """
        Expect no ingress template to be created, thought its mode is "always",
        since the function already have a pre-configured ingress
        """
        function = self._generate_runtime(self.runtime_kind)

        # both ingress and node port
        ingress_host = "something.com"
        function.with_http(host=ingress_host, paths=["/"], port=30030)
        function_name, project_name, config = compile_function_config(function)
        service_type = "NodePort"
        enrich_function_with_ingress(
            config, NuclioIngressAddTemplatedIngressModes.always, service_type
        )
        ingresses = resolve_function_ingresses(config["spec"])
        assert len(ingresses) > 0, "Expected one ingress to be created"
        for ingress in ingresses:
            assert "hostTemplate" not in ingress, "No host template should be added"
            assert ingress["host"] == ingress_host