Files
seaweedfs/seaweed-block/scripts/basic_app_pvc_test.go
T
Ping QiuandClaude Opus 5.5 a5686e7fa7 Sync seaweed-block v1.1.1 into seaweed-block/ (#13411)
Brings seaweed-block main (v1.1.1 plus the docs and a test fix after it)
into seaweed-block/ as one commit. Only files under seaweed-block/ change,
and the subtree equals seaweed-block main exactly. The module's full
history stays in the seaweed-block repository.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 19:04:53 -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)
}
}
}