Copilot commented on code in PR #11091:
URL: https://github.com/apache/gravitino/pull/11091#discussion_r3321800805


##########
dev/charts/gravitino/tests/ingress_test.yaml:
##########
@@ -0,0 +1,84 @@
+#
+# 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.
+#
+
+suite: test gravitino ingress
+templates:
+  - ingress.yaml
+tests:
+  - it: does not render ingress by default
+    asserts:
+      - hasDocuments:
+          count: 0
+
+  - it: renders networking v1 ingress for supported Kubernetes versions
+    release:
+      name: gravitino
+    capabilities:
+      majorVersion: 1
+      minorVersion: 29
+    set:
+      ingress:
+        enabled: true
+        className: nginx
+        annotations:
+          nginx.ingress.kubernetes.io/proxy-read-timeout: "3600"
+        hosts:
+          - host: gravitino.example.com
+            paths:
+              - path: /api
+                pathType: Prefix
+        tls:
+          - secretName: gravitino-tls
+            hosts:
+              - gravitino.example.com
+    asserts:
+      - isAPIVersion:
+          of: networking.k8s.io/v1
+      - isKind:
+          of: Ingress
+      - equal:
+          path: metadata.name
+          value: gravitino-gravitino-helm
+      - equal:
+          path: 
metadata.annotations["nginx.ingress.kubernetes.io/proxy-read-timeout"]
+          value: "3600"
+      - equal:
+          path: spec.ingressClassName
+          value: nginx
+      - equal:
+          path: spec.rules[0].host
+          value: gravitino.example.com
+      - equal:
+          path: spec.rules[0].http.paths[0].path
+          value: /api
+      - equal:
+          path: spec.rules[0].http.paths[0].pathType
+          value: Prefix
+      - equal:
+          path: spec.rules[0].http.paths[0].backend.service.name
+          value: gravitino-gravitino-helm

Review Comment:
   This assertion locks in an ingress backend service name that does not match 
the Service rendered by this chart: `service.yaml` sets `metadata.name` from 
`.Values.service.name` (default `gravitino`), while this test expects the 
deployment fullname. With default values, an enabled ingress would route to a 
non-existent Service. Please either update the ingress template to target the 
rendered service name or change the test to assert the actual Service name.



##########
dev/charts/gravitino/templates/_helpers.tpl:
##########
@@ -66,19 +66,41 @@ Define the gravitino.namespace
     {{- .Release.Namespace -}}
 {{- end -}}
 
+{{/*
+Return an image reference for the provided image root and global values.
+*/}}
+{{- define "gravitino.imageReference" -}}
+{{- $registry := coalesce .global.imageRegistry .imageRoot.registry -}}
+{{- $repository := required "image repository is required" 
.imageRoot.repository -}}
+{{- if .imageRoot.digest -}}
+{{- if $registry -}}
+{{- printf "%s/%s@%s" $registry $repository .imageRoot.digest -}}
+{{- else -}}
+{{- printf "%s@%s" $repository .imageRoot.digest -}}
+{{- end -}}
+{{- else -}}
+{{- $tag := required "image tag is required" .imageRoot.tag -}}
+{{- if $registry -}}

Review Comment:
   The new image helper adds untested rendering branches for digest-based 
images and global registry overrides, while the added deployment tests only 
cover the default tag-based Gravitino image. Please add Helm unit coverage for 
these helper paths so future changes do not regress image references rendered 
with `image.digest` or `global.imageRegistry`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to