Skip to content

Commit db1a200

Browse files
authored
Fix failing E2E tests (#1256)
Signed-off-by: Emruz Hossain <emruz@appscode.com>
1 parent c3c2ae0 commit db1a200

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+59
-9125
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
github.com/Azure/go-autorest/autorest/to v0.3.1-0.20191028180845-3492b2aff503 // indirect
88
github.com/cenkalti/backoff v2.2.1+incompatible
99
github.com/codeskyblue/go-sh v0.0.0-20200712050446-30169cf553fe
10-
github.com/go-sql-driver/mysql v1.5.0
1110
github.com/gogo/protobuf v1.3.1
1211
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1312
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de // indirect

pkg/status/status.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,12 @@ func (o UpdateStatusOptions) UpdatePostBackupStatus(backupOutput *restic.BackupO
122122
return err
123123
}
124124

125+
var statusErr error
125126
// If the target has been assigned some post-backup actions, execute them
126127
// Only execute the postBackupActions if the backup of current host/hosts has succeeded
128+
// We should update the the target status even if the post-backup actions failed
127129
if backupSucceeded(backupOutput) {
128-
err = o.executePostBackupActions(inv, backupSession, targetInfo.Target.Ref, len(backupOutput.BackupTargetStatus.Stats))
129-
if err != nil {
130-
return err
131-
}
130+
statusErr = o.executePostBackupActions(inv, backupSession, targetInfo.Target.Ref, len(backupOutput.BackupTargetStatus.Stats))
132131
}
133132

134133
// add or update entry for each host in BackupSession status + create event
@@ -145,7 +144,7 @@ func (o UpdateStatusOptions) UpdatePostBackupStatus(backupOutput *restic.BackupO
145144
return backupSession.UID, in
146145
}, metav1.UpdateOptions{})
147146
if err != nil {
148-
return err
147+
statusErr = utilerrors.NewAggregate([]error{statusErr, err})
149148
}
150149

151150
// create status against the BackupSession for each hosts
@@ -180,9 +179,12 @@ func (o UpdateStatusOptions) UpdatePostBackupStatus(backupOutput *restic.BackupO
180179

181180
// if metrics enabled then send backup host specific metrics to the Prometheus pushgateway
182181
if o.Metrics.Enabled && targetInfo.Target != nil {
183-
return o.Metrics.SendBackupHostMetrics(o.Config, inv, targetInfo.Target.Ref, backupOutput)
182+
err = o.Metrics.SendBackupHostMetrics(o.Config, inv, targetInfo.Target.Ref, backupOutput)
183+
if err != nil {
184+
statusErr = utilerrors.NewAggregate([]error{statusErr, err})
185+
}
184186
}
185-
return nil
187+
return statusErr
186188
}
187189

188190
func (o UpdateStatusOptions) UpdatePostRestoreStatus(restoreOutput *restic.RestoreOutput, inv invoker.RestoreInvoker, targetInfo invoker.RestoreTargetInfo) error {

test/e2e/backend/rest.go

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ var _ = Describe("Rest Backend", func() {
4747
Expect(err).NotTo(HaveOccurred())
4848
})
4949

50-
Context("General Backup/Restore with tls secured", func() {
50+
Context("Without TLS", func() {
5151
BeforeEach(func() {
52-
By("Creating Rest Server")
53-
_, err := f.CreateRestServer(true, []net.IP{net.ParseIP("127.0.0.1")})
52+
By("Creating REST Server")
53+
_, err := f.CreateRestServer(false, []net.IP{net.ParseIP("127.0.0.1")})
5454
Expect(err).NotTo(HaveOccurred())
5555
})
5656

57-
It("should backup/restore in/from Rest backend", func() {
57+
It("should backup and restore sample data", func() {
5858
// Deploy a Deployment
5959
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
6060
Expect(err).NotTo(HaveOccurred())
@@ -64,7 +64,7 @@ var _ = Describe("Rest Backend", func() {
6464
Expect(err).NotTo(HaveOccurred())
6565

6666
// Setup a Rest Repository
67-
repo, err := f.SetupRestRepository(true, framework.TEST_REST_SERVER_USERNAME, framework.TEST_REST_SERVER_PASSWORD)
67+
repo, err := f.SetupRestRepository(false, framework.TEST_REST_SERVER_USERNAME, framework.TEST_REST_SERVER_PASSWORD)
6868
Expect(err).NotTo(HaveOccurred())
6969
//
7070
// Setup workload Backup
@@ -107,26 +107,26 @@ var _ = Describe("Rest Backend", func() {
107107
})
108108
})
109109

110-
Context("Backup/Restore big file with tls secured", func() {
110+
Context("With TLS", func() {
111111
BeforeEach(func() {
112-
By("Creating Rest Server")
112+
By("Creating REST Server")
113113
_, err := f.CreateRestServer(true, []net.IP{net.ParseIP("127.0.0.1")})
114114
Expect(err).NotTo(HaveOccurred())
115115
})
116116

117-
It("should backup/restore big file", func() {
117+
It("should backup and restore sample data", func() {
118118
// Deploy a Deployment
119119
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
120120
Expect(err).NotTo(HaveOccurred())
121121

122122
// Generate Sample Data
123-
sampleData, err := f.GenerateBigSampleFile(deployment.ObjectMeta, apis.KindDeployment)
123+
sampleData, err := f.GenerateSampleData(deployment.ObjectMeta, apis.KindDeployment)
124124
Expect(err).NotTo(HaveOccurred())
125125

126126
// Setup a Rest Repository
127127
repo, err := f.SetupRestRepository(true, framework.TEST_REST_SERVER_USERNAME, framework.TEST_REST_SERVER_PASSWORD)
128128
Expect(err).NotTo(HaveOccurred())
129-
129+
//
130130
// Setup workload Backup
131131
backupConfig, err := f.SetupWorkloadBackup(deployment.ObjectMeta, repo, apis.KindDeployment)
132132
Expect(err).NotTo(HaveOccurred())
@@ -142,7 +142,7 @@ var _ = Describe("Rest Backend", func() {
142142
completedBS, err := f.StashClient.StashV1beta1().BackupSessions(backupSession.Namespace).Get(context.TODO(), backupSession.Name, metav1.GetOptions{})
143143
Expect(err).NotTo(HaveOccurred())
144144
Expect(completedBS.Status.Phase).Should(Equal(v1beta1.BackupSessionSucceeded))
145-
145+
//
146146
// Simulate disaster scenario. Delete the data from source PVC
147147
By("Deleting sample data from source Deployment")
148148
err = f.CleanupSampleDataFromWorkload(deployment.ObjectMeta, apis.KindDeployment)
@@ -165,28 +165,20 @@ var _ = Describe("Rest Backend", func() {
165165
By("Verifying restored data is same as the original data")
166166
Expect(restoredData).Should(BeSameAs(sampleData))
167167
})
168-
})
169-
170-
Context("General Backup/Restore without tls secured", func() {
171-
BeforeEach(func() {
172-
By("Creating Rest Server")
173-
_, err := f.CreateRestServer(false, []net.IP{net.ParseIP("127.0.0.1")})
174-
Expect(err).NotTo(HaveOccurred())
175-
})
176168

177-
It("should backup/restore in/from Rest backend", func() {
169+
It("should backup and restore big file", func() {
178170
// Deploy a Deployment
179171
deployment, err := f.DeployDeployment(framework.SourceDeployment, int32(1), framework.SourceVolume)
180172
Expect(err).NotTo(HaveOccurred())
181173

182174
// Generate Sample Data
183-
sampleData, err := f.GenerateSampleData(deployment.ObjectMeta, apis.KindDeployment)
175+
sampleData, err := f.GenerateBigSampleFile(deployment.ObjectMeta, apis.KindDeployment)
184176
Expect(err).NotTo(HaveOccurred())
185177

186178
// Setup a Rest Repository
187-
repo, err := f.SetupRestRepository(false, framework.TEST_REST_SERVER_USERNAME, framework.TEST_REST_SERVER_PASSWORD)
179+
repo, err := f.SetupRestRepository(true, framework.TEST_REST_SERVER_USERNAME, framework.TEST_REST_SERVER_PASSWORD)
188180
Expect(err).NotTo(HaveOccurred())
189-
//
181+
190182
// Setup workload Backup
191183
backupConfig, err := f.SetupWorkloadBackup(deployment.ObjectMeta, repo, apis.KindDeployment)
192184
Expect(err).NotTo(HaveOccurred())
@@ -202,7 +194,7 @@ var _ = Describe("Rest Backend", func() {
202194
completedBS, err := f.StashClient.StashV1beta1().BackupSessions(backupSession.Namespace).Get(context.TODO(), backupSession.Name, metav1.GetOptions{})
203195
Expect(err).NotTo(HaveOccurred())
204196
Expect(completedBS.Status.Phase).Should(Equal(v1beta1.BackupSessionSucceeded))
205-
//
197+
206198
// Simulate disaster scenario. Delete the data from source PVC
207199
By("Deleting sample data from source Deployment")
208200
err = f.CleanupSampleDataFromWorkload(deployment.ObjectMeta, apis.KindDeployment)

test/e2e/e2e_suite_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
. "github.com/onsi/ginkgo"
3737
"github.com/onsi/ginkgo/reporters"
3838
. "github.com/onsi/gomega"
39-
"k8s.io/apimachinery/pkg/api/errors"
4039
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
4140
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
4241
"k8s.io/kubernetes/pkg/api/legacyscheme"
@@ -82,12 +81,6 @@ var _ = BeforeSuite(func() {
8281
By("Deploy TLS secured Minio Server")
8382
_, err = root.CreateMinioServer(true, []net.IP{net.ParseIP(framework.LocalHostIP)})
8483
Expect(err).NotTo(HaveOccurred())
85-
86-
By("Ensure MySQL Addon")
87-
err = root.EnsureMySQLAddon()
88-
if !errors.IsAlreadyExists(err) {
89-
Expect(err).NotTo(HaveOccurred())
90-
}
9184
})
9285

9386
var _ = AfterSuite(func() {
@@ -99,12 +92,6 @@ var _ = AfterSuite(func() {
9992
err := root.DeleteMinioServer()
10093
Expect(err).NotTo(HaveOccurred())
10194

102-
By("Deleting MySQL Addon")
103-
err = root.EnsureMySQLAddonDeleted()
104-
if !errors.IsNotFound(err) {
105-
Expect(err).NotTo(HaveOccurred())
106-
}
107-
10895
By("Deleting namespace: " + root.Namespace())
10996
err = root.DeleteNamespace(root.Namespace())
11097
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)