Skip to content

Commit 5cd097a

Browse files
committed
test: Add deadlines for test operations
Add the standard deadline for test operations (deploy, undeploy, protect, unprotect, failover, relocate) and for our special cleanup operation. We will use more fine grain timeout later. This work will be done in ramen/e2e and we will consume the new finer grain timeouts. This change is required to consume ramen/e2e context deadline added in RamenDR/ramen#2043 Signed-off-by: Nir Soffer <[email protected]>
1 parent 72473e6 commit 5cd097a

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

pkg/test/test.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/ramendr/ramen/e2e/deployers"
1212
"github.com/ramendr/ramen/e2e/types"
13+
"github.com/ramendr/ramen/e2e/util"
1314
"github.com/ramendr/ramen/e2e/workloads"
1415
"golang.org/x/sync/errgroup"
1516

@@ -56,7 +57,9 @@ func newTest(tc types.TestConfig, cmd *Command) *Test {
5657

5758
func (t *Test) Deploy() bool {
5859
t.startStep("deploy")
59-
if err := t.Backend.Deploy(t.Context); err != nil {
60+
timedCtx, cancel := t.WithTimeout(util.Timeout)
61+
defer cancel()
62+
if err := t.Backend.Deploy(timedCtx); err != nil {
6063
return t.failStep(err)
6164
}
6265
console.Pass("Application %q deployed", t.Name())
@@ -65,7 +68,9 @@ func (t *Test) Deploy() bool {
6568

6669
func (t *Test) Undeploy() bool {
6770
t.startStep("undeploy")
68-
if err := t.Backend.Undeploy(t.Context); err != nil {
71+
timedCtx, cancel := t.WithTimeout(util.Timeout)
72+
defer cancel()
73+
if err := t.Backend.Undeploy(timedCtx); err != nil {
6974
return t.failStep(err)
7075
}
7176
console.Pass("Application %q undeployed", t.Name())
@@ -74,7 +79,9 @@ func (t *Test) Undeploy() bool {
7479

7580
func (t *Test) Protect() bool {
7681
t.startStep("protect")
77-
if err := t.Backend.Protect(t.Context); err != nil {
82+
timedCtx, cancel := t.WithTimeout(util.Timeout)
83+
defer cancel()
84+
if err := t.Backend.Protect(timedCtx); err != nil {
7885
return t.failStep(err)
7986
}
8087
console.Pass("Application %q protected", t.Name())
@@ -83,7 +90,9 @@ func (t *Test) Protect() bool {
8390

8491
func (t *Test) Unprotect() bool {
8592
t.startStep("unprotect")
86-
if err := t.Backend.Unprotect(t.Context); err != nil {
93+
timedCtx, cancel := t.WithTimeout(util.Timeout)
94+
defer cancel()
95+
if err := t.Backend.Unprotect(timedCtx); err != nil {
8796
return t.failStep(err)
8897
}
8998
console.Pass("Application %q unprotected", t.Name())
@@ -92,7 +101,9 @@ func (t *Test) Unprotect() bool {
92101

93102
func (t *Test) Failover() bool {
94103
t.startStep("failover")
95-
if err := t.Backend.Failover(t.Context); err != nil {
104+
timedCtx, cancel := t.WithTimeout(util.Timeout)
105+
defer cancel()
106+
if err := t.Backend.Failover(timedCtx); err != nil {
96107
return t.failStep(err)
97108
}
98109
console.Pass("Application %q failed over", t.Name())
@@ -101,7 +112,9 @@ func (t *Test) Failover() bool {
101112

102113
func (t *Test) Relocate() bool {
103114
t.startStep("relocate")
104-
if err := t.Backend.Relocate(t.Context); err != nil {
115+
timedCtx, cancel := t.WithTimeout(util.Timeout)
116+
defer cancel()
117+
if err := t.Backend.Relocate(timedCtx); err != nil {
105118
return t.failStep(err)
106119
}
107120
console.Pass("Application %q relocated", t.Name())
@@ -110,23 +123,26 @@ func (t *Test) Relocate() bool {
110123

111124
func (t *Test) Cleanup() bool {
112125
var g errgroup.Group
126+
timedCtx, cancel := t.WithTimeout(util.Timeout)
127+
defer cancel()
113128

114129
t.startStep("cleanup")
115130
g.Go(func() error {
116-
if err := t.Backend.Unprotect(t.Context); err != nil {
131+
if err := t.Backend.Unprotect(timedCtx); err != nil {
117132
return err
118133
}
119134
return nil
120135
})
121136
g.Go(func() error {
122-
if err := t.Backend.Undeploy(t.Context); err != nil {
137+
if err := t.Backend.Undeploy(timedCtx); err != nil {
123138
return err
124139
}
125140
return nil
126141
})
127142
if err := g.Wait(); err != nil {
128143
return t.failStep(err)
129144
}
145+
130146
console.Pass("Application %q cleaned up", t.Name())
131147
return t.passStep()
132148
}

0 commit comments

Comments
 (0)