-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathtest_v1_config.sh
More file actions
executable file
·135 lines (117 loc) · 4.89 KB
/
Copy pathtest_v1_config.sh
File metadata and controls
executable file
·135 lines (117 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
set -euo pipefail
CHART_DIR="$(cd "$(dirname "$0")/../charts/chromadb-chart" && pwd)"
PASS=0
FAIL=0
assert_config_key() {
local desc="$1" yaml="$2" key="$3" expected="$4"
actual=$(echo "$yaml" | yq eval ".$key" -)
if [ "$actual" = "$expected" ]; then
echo " PASS: $desc"
PASS=$((PASS+1))
else
echo " FAIL: $desc (expected '$expected', got '$actual')"
FAIL=$((FAIL+1))
fi
}
assert_config_key_missing() {
local desc="$1" yaml="$2" key="$3"
actual=$(echo "$yaml" | yq eval ".$key" -)
if [ "$actual" = "null" ]; then
echo " PASS: $desc"
PASS=$((PASS+1))
else
echo " FAIL: $desc (expected key '$key' to be absent, got '$actual')"
FAIL=$((FAIL+1))
fi
}
get_v1_config() {
local output
output=$(helm template test "$CHART_DIR" "$@" 2>&1) || {
echo "TEMPLATE_ERROR: $output" >&2
return 1
}
echo "$output" | yq eval 'select(.metadata.name == "v1-config") | .data["config.yaml"]' -
}
assert_template_fails() {
local desc="$1"; shift
local output
if output=$(helm template test "$CHART_DIR" "$@" 2>&1); then
echo " FAIL: $desc (expected template to fail, but it succeeded)"
FAIL=$((FAIL+1))
else
echo " PASS: $desc"
PASS=$((PASS+1))
fi
}
# --- Test suite ---
echo "=== v1-config template tests ==="
echo ""
echo "1. Default values"
config=$(get_v1_config)
assert_config_key "port defaults to 8000" "$config" "port" "8000"
assert_config_key "listen_address defaults to 0.0.0.0" "$config" "listen_address" "0.0.0.0"
assert_config_key "max_payload_size_bytes defaults to 41943040" "$config" "max_payload_size_bytes" "41943040"
assert_config_key "persist_path defaults to /data" "$config" "persist_path" "/data"
assert_config_key "allow_reset defaults to false" "$config" "allow_reset" "false"
assert_config_key_missing "cors_allow_origins absent when empty" "$config" "cors_allow_origins"
assert_config_key_missing "open_telemetry absent when disabled" "$config" "open_telemetry"
echo ""
echo "2. CORS wildcard (should work)"
config=$(get_v1_config --set 'chromadb.corsAllowOrigins={*}')
assert_config_key "cors_allow_origins contains wildcard" "$config" "cors_allow_origins[0]" "*"
echo ""
echo "3. CORS multiple origins"
config=$(get_v1_config --set 'chromadb.corsAllowOrigins={https://a.com,https://b.com}')
assert_config_key "first origin" "$config" "cors_allow_origins[0]" "https://a.com"
assert_config_key "second origin" "$config" "cors_allow_origins[1]" "https://b.com"
echo ""
echo "4. OpenTelemetry enabled"
config=$(get_v1_config \
--set 'chromadb.telemetry.enabled=true' \
--set 'chromadb.telemetry.endpoint=http://otel:4317' \
--set 'chromadb.telemetry.serviceName=my-chroma')
assert_config_key "otel endpoint" "$config" "open_telemetry.endpoint" "http://otel:4317"
assert_config_key "otel service_name" "$config" "open_telemetry.service_name" "my-chroma"
echo ""
echo "5. Custom server settings"
config=$(get_v1_config \
--set 'chromadb.serverHttpPort=9000' \
--set 'chromadb.serverHost=127.0.0.1' \
--set 'chromadb.allowReset=true' \
--set 'chromadb.persistDirectory=/mnt/data' \
--set 'chromadb.maxPayloadSizeBytes=52428800')
assert_config_key "custom port" "$config" "port" "9000"
assert_config_key "custom listen_address" "$config" "listen_address" "127.0.0.1"
assert_config_key "allow_reset true" "$config" "allow_reset" "true"
assert_config_key "custom persist_path" "$config" "persist_path" "/mnt/data"
assert_config_key "custom max_payload_size_bytes" "$config" "max_payload_size_bytes" "52428800"
echo ""
echo "6. extraConfig merge"
config=$(get_v1_config \
--set 'chromadb.extraConfig.circuit_breaker.requests=500' \
--set 'chromadb.extraConfig.sqlite_filename=custom.db')
assert_config_key "circuit_breaker.requests from extraConfig" "$config" "circuit_breaker.requests" "500"
assert_config_key "sqlite_filename from extraConfig" "$config" "sqlite_filename" "custom.db"
assert_config_key "port still present after merge" "$config" "port" "8000"
echo ""
echo "7. extraConfig override of port fails"
assert_template_fails "extraConfig.port override rejected" \
--set 'chromadb.extraConfig.port=9999'
echo ""
echo "8. extraConfig override of listen_address fails"
assert_template_fails "extraConfig.listen_address override rejected" \
--set 'chromadb.extraConfig.listen_address=127.0.0.1'
echo ""
echo "9. telemetry enabled without endpoint fails"
assert_template_fails "telemetry.enabled without endpoint rejected" \
--set 'chromadb.telemetry.enabled=true'
echo ""
# v1-config is only mounted for >= 1.0.0; this test validates template
# rendering only, not runtime CORS behavior for pre-1.0 versions.
echo "10. CORS wildcard on < 1.0.0 (ConfigMap renders)"
config=$(get_v1_config --set 'chromadb.corsAllowOrigins={*}' --set 'chromadb.apiVersion=0.6.3')
assert_config_key "cors_allow_origins wildcard for pre-1.0" "$config" "cors_allow_origins[0]" "*"
echo ""
echo "--- Results: $PASS passed, $FAIL failed ---"
[ "$FAIL" -eq 0 ] || exit 1