Skip to content

Commit ecef64d

Browse files
authored
test(e2e): enable GCS tests with fake-gcs-server (#82)
Activate backup and restore tests with GCS using the fake-gcs-server emulator. Use a fork that support partial reads. Signed-off-by: Francesco Canovai <[email protected]>
1 parent be40375 commit ecef64d

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

test/e2e/internal/objectstore/fakegcsserver.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ func newGCSDeployment(namespace, name string) *appsv1.Deployment {
6767
Containers: []corev1.Container{
6868
{
6969
Name: name,
70-
// TODO: renovate the image
71-
Image: "registry.barman-cloud-plugin:5000/fakegcs:test",
70+
// TODO: use the official image when https://github.com/fsouza/fake-gcs-server/pull/1827
71+
// is merged and released
72+
Image: "ghcr.io/fcanovai/fake-gcs-server:latest",
7273
Ports: []corev1.ContainerPort{
7374
{
7475
ContainerPort: 4443,
@@ -189,7 +190,14 @@ func NewGCSObjectStore(namespace, name, gcsOSName string) *pluginBarmanCloudV1.O
189190
},
190191
},
191192
DestinationPath: "gs://backups/",
192-
EndpointURL: fmt.Sprintf("http://%v:4443", gcsOSName),
193+
},
194+
InstanceSidecarConfiguration: pluginBarmanCloudV1.InstanceSidecarConfiguration{
195+
Env: []corev1.EnvVar{
196+
{
197+
Name: "STORAGE_EMULATOR_HOST",
198+
Value: fmt.Sprintf("http://%v:4443", gcsOSName),
199+
},
200+
},
193201
},
194202
},
195203
}

test/e2e/internal/tests/backup/backup_restore.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,13 @@ var _ = Describe("Backup and restore", func() {
195195
"using in-tree for backup and the plugin for restore on Azure",
196196
&azureBackupPluginInTreeBackupPluginRestore{},
197197
),
198-
// TODO: enable the tests for GCS when we have support for STORAGE_EMULATOR_HOST
199-
// env variable.
200-
PEntry("using the plugin for backup and restore on GCS",
198+
Entry("using the plugin for backup and restore on GCS",
201199
&gcsBackupPluginBackupPluginRestore{},
202200
),
203-
PEntry("using the plugin for backup and in-tree for restore on GCS",
201+
Entry("using the plugin for backup and in-tree for restore on GCS",
204202
&gcsBackupPluginBackupInTreeRestore{},
205203
),
206-
PEntry(
204+
Entry(
207205
"using in-tree for backup and the plugin for restore on GCS",
208206
&gcsBackupPluginInTreeBackupPluginRestore{},
209207
),

test/e2e/internal/tests/backup/fixtures.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ func newSrcClusterInTreeGCS(namespace string) *cloudnativepgv1.Cluster {
579579
StorageConfiguration: cloudnativepgv1.StorageConfiguration{
580580
Size: size,
581581
},
582+
Env: []corev1.EnvVar{
583+
{
584+
Name: "STORAGE_EMULATOR_HOST",
585+
Value: fmt.Sprintf("http://%v:4443", gcs),
586+
},
587+
},
582588
Backup: &cloudnativepgv1.BackupConfiguration{
583589
BarmanObjectStore: &cloudnativepgv1.BarmanObjectStoreConfiguration{
584590
BarmanCredentials: barmanapi.BarmanCredentials{
@@ -591,7 +597,6 @@ func newSrcClusterInTreeGCS(namespace string) *cloudnativepgv1.Cluster {
591597
},
592598
},
593599
},
594-
EndpointURL: fmt.Sprintf("http://%v:4443", gcs),
595600
DestinationPath: "gs://backups/",
596601
},
597602
},
@@ -627,6 +632,12 @@ func newDstClusterInTreeGCS(namespace string) *cloudnativepgv1.Cluster {
627632
},
628633
},
629634
},
635+
Env: []corev1.EnvVar{
636+
{
637+
Name: "STORAGE_EMULATOR_HOST",
638+
Value: fmt.Sprintf("http://%v:4443", gcs),
639+
},
640+
},
630641
ExternalClusters: []cloudnativepgv1.ExternalCluster{
631642
{
632643
Name: "source",
@@ -642,7 +653,6 @@ func newDstClusterInTreeGCS(namespace string) *cloudnativepgv1.Cluster {
642653
},
643654
},
644655
DestinationPath: "gs://backups/",
645-
EndpointURL: fmt.Sprintf("http://%v:4443", gcs),
646656
},
647657
},
648658
},

0 commit comments

Comments
 (0)