jedcunningham commented on code in PR #38549:
URL: https://github.com/apache/airflow/pull/38549#discussion_r1631711428


##########
helm_tests/webserver/test_rpc_server.py:
##########
@@ -0,0 +1,923 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import jmespath
+import pytest
+
+from tests.charts.helm_template_generator import render_chart
+
+
+class TestRPCServerDeployment:
+    """Tests rpc-server deployment."""
+
+    def test_can_be_disabled(self):
+        """
+        RPC server should be able to be disabled if the users desires.
+
+        For example, user may be disabled when using rpc-server and having it 
deployed on another host.
+        """
+        docs = render_chart(
+            values={"rpcServer": {"enabled": False}},
+            show_only=["templates/rpc-server/rpc-server-deployment.yaml"],
+        )
+
+        assert 0 == len(docs)
+
+    def 
test_should_add_host_header_to_liveness_and_readiness_and_startup_probes(self):
+        docs = render_chart(
+            values={"rpcServer": {"baseUrl": 
"https://example.com:21222/mypath/path"}},
+            show_only=["templates/rpc-server/rpc-server-deployment.yaml"],
+        )
+
+        assert {"name": "Host", "value": "example.com"} in jmespath.search(
+            
"spec.template.spec.containers[0].livenessProbe.httpGet.httpHeaders", docs[0]
+        )
+        assert {"name": "Host", "value": "example.com"} in jmespath.search(
+            
"spec.template.spec.containers[0].readinessProbe.httpGet.httpHeaders", docs[0]
+        )
+        assert {"name": "Host", "value": "example.com"} in jmespath.search(
+            
"spec.template.spec.containers[0].startupProbe.httpGet.httpHeaders", docs[0]
+        )
+
+    def 
test_should_add_path_to_liveness_and_readiness_and_startup_probes(self):
+        docs = render_chart(
+            values={"rpcServer": {"baseUrl": 
"https://example.com:21222/mypath/path"}},
+            show_only=["templates/rpc-server/rpc-server-deployment.yaml"],
+        )
+
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].livenessProbe.httpGet.path", 
docs[0])
+            == "/mypath/path/internal_api/v1/health"
+        )
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].readinessProbe.httpGet.path", 
docs[0])
+            == "/mypath/path/internal_api/v1/health"
+        )
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].startupProbe.httpGet.path", 
docs[0])
+            == "/mypath/path/internal_api/v1/health"
+        )
+
+    @pytest.mark.parametrize(
+        "revision_history_limit, global_revision_history_limit",
+        [(8, 10), (10, 8), (8, None), (None, 10), (None, None)],
+    )
+    def test_revision_history_limit(self, revision_history_limit, 
global_revision_history_limit):
+        values = {"rpcServer": {}}
+        if revision_history_limit:
+            values["rpcServer"]["revisionHistoryLimit"] = 
revision_history_limit
+        if global_revision_history_limit:
+            values["revisionHistoryLimit"] = global_revision_history_limit
+        docs = render_chart(
+            values=values,
+            show_only=["templates/rpc-server/rpc-server-deployment.yaml"],
+        )
+        expected_result = revision_history_limit if revision_history_limit 
else global_revision_history_limit
+        assert jmespath.search("spec.revisionHistoryLimit", docs[0]) == 
expected_result
+
+    @pytest.mark.parametrize("values", [{"config": {"rpcServer": {"base_url": 
""}}}, {}])
+    def test_should_not_contain_host_header(self, values):
+        print(values)
+        docs = render_chart(values=values, 
show_only=["templates/rpc-server/rpc-server-deployment.yaml"])
+
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].livenessProbe.httpGet.httpHeaders",
 docs[0])
+            is None
+        )
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].readinessProbe.httpGet.httpHeaders",
 docs[0])
+            is None
+        )
+        assert (
+            
jmespath.search("spec.template.spec.containers[0].startupProbe.httpGet.httpHeaders",
 docs[0])
+            is None
+        )
+
+    def test_should_use_templated_base_url_for_probes(self):
+        docs = render_chart(
+            values={
+                "rpcServer": {
+                    "baseUrl": "https://{{ .Release.Name 
}}.com:21222/mypath/{{ .Release.Name }}/path"

Review Comment:
   Forgive me for not being up to speed on 44. If there isn't a config for it, 
how do the other components know where to send their requests?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to