Skip to content

Commit dd10fda

Browse files
committed
fix(helm): select the graph checked by test
- expose an explicit graph alias with existing defaults - retain authenticated per-Pod checks and retry limits - validate alias input and cover missing graph failures - explain target graph creation and binding requirements
1 parent bf33ef6 commit dd10fda

6 files changed

Lines changed: 86 additions & 7 deletions

File tree

‎.github/workflows/helm-chart-ci.yml‎

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ jobs:
163163
graph_space_max=$(printf 'a%.0s' {1..48})
164164
helm template ci helm/hugegraph --set-string "server.graphSpace=${graph_space_max}" > /dev/null
165165
must_fail --set-string "server.graphSpace=${graph_space_max}a"
166+
# The hook queries an explicit, fully qualified existing graph binding.
167+
must_fail --set-string server.testGraphAlias=
168+
must_fail --set-string server.testGraphAlias=team_a
169+
must_fail --set-string server.testGraphAlias=team_a-demo-name
170+
must_fail --set-string "server.testGraphAlias=team_a-demo'"
171+
graph_name_max=$(printf 'g%.0s' {1..48})
172+
helm template ci helm/hugegraph \
173+
--set-string "server.testGraphAlias=${graph_space_max}-${graph_name_max}" > /dev/null
174+
must_fail --set-string "server.testGraphAlias=${graph_space_max}a-demo"
175+
must_fail --set-string "server.testGraphAlias=team_a-${graph_name_max}g"
166176
must_fail --set pd.replicas=100
167177
must_fail --set pd.pdb.minAvailable=3
168178
must_fail --set server.hpa.enabled=true
@@ -345,7 +355,7 @@ jobs:
345355
printf '#!/bin/sh\nfor ip in ${STUB_IPS}; do printf "%%s STREAM host\\n" "$ip"; done\n' > /tmp/stub/getent
346356
chmod +x /tmp/stub/getent
347357
cat > /tmp/fixture.py <<'PY'
348-
import http.server, os, sys, threading, time
358+
import http.server, json, os, sys, threading, time
349359
calls = {}
350360
class H(http.server.BaseHTTPRequestHandler):
351361
def _send(self, code, body):
@@ -357,7 +367,9 @@ jobs:
357367
def do_GET(self):
358368
self._send(200, b'{"versions":{}}')
359369
def do_POST(self):
360-
self.rfile.read(int(self.headers.get('Content-Length', 0)))
370+
body = json.loads(self.rfile.read(int(self.headers.get('Content-Length', 0))))
371+
expected_alias = ('team_a-demo' if os.path.exists('/tmp/selected-graph')
372+
else 'DEFAULT-hugegraph')
361373
ip = self.server.server_address[0]
362374
# broken-<ip>: every Gremlin call fails. flip-odd-<ip> /
363375
# flip-even-<ip>: the odd or even calls fail, counted from
@@ -367,6 +379,7 @@ jobs:
367379
even = os.path.exists('/tmp/flip-even-' + ip)
368380
n = calls[ip] = (calls.get(ip, 0) + 1) if (odd or even) else 0
369381
broken = (os.path.exists('/tmp/broken-' + ip)
382+
or body.get('aliases', {}).get('graph') != expected_alias
370383
or (odd and n % 2 == 1)
371384
or (even and n % 2 == 0))
372385
if broken:
@@ -384,7 +397,7 @@ jobs:
384397
sleep 1
385398
run_hook() {
386399
PATH="/tmp/stub:${PATH}" PASSWORD=ci-password HG_TEST_DEADLINE_S=8 \
387-
STUB_IPS="$1" sh /tmp/hook.sh
400+
STUB_IPS="$1" sh "${2:-/tmp/hook.sh}"
388401
}
389402
# Healthy: three Pods, all Gremlin-bound.
390403
run_hook "127.0.0.1 127.0.0.2 127.0.0.3"
@@ -419,6 +432,26 @@ jobs:
419432
exit 1
420433
fi
421434
run_hook "127.0.0.1 127.0.0.2 127.0.0.3 ::1 ::2 ::3"
435+
# A non-default graph space must query the explicitly selected graph.
436+
# A missing alias still fails rather than weakening the per-Pod sweep.
437+
touch /tmp/selected-graph
438+
for alias in team_a-demo team_a-missing; do
439+
helm template ci helm/hugegraph -s templates/tests/test-connection.yaml \
440+
--set-string server.graphSpace=team_a \
441+
--set-string "server.testGraphAlias=${alias}" > "/tmp/hook-${alias}.yaml"
442+
done
443+
python3 - <<'PY'
444+
import yaml
445+
for alias in ('team_a-demo', 'team_a-missing'):
446+
d = yaml.safe_load(open('/tmp/hook-' + alias + '.yaml'))
447+
open('/tmp/hook-' + alias + '.sh', 'w').write(d['spec']['containers'][0]['command'][2])
448+
PY
449+
run_hook "127.0.0.1 127.0.0.2 127.0.0.3" /tmp/hook-team_a-demo.sh
450+
if run_hook "127.0.0.1 127.0.0.2 127.0.0.3" /tmp/hook-team_a-missing.sh; then
451+
echo "expected the hook to fail on a missing selected graph" >&2
452+
exit 1
453+
fi
454+
rm /tmp/selected-graph
422455
# The auth-off render must carry no credentials.
423456
if helm template ci helm/hugegraph -s templates/tests/test-connection.yaml \
424457
--set server.auth.enabled=false | grep -q 'Authorization'; then

‎helm/hugegraph/README.md‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ or recovery. Hubble health probes and the Server hook do not verify UI access.
202202

203203
Besides the Service checks, the test resolves a headless Server Service and
204204
requires an authenticated, graph-bound Gremlin answer from every Server Pod
205-
(at least the replica floor), because a Server that started during a PD roll
205+
(at least the replica floor). `server.testGraphAlias` selects that binding and
206+
defaults to `DEFAULT-hugegraph`. Set it to an existing target graph's full alias,
207+
such as `team_a-demo`, to check that graph instead. The hook does not create a
208+
graph or infer an alias from `server.graphSpace`. A Server that started during a PD roll
206209
can pass readiness and serve REST while every Gremlin call on it fails (see
207210
Troubleshooting, "Could not rebind"). Transient failures are retried for
208211
150 seconds before the test fails and names the failing Pod IPs. Large HPA
@@ -617,6 +620,7 @@ default values.
617620
| `server.probes.startup.failureThreshold` | Raised automatically so the guaranteed budget, `(failureThreshold - 1) * periodSeconds` (the first probe can fail immediately), is at least 450s | `91` |
618621
| `server.probes.startup.periodSeconds` | Startup probe interval | `5` |
619622
| `server.probes.*` | Same optional probe keys as PD | see `values.yaml` |
623+
| `server.testGraphAlias` | Existing Gremlin graph binding checked on every Server Pod by `helm test` | `DEFAULT-hugegraph` |
620624

621625
When `server.hpa.enabled` is `true` the Deployment omits `spec.replicas`, so a
622626
Helm upgrade does not overwrite the autoscaler's live replica count. Enabling
@@ -653,6 +657,13 @@ existing graphs or change `server.path_graphspace`. Use explicit
653657
Hubble. Rendering and entrypoint checks verify configuration only; non-default
654658
PD discovery, authentication and isolation require a running Linux cluster.
655659

660+
To validate a graph in the selected space, create the graph there and set
661+
`server.testGraphAlias` to its actual Gremlin binding, for example
662+
`--set-string server.testGraphAlias=team_a-demo`. Creating `team_a` does not
663+
create a `hugegraph` graph. The default hook checks the local `DEFAULT-hugegraph`
664+
binding, which may exist independently of the Server's assigned PD graph space;
665+
its success alone does not validate graphs in `team_a`.
666+
656667
### Reaching Hubble (pick one path)
657668

658669
Most people should stop at **1**. Use **2** only if Hubble must run outside
@@ -1092,8 +1103,13 @@ curl -s --compressed -u "admin:${PASSWORD}" -H 'Content-Type: application/json'
10921103
-d '{"gremlin":"graph.traversal().V().limit(1).count()","aliases":{"graph":"DEFAULT-hugegraph"}}'
10931104
```
10941105

1095-
A healthy Pod answers with `result.data`; delete a Pod that answers
1096-
`Could not rebind`, and its replacement binds normally once PD is stable.
1106+
A healthy Pod answers with `result.data`. This example uses the default
1107+
`server.testGraphAlias`; replace `DEFAULT-hugegraph` with your configured alias.
1108+
If a Pod answers `Could not rebind`, first confirm that the requested graph
1109+
exists and the alias matches its binding. For a missing binding caused by the
1110+
PD startup failure above, delete the affected Pod once PD is stable so its
1111+
replacement can bind the graph. Restarting a Pod cannot create a missing graph
1112+
or correct the requested alias.
10971113
`helm test` runs this same graph-bound query against every Server Pod
10981114
through the headless Service, so a stuck replica now fails the release
10991115
check instead of hiding behind the load balancer. The measurements behind

‎helm/hugegraph/templates/tests/test-connection.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ spec:
7474
PORT="{{ .Values.server.port }}"
7575
FLOOR="{{ include "hugegraph.server.replicaFloor" . }}"
7676
DEADLINE_S="${HG_TEST_DEADLINE_S:-150}"
77-
BODY='{"gremlin":"graph.traversal().V().limit(1).count()","aliases":{"graph":"DEFAULT-hugegraph"}}'
77+
BODY={{ dict "gremlin" "graph.traversal().V().limit(1).count()" "aliases" (dict "graph" (.Values.server.testGraphAlias | default "DEFAULT-hugegraph")) | toJson | squote }}
7878
{{- if .Values.server.auth.enabled }}
7979
AUTH_HEADER=$(printf 'admin:%s' "${PASSWORD}" | base64 | tr -d '\r\n')
8080
request() {

‎helm/hugegraph/tests/test_hook_gremlin_test.yaml‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ tests:
6060
path: spec.containers[0].command[2]
6161
pattern: "FLOOR=\"3\""
6262

63+
- it: checks the explicitly selected graph in a non-default graph space
64+
template: tests/test-connection.yaml
65+
set:
66+
server.graphSpace: team_a
67+
server.testGraphAlias: team_a-demo
68+
asserts:
69+
- matchRegex:
70+
path: spec.containers[0].command[2]
71+
pattern: '"graph":"team_a-demo"'
72+
- notMatchRegex:
73+
path: spec.containers[0].command[2]
74+
pattern: "DEFAULT-hugegraph"
75+
76+
- it: preserves the default binding when graphSpace changes without a selected graph
77+
template: tests/test-connection.yaml
78+
set:
79+
server.graphSpace: team_a
80+
asserts:
81+
- matchRegex:
82+
path: spec.containers[0].command[2]
83+
pattern: '"graph":"DEFAULT-hugegraph"'
84+
6385
- it: floors the per-Pod count at the HPA minimum when HPA is enabled
6486
template: tests/test-connection.yaml
6587
set:

‎helm/hugegraph/values.schema.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,11 @@
774774
"pattern": "^(DEFAULT|[a-z][a-z0-9_]{0,47})$",
775775
"description": "Existing PD graph space: DEFAULT or up to 48 lowercase letters, digits and underscores, starting with a letter. DEFAULT preserves the image config."
776776
},
777+
"testGraphAlias": {
778+
"type": "string",
779+
"pattern": "^(DEFAULT|[a-z][a-z0-9_]{0,47})-[A-Za-z][A-Za-z0-9_]{0,47}$",
780+
"description": "Existing Gremlin graph binding checked by helm test, as <graph-space>-<graph-name>. Choose the target graph explicitly; server.graphSpace does not create or infer this binding."
781+
},
777782
"replicas": {
778783
"type": "integer",
779784
"minimum": 1

‎helm/hugegraph/values.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ server:
336336
minAvailable: 2
337337
# Image used by the Helm test hook.
338338
waitImage: curlimages/curl:8.5.0
339+
# Existing Gremlin graph binding checked on every Server Pod. Select the
340+
# target graph explicitly; graphSpace does not create or infer this binding.
341+
testGraphAlias: DEFAULT-hugegraph
339342
# Resources for the Helm test hook container. Bounded by default so the hook
340343
# cannot run unlimited on a restricted or quota-managed namespace.
341344
testResources:

0 commit comments

Comments
 (0)