Files
seaweedfs/seaweed-block/scripts/basic_app_pvc_test.go
T
pingqiu-cpu ed37bff915 docs(k8s): quick start helper TLS, own PVC on the chart class, per-node cleanup (#1046)
Merge note (pull_request_target spec-trace workflow has a startup_failure on every branch since 2026-12-02 22:45Z, so its checks run locally):
- Test run 47286735263 succeeded (go test (linux), process-level tests (real binaries)) on head 8c9f7025 against main 8d0d03e5, the current main head.
- spec-trace-check.sh and public-text-check.sh, run with the main branch's scripts against this head and body: both exit 0.
2026-12-03 23:28:16 -08:00

48 lines
1.7 KiB
Go

package scripts_test
import (
"os"
"path/filepath"
"testing"
"gopkg.in/yaml.v3"
)
// The quick start's own-PVC example mounts on an install with several nodes:
// its PVC uses the StorageClass the chart installs, which carries the CHAP
// node-stage Secret whenever CHAP is on (chap.enabled with
// storageClass.nodeStageSecret.enabled, the default), and the example writer
// and reader pods claim that PVC.
func TestOwnPVCExampleUsesTheChartsStorageClass(t *testing.T) {
root := repoRoot(t)
read := func(p ...string) map[string]any {
t.Helper()
b, err := os.ReadFile(filepath.Join(append([]string{root}, p...)...))
if err != nil {
t.Fatal(err)
}
doc := map[string]any{}
if err := yaml.Unmarshal(b, &doc); err != nil {
t.Fatal(err)
}
return doc
}
pvc := read("examples", "kubernetes", "basic-app", "pvc.yaml")
values := read("charts", "seaweed-block", "values.yaml")
sc := values["storageClass"].(map[string]any)
if got := pvc["spec"].(map[string]any)["storageClassName"]; got != sc["name"] {
t.Fatalf("pvc.yaml storageClassName %v, want the chart's StorageClass %v", got, sc["name"])
}
if sc["nodeStageSecret"].(map[string]any)["enabled"] != true {
t.Fatal("the chart's StorageClass does not carry the node-stage Secret by default")
}
name := pvc["metadata"].(map[string]any)["name"]
for _, pod := range []string{"writer-pod.yaml", "reader-pod.yaml"} {
spec := read("examples", "kubernetes", "basic-app", pod)["spec"].(map[string]any)
claim := spec["volumes"].([]any)[0].(map[string]any)["persistentVolumeClaim"].(map[string]any)["claimName"]
if claim != name {
t.Errorf("%s claims %v, want the example PVC %v", pod, claim, name)
}
}
}