From fe73b0970992fa22a2ca05bac20f2456731f74e0 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Sun, 20 Sep 2026 19:14:51 -0700 Subject: [PATCH] fix(e2e): validate rendered server fixture --- e2e/server_harness_test.go | 20 ++++++++++++++++++++ e2e/testdata/postgres/ob.yml.tmpl | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/e2e/server_harness_test.go b/e2e/server_harness_test.go index 11f406ba..6c42def6 100644 --- a/e2e/server_harness_test.go +++ b/e2e/server_harness_test.go @@ -13,6 +13,7 @@ package e2e import ( + "bytes" "context" "crypto/ecdsa" "crypto/elliptic" @@ -32,6 +33,8 @@ import ( "testing" "text/template" "time" + + "github.com/labstack/onebox/internal/app" ) type server struct { @@ -173,6 +176,23 @@ func repoRoot(t *testing.T) string { return root } +func TestPostgresServerFixtureRendersValidApplication(t *testing.T) { + tmpl, err := template.ParseFiles(filepath.Join("testdata", "postgres", "ob.yml.tmpl")) + if err != nil { + t.Fatal(err) + } + var rendered bytes.Buffer + data := struct{ Server, Endpoint, Version string }{ + Server: "root@127.0.0.1:2222", Endpoint: "https://backup.example.net:9000", Version: "v1", + } + if err := tmpl.Execute(&rendered, data); err != nil { + t.Fatal(err) + } + if _, err := app.LoadBytes(rendered.Bytes(), filepath.Join(t.TempDir(), "ob.yml")); err != nil { + t.Fatalf("rendered server fixture is not a valid Application: %v\n%s", err, rendered.String()) + } +} + // project renders the fixture against this server and returns its directory. // // The version is what the workload serves, so a second render into the same diff --git a/e2e/testdata/postgres/ob.yml.tmpl b/e2e/testdata/postgres/ob.yml.tmpl index 735aa6ac..9d75580a 100644 --- a/e2e/testdata/postgres/ob.yml.tmpl +++ b/e2e/testdata/postgres/ob.yml.tmpl @@ -5,7 +5,7 @@ metadata: spec: environments: production: - server: {? {.Server: ''} : ''} + server: "{{ .Server }}" # A workload is required, and this one exists only to satisfy that: the suite # is about the database beside it. Kept to a sleeping busybox so the deploy # costs a pull of a few megabytes rather than a real application image. @@ -80,7 +80,7 @@ spec: persistence: {mode: Durable} backup: target: offsite - recoveryKind: pitr + recoveryKind: Pitr maxDataLoss: 15m schedule: {cron: "0 2 * * *", timezone: UTC} backupTargets: @@ -90,14 +90,14 @@ spec: # guest. That is the whole point: nothing about this endpoint is publicly # trusted, so it can only verify if ob carries the host's trust store into # the container the way it carries the binary. - endpoint: {? {.Endpoint: ''} : ''} + endpoint: "{{ .Endpoint }}" bucket: observer-backups failureDomain: {identity: e2e/guest} credentials: file: secrets/backup.env accessKeyEntry: BACKUP_ACCESS_KEY_ID secretKeyEntry: BACKUP_SECRET_ACCESS_KEY - encryption: {pitr: client-side} + encryption: {pitr: ClientSide} notifications: # The server test starts a one-shot receiver before inducing a scheduled-job # timeout. Because the timer fires on the host, localhost is the guest itself.