Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions e2e/server_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package e2e

import (
"bytes"
"context"
"crypto/ecdsa"
"crypto/elliptic"
Expand All @@ -32,6 +33,8 @@ import (
"testing"
"text/template"
"time"

"github.com/labstack/onebox/internal/app"
)

type server struct {
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions e2e/testdata/postgres/ob.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -80,7 +80,7 @@ spec:
persistence: {mode: Durable}
backup:
target: offsite
recoveryKind: pitr
recoveryKind: Pitr
maxDataLoss: 15m
schedule: {cron: "0 2 * * *", timezone: UTC}
backupTargets:
Expand All @@ -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.
Expand Down