mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
Seven guides in docs/ were written next to the code and left in the source tree, where no operator looks. The website carries them now, so a second copy here only lets the two drift again: the Backup Classes page had already fallen behind its original. docs/release.md, docs/deprecating-applications.md and the two SeaweedFS runbooks in docs/operations stay. A migration, a bats suite, a workflow or AGENTS.md reads each of them by path, which is the test for keeping a document in this repository. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
484 lines
12 KiB
YAML
484 lines
12 KiB
YAML
suite: restore tests
|
|
|
|
templates:
|
|
- templates/restore.yaml
|
|
|
|
tests:
|
|
#####################
|
|
# Rendering #
|
|
#####################
|
|
|
|
- it: does not render when bootstrap is disabled
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: false
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 0
|
|
|
|
- it: renders PerconaServerMongoDBRestore CR when enabled
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "my-backup-2025-01-07"
|
|
backup:
|
|
destinationPath: "s3://bucket/backups/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- isKind:
|
|
of: PerconaServerMongoDBRestore
|
|
|
|
#####################
|
|
# Validation #
|
|
#####################
|
|
|
|
- it: fails when backupName is missing
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: ""
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "bootstrap.backupName is required when bootstrap.enabled is true"
|
|
|
|
- it: fails when bootstrap and useSystemBucket are both enabled
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "my-backup"
|
|
backup:
|
|
useSystemBucket: true
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "mongodb: bootstrap.enabled=true is incompatible with backup.useSystemBucket=true. bootstrap.enabled is not reset after a bootstrap restore completes, so set bootstrap.enabled=false before opting in; to restore from the system bucket use a backups.cozystack.io/RestoreJob against the cozy-default BackupClass instead. See https://cozystack.io/docs/v1/operations/services/backup-classes/."
|
|
|
|
- it: fails when destinationPath is missing
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "my-backup"
|
|
backup:
|
|
destinationPath: ""
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "backup.destinationPath is required when bootstrap.enabled is true"
|
|
|
|
- it: fails when endpointURL is missing
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "my-backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: ""
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "backup.endpointURL is required when bootstrap.enabled is true"
|
|
|
|
#####################
|
|
# CR metadata #
|
|
#####################
|
|
|
|
- it: uses correct restore CR name
|
|
release:
|
|
name: mydb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup-2025"
|
|
backup:
|
|
destinationPath: "s3://bucket/backups/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: metadata.name
|
|
value: mydb-restore
|
|
|
|
- it: references correct cluster name
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup-2025"
|
|
backup:
|
|
destinationPath: "s3://bucket/backups/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.clusterName
|
|
value: test-mongodb
|
|
|
|
#####################
|
|
# Backup source #
|
|
#####################
|
|
|
|
- it: sets backupSource type to logical
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup-2025"
|
|
backup:
|
|
destinationPath: "s3://bucket/backups/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.type
|
|
value: logical
|
|
|
|
- it: constructs destination from destinationPath and backupName
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "daily-backup-2025-01-07"
|
|
backup:
|
|
destinationPath: "s3://mybucket/mongodb/prod/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.destination
|
|
value: s3://mybucket/mongodb/prod/daily-backup-2025-01-07
|
|
|
|
- it: trims trailing slash from destinationPath
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.destination
|
|
value: s3://bucket/path/backup
|
|
|
|
#####################
|
|
# S3 configuration #
|
|
#####################
|
|
|
|
- it: references s3-creds secret
|
|
release:
|
|
name: mydb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.credentialsSecret
|
|
value: mydb-s3-creds
|
|
|
|
- it: sets S3 endpoint URL
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "https://s3.amazonaws.com"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.endpointUrl
|
|
value: "https://s3.amazonaws.com"
|
|
|
|
- it: disables insecureSkipTLSVerify
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.insecureSkipTLSVerify
|
|
value: false
|
|
|
|
- it: enables forcePathStyle
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.forcePathStyle
|
|
value: true
|
|
|
|
- it: sets bucket and prefix from destinationPath
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://mybucket/mongodb/prod/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.bucket
|
|
value: mybucket
|
|
- equal:
|
|
path: spec.backupSource.s3.prefix
|
|
value: mongodb/prod/
|
|
|
|
- it: keeps a prefix without a trailing slash as given
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://mybucket/mongodb/prod"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.prefix
|
|
value: mongodb/prod
|
|
- equal:
|
|
path: spec.backupSource.destination
|
|
value: s3://mybucket/mongodb/prod/backup
|
|
|
|
- it: sets an empty prefix when destinationPath is the bucket root
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://mybucket"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.bucket
|
|
value: mybucket
|
|
- equal:
|
|
path: spec.backupSource.s3.prefix
|
|
value: ""
|
|
- equal:
|
|
path: spec.backupSource.destination
|
|
value: s3://mybucket/backup
|
|
|
|
- it: keeps a numeric bucket and prefix as strings
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://2024/10"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.backupSource.s3.bucket
|
|
value: "2024"
|
|
- equal:
|
|
path: spec.backupSource.s3.prefix
|
|
value: "10"
|
|
|
|
- it: fails when destinationPath names no bucket
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "backup.destinationPath must name a bucket (s3://bucket/path/) when bootstrap.enabled is true"
|
|
|
|
- it: does not check the bucket when bootstrap is disabled
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: false
|
|
backup:
|
|
destinationPath: "s3://"
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 0
|
|
|
|
#####################
|
|
# PITR #
|
|
#####################
|
|
|
|
- it: does not set pitr when recoveryTime not specified
|
|
documentSelector:
|
|
path: kind
|
|
value: PerconaServerMongoDBRestore
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- notExists:
|
|
path: spec.pitr
|
|
|
|
- it: configures PITR when recoveryTime is set
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "my-backup"
|
|
recoveryTime: "2025-01-07 14:30:00"
|
|
backup:
|
|
destinationPath: "s3://bucket/backups/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- equal:
|
|
path: spec.pitr.type
|
|
value: date
|
|
- equal:
|
|
path: spec.pitr.date
|
|
value: "2025-01-07 14:30:00"
|
|
|
|
#####################
|
|
# S3 credentials #
|
|
#####################
|
|
|
|
- it: fails when s3AccessKey is missing
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: ""
|
|
s3SecretKey: "secret"
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "backup.s3AccessKey is required when bootstrap.enabled is true"
|
|
|
|
- it: fails when s3SecretKey is missing
|
|
release:
|
|
name: test-mongodb
|
|
namespace: tenant-test
|
|
set:
|
|
bootstrap:
|
|
enabled: true
|
|
backupName: "backup"
|
|
backup:
|
|
destinationPath: "s3://bucket/path/"
|
|
endpointURL: "http://minio:9000"
|
|
s3AccessKey: "access"
|
|
s3SecretKey: ""
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: "backup.s3SecretKey is required when bootstrap.enabled is true"
|