@@ -12,6 +12,7 @@ import (
12
12
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
13
13
14
14
apiv1 "github.com/EnterpriseDB/cloud-native-postgresql/api/v1"
15
+ "github.com/EnterpriseDB/cloud-native-postgresql/pkg/certs"
15
16
"github.com/EnterpriseDB/cloud-native-postgresql/tests"
16
17
"github.com/EnterpriseDB/cloud-native-postgresql/tests/utils"
17
18
@@ -84,13 +85,13 @@ var _ = Describe("Backup and restore", func() {
84
85
})
85
86
86
87
By ("setting up minio" , func () {
87
- InstallMinio (namespace )
88
+ InstallMinio (namespace , "/backup/minio/minio-deployment.yaml" )
88
89
})
89
90
90
91
// Create the minio client pod and wait for it to be ready.
91
92
// We'll use it to check if everything is archived correctly
92
93
By ("setting up minio client pod" , func () {
93
- InstallMinioClient (namespace )
94
+ InstallMinioClient (namespace , "/backup/minio/minio-client.yaml" )
94
95
})
95
96
96
97
// Create ConfigMap and secrets to verify metrics for target database after backup restore
@@ -168,13 +169,13 @@ var _ = Describe("Backup and restore", func() {
168
169
})
169
170
170
171
By ("setting up minio" , func () {
171
- InstallMinio (namespace )
172
+ InstallMinio (namespace , "/backup/minio/minio-deployment.yaml" )
172
173
})
173
174
174
175
// Create the minio client pod and wait for it to be ready.
175
176
// We'll use it to check if everything is archived correctly
176
177
By ("setting up minio client pod" , func () {
177
- InstallMinioClient (namespace )
178
+ InstallMinioClient (namespace , "/backup/minio/minio-client.yaml" )
178
179
})
179
180
180
181
AssertCreateCluster (namespace , clusterName , clusterWithMinioSampleFile , env )
@@ -207,13 +208,13 @@ var _ = Describe("Backup and restore", func() {
207
208
})
208
209
209
210
By ("setting up minio" , func () {
210
- InstallMinio (namespace )
211
+ InstallMinio (namespace , "/backup/minio/minio-deployment.yaml" )
211
212
})
212
213
213
214
// Create the minio client pod and wait for it to be ready.
214
215
// We'll use it to check if everything is archived correctly
215
216
By ("setting up minio client pod" , func () {
216
- InstallMinioClient (namespace )
217
+ InstallMinioClient (namespace , "/backup/minio/minio-client.yaml" )
217
218
})
218
219
219
220
AssertCreateCluster (namespace , clusterName , clusterWithMinioSampleFile , env )
@@ -246,6 +247,89 @@ var _ = Describe("Backup and restore", func() {
246
247
247
248
AssertClusterRestorePITR (namespace , restoredClusterName , tableName )
248
249
})
250
+
251
+ It ("backup and restore with endpoint ca and tls connection" , func () {
252
+ const (
253
+ clusterWithMinioSampleFile = fixturesDir + "/backup/minio-with-tls/cluster-with-backup-minio.yaml"
254
+ clusterRestoreSampleFile = fixturesDir + "/backup/minio-with-tls/cluster-from-restore.yaml"
255
+ caSecName = "minio-server-ca-secret"
256
+ tlsSecName = "minio-server-tls-secret"
257
+ )
258
+ namespace = "backup-minio-endpoint-ca"
259
+ clusterName , err := env .GetResourceNameFromYAML (clusterWithMinioSampleFile )
260
+ Expect (err ).ToNot (HaveOccurred ())
261
+ // create namespace
262
+ err = env .CreateNamespace (namespace )
263
+ Expect (err ).ToNot (HaveOccurred ())
264
+
265
+ // create CA certificates
266
+ _ , caPair := utils .CreateSecretCA (namespace , clusterName , caSecName , true , env )
267
+
268
+ // sign and create secret using CA certificate and key
269
+ serverPair , err := caPair .CreateAndSignPair ("minio-service" , certs .CertTypeServer ,
270
+ []string {"minio-service.internal.mydomain.net, minio-service.default.svc, minio-service.default," },
271
+ )
272
+ Expect (err ).ToNot (HaveOccurred ())
273
+ serverSecret := serverPair .GenerateCertificateSecret (namespace , tlsSecName )
274
+ err = env .Client .Create (env .Ctx , serverSecret )
275
+ Expect (err ).ToNot (HaveOccurred ())
276
+
277
+ By ("creating the credentials for minio" , func () {
278
+ AssertStorageCredentialsAreCreated (namespace , "backup-storage-creds" , "minio" , "minio123" )
279
+ })
280
+
281
+ By ("setting up minio" , func () {
282
+ InstallMinio (namespace , "/backup/minio-with-tls/minio-deployment.yaml" )
283
+ })
284
+
285
+ // Create the minio client pod and wait for it to be ready.
286
+ // We'll use it to check if everything is archived correctly
287
+ By ("setting up minio client pod" , func () {
288
+ InstallMinioClient (namespace , "/backup/minio-with-tls/minio-client.yaml" )
289
+ })
290
+
291
+ // Create the cluster
292
+ AssertCreateCluster (namespace , clusterName , clusterWithMinioSampleFile , env )
293
+
294
+ // Write a table and some data on the "app" database
295
+ AssertCreateTestData (namespace , clusterName , "test_table" )
296
+
297
+ AssertArchiveWalOnMinio (namespace , clusterName )
298
+
299
+ // There should be a backup resource and
300
+ By ("backing up a cluster and verifying it exists on minio" , func () {
301
+ utils .ExecuteBackup (namespace , backupFile , env )
302
+
303
+ Eventually (func () (int , error ) {
304
+ return CountFilesOnMinio (namespace , "data.tar" )
305
+ }, 30 ).Should (BeEquivalentTo (1 ))
306
+ Eventually (func () (string , error ) {
307
+ cluster := & apiv1.Cluster {}
308
+ err := env .Client .Get (env .Ctx ,
309
+ ctrlclient.ObjectKey {Namespace : namespace , Name : clusterName },
310
+ cluster )
311
+ return cluster .Status .FirstRecoverabilityPoint , err
312
+ }, 30 ).ShouldNot (BeEmpty ())
313
+ })
314
+
315
+ // Restore backup in a new cluster
316
+ AssertClusterRestore (namespace , clusterRestoreSampleFile , "test_table" )
317
+
318
+ previous := 0
319
+
320
+ By ("checking the previous number of .history files in minio" , func () {
321
+ previous , err = CountFilesOnMinio (namespace , "*.history.gz" )
322
+ Expect (err ).ToNot (HaveOccurred ())
323
+ })
324
+
325
+ AssertSwitchover (namespace , clusterName , env )
326
+
327
+ By ("checking the number of .history after switchover" , func () {
328
+ Eventually (func () (int , error ) {
329
+ return CountFilesOnMinio (namespace , "*.history.gz" )
330
+ }, 60 ).Should (BeNumerically (">" , previous ))
331
+ })
332
+ })
249
333
})
250
334
251
335
Context ("using azure blobs as object storage with storage account access authentication" , func () {
@@ -589,13 +673,13 @@ var _ = Describe("Clusters Recovery From Barman Object Store", func() {
589
673
AssertStorageCredentialsAreCreated (namespace , "backup-storage-creds" , "minio" , "minio123" )
590
674
})
591
675
By ("setting up minio" , func () {
592
- InstallMinio (namespace )
676
+ InstallMinio (namespace , "/backup/minio/minio-deployment.yaml" )
593
677
})
594
678
595
679
// Create the minio client pod and wait for it to be ready.
596
680
// We'll use it to check if everything is archived correctly
597
681
By ("setting up minio client pod" , func () {
598
- InstallMinioClient (namespace )
682
+ InstallMinioClient (namespace , "/backup/minio/minio-client.yaml" )
599
683
})
600
684
601
685
// Create the cluster
@@ -659,13 +743,13 @@ var _ = Describe("Clusters Recovery From Barman Object Store", func() {
659
743
AssertStorageCredentialsAreCreated (namespace , "backup-storage-creds" , "minio" , "minio123" )
660
744
})
661
745
By ("setting up minio" , func () {
662
- InstallMinio (namespace )
746
+ InstallMinio (namespace , "/backup/minio/minio-deployment.yaml" )
663
747
})
664
748
665
749
// Create the minio client pod and wait for it to be ready.
666
750
// We'll use it to check if everything is archived correctly.
667
751
By ("setting up minio client pod" , func () {
668
- InstallMinioClient (namespace )
752
+ InstallMinioClient (namespace , "/backup/minio/minio-client.yaml" )
669
753
})
670
754
671
755
// Create the Cluster
0 commit comments