github.com/weaviate/weaviate@v1.24.6/test/helper/backups.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package helper 13 14 import ( 15 "testing" 16 17 "github.com/weaviate/weaviate/client/backups" 18 "github.com/weaviate/weaviate/entities/models" 19 "github.com/weaviate/weaviate/usecases/backup" 20 ) 21 22 func DefaultBackupConfig() *models.BackupConfig { 23 return &models.BackupConfig{ 24 CompressionLevel: models.BackupConfigCompressionLevelDefaultCompression, 25 CPUPercentage: backup.DefaultCPUPercentage, 26 ChunkSize: 128, 27 } 28 } 29 30 func DefaultRestoreConfig() *models.RestoreConfig { 31 return &models.RestoreConfig{ 32 CPUPercentage: backup.DefaultCPUPercentage, 33 } 34 } 35 36 func CreateBackup(t *testing.T, cfg *models.BackupConfig, className, backend, backupID string) (*backups.BackupsCreateOK, error) { 37 params := backups.NewBackupsCreateParams(). 38 WithBackend(backend). 39 WithBody(&models.BackupCreateRequest{ 40 ID: backupID, 41 Include: []string{className}, 42 Config: cfg, 43 }) 44 return Client(t).Backups.BackupsCreate(params, nil) 45 } 46 47 func CreateBackupStatus(t *testing.T, backend, backupID string) (*backups.BackupsCreateStatusOK, error) { 48 params := backups.NewBackupsCreateStatusParams(). 49 WithBackend(backend). 50 WithID(backupID) 51 return Client(t).Backups.BackupsCreateStatus(params, nil) 52 } 53 54 func RestoreBackup(t *testing.T, cfg *models.RestoreConfig, className, backend, backupID string, nodeMapping map[string]string) (*backups.BackupsRestoreOK, error) { 55 params := backups.NewBackupsRestoreParams(). 56 WithBackend(backend). 57 WithID(backupID). 58 WithBody(&models.BackupRestoreRequest{ 59 Include: []string{className}, 60 NodeMapping: nodeMapping, 61 Config: cfg, 62 }) 63 return Client(t).Backups.BackupsRestore(params, nil) 64 } 65 66 func RestoreBackupStatus(t *testing.T, backend, backupID string) (*backups.BackupsRestoreStatusOK, error) { 67 params := backups.NewBackupsRestoreStatusParams(). 68 WithBackend(backend). 69 WithID(backupID) 70 return Client(t).Backups.BackupsRestoreStatus(params, nil) 71 }