Skip to content

Commit e5a004d

Browse files
fcanovaileonardoce
andauthored
test(e2e): replica cluster (#88)
Signed-off-by: Francesco Canovai <[email protected]> Signed-off-by: Leonardo Cecchi <[email protected]> Co-authored-by: Leonardo Cecchi <[email protected]>
1 parent c462306 commit e5a004d

File tree

10 files changed

+605
-25
lines changed

10 files changed

+605
-25
lines changed

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ tasks:
204204
deps:
205205
- build-images
206206
cmds:
207-
- go test -timeout 30m -v ./test/e2e
207+
- go test -timeout 60m -v ./test/e2e
208208

209209
ci:
210210
desc: Run the CI pipeline

test/e2e/e2e_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/kustomize"
4242

4343
_ "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/tests/backup"
44+
_ "github.com/cloudnative-pg/plugin-barman-cloud/test/e2e/internal/tests/replicacluster"
4445

4546
. "github.com/onsi/ginkgo/v2"
4647
. "github.com/onsi/gomega"

test/e2e/internal/objectstore/azurite.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
pluginBarmanCloudV1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
3232
)
3333

34-
func NewAzuriteObjectStoreResources(namespace, name string) Resources {
35-
return Resources{
34+
// NewAzuriteObjectStoreResources creates the resources required to create an Azurite object store.
35+
func NewAzuriteObjectStoreResources(namespace, name string) *Resources {
36+
return &Resources{
3637
Deployment: newAzuriteDeployment(namespace, name),
3738
Service: newAzuriteService(namespace, name),
3839
PVC: newAzuritePVC(namespace, name),
@@ -174,6 +175,7 @@ func newAzuritePVC(namespace, name string) *corev1.PersistentVolumeClaim {
174175
}
175176
}
176177

178+
// NewAzuriteObjectStore creates a new ObjectStore object for Azurite.
177179
func NewAzuriteObjectStore(namespace, name, azuriteOSName string) *pluginBarmanCloudV1.ObjectStore {
178180
return &pluginBarmanCloudV1.ObjectStore{
179181
TypeMeta: metav1.TypeMeta{

test/e2e/internal/objectstore/fakegcsserver.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
pluginBarmanCloudV1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
3232
)
3333

34-
func NewGCSObjectStoreResources(namespace, name string) Resources {
35-
return Resources{
34+
// NewGCSObjectStoreResources creates the resources required to create a GCS object store.
35+
func NewGCSObjectStoreResources(namespace, name string) *Resources {
36+
return &Resources{
3637
Deployment: newGCSDeployment(namespace, name),
3738
Service: newGCSService(namespace, name),
3839
Secret: newGCSSecret(namespace, name),
@@ -76,7 +77,8 @@ func newGCSDeployment(namespace, name string) *appsv1.Deployment {
7677
},
7778
},
7879
Command: []string{"fake-gcs-server"},
79-
Args: []string{"-scheme",
80+
Args: []string{
81+
"-scheme",
8082
"http",
8183
"-port",
8284
"4443",
@@ -167,6 +169,7 @@ func newGCSPVC(namespace, name string) *corev1.PersistentVolumeClaim {
167169
}
168170
}
169171

172+
// NewGCSObjectStore creates a new GCS object store.
170173
func NewGCSObjectStore(namespace, name, gcsOSName string) *pluginBarmanCloudV1.ObjectStore {
171174
return &pluginBarmanCloudV1.ObjectStore{
172175
TypeMeta: metav1.TypeMeta{

test/e2e/internal/objectstore/minio.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ import (
3131
pluginBarmanCloudV1 "github.com/cloudnative-pg/plugin-barman-cloud/api/v1"
3232
)
3333

34-
func NewMinioObjectStoreResources(namespace, name string) Resources {
35-
return Resources{
34+
// NewMinioObjectStoreResources creates the resources required to create a Minio object store.
35+
func NewMinioObjectStoreResources(namespace, name string) *Resources {
36+
return &Resources{
3637
Deployment: newMinioDeployment(namespace, name),
3738
Service: newMinioService(namespace, name),
3839
PVC: newMinioPVC(namespace, name),
@@ -189,6 +190,7 @@ func newMinioPVC(namespace, name string) *corev1.PersistentVolumeClaim {
189190
}
190191
}
191192

193+
// NewMinioObjectStore creates a new Minio object store.
192194
func NewMinioObjectStore(namespace, name, minioOSName string) *pluginBarmanCloudV1.ObjectStore {
193195
return &pluginBarmanCloudV1.ObjectStore{
194196
TypeMeta: metav1.TypeMeta{

test/e2e/internal/objectstore/objectstore.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,45 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"k8s.io/api/apps/v1"
24-
v2 "k8s.io/api/core/v1"
23+
appsv1 "k8s.io/api/apps/v1"
24+
corev1 "k8s.io/api/core/v1"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626
)
2727

2828
const (
29-
// Size of the PVCs for the object stores
29+
// DefaultSize is the default size of the PVCs for the object stores.
3030
DefaultSize = "1Gi"
3131
)
3232

3333
// Resources represents the resources required to create an object store.
3434
type Resources struct {
35-
Deployment *v1.Deployment
36-
Service *v2.Service
37-
Secret *v2.Secret
38-
PVC *v2.PersistentVolumeClaim
35+
Deployment *appsv1.Deployment
36+
Service *corev1.Service
37+
Secret *corev1.Secret
38+
PVC *corev1.PersistentVolumeClaim
3939
}
4040

4141
// Create creates the object store resources.
4242
func (osr Resources) Create(ctx context.Context, cl client.Client) error {
43-
if err := cl.Create(ctx, osr.PVC); err != nil {
44-
return fmt.Errorf("failed to create PVC: %w", err)
43+
if osr.PVC != nil {
44+
if err := cl.Create(ctx, osr.PVC); err != nil {
45+
return fmt.Errorf("failed to create PVC: %w", err)
46+
}
4547
}
46-
if err := cl.Create(ctx, osr.Secret); err != nil {
47-
return fmt.Errorf("failed to create secret: %w", err)
48+
if osr.Secret != nil {
49+
if err := cl.Create(ctx, osr.Secret); err != nil {
50+
return fmt.Errorf("failed to create secret: %w", err)
51+
}
4852
}
49-
if err := cl.Create(ctx, osr.Deployment); err != nil {
50-
return fmt.Errorf("failed to create deployment: %w", err)
53+
if osr.Deployment != nil {
54+
if err := cl.Create(ctx, osr.Deployment); err != nil {
55+
return fmt.Errorf("failed to create deployment: %w", err)
56+
}
5157
}
52-
if err := cl.Create(ctx, osr.Service); err != nil {
53-
return fmt.Errorf("failed to create service: %w", err)
58+
if osr.Service != nil {
59+
if err := cl.Create(ctx, osr.Service); err != nil {
60+
return fmt.Errorf("failed to create service: %w", err)
61+
}
5462
}
5563

5664
return nil

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const (
3434
minio = "minio"
3535
azurite = "azurite"
3636
gcs = "gcs"
37-
// Size of the PVCs for the object stores and the cluster instances
37+
// Size of the PVCs for the object stores and the cluster instances.
3838
size = "1Gi"
3939
srcClusterName = "source"
4040
srcBackupName = "source"
@@ -48,7 +48,7 @@ type testCaseFactory interface {
4848
}
4949

5050
type backupRestoreTestResources struct {
51-
ObjectStoreResources objectstore.Resources
51+
ObjectStoreResources *objectstore.Resources
5252
ObjectStore *pluginBarmanCloudV1.ObjectStore
5353
SrcCluster *cloudnativepgv1.Cluster
5454
SrcBackup *cloudnativepgv1.Backup
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright 2024.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package replicacluster contains tests validating replica clusters
18+
// using the Barman Cloud Plugin.
19+
package replicacluster

0 commit comments

Comments
 (0)