Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: remove the use of test context #1606

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 0 additions & 77 deletions e2e/actions_test.go

This file was deleted.

72 changes: 37 additions & 35 deletions e2e/exhaustive_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"

"github.com/ramendr/ramen/e2e/deployers"
"github.com/ramendr/ramen/e2e/testcontext"
"github.com/ramendr/ramen/e2e/dractions"
"github.com/ramendr/ramen/e2e/util"
"github.com/ramendr/ramen/e2e/workloads"
)
Expand Down Expand Up @@ -55,7 +55,7 @@ func generateWorkloads([]workloads.Workload) {
Path: GITPATH,
Revision: GITREVISION,
AppName: APPNAME,
Name: fmt.Sprintf("Deploy-%s", suffix),
Name: fmt.Sprintf("Deployment-%s", suffix),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy is indeed confusing. I think the a better way is to remove the "Deploy-" prefix.

PVCSpec: pvcSpec,
}
Workloads = append(Workloads, deployment)
Expand Down Expand Up @@ -85,52 +85,54 @@ func Exhaustive(t *testing.T) {
w := workload
d := deployer

t.Run(w.GetName(), func(t *testing.T) {
t.Run(w.GetName()+"-"+d.GetName(), func(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a function accepting a workload and deloyer and returning a test name would be little nicer.

t.Parallel()
t.Run(d.GetName(), func(t *testing.T) {
t.Parallel()
testcontext.AddTestContext(t.Name(), w, d)
runTestFlow(t)
testcontext.DeleteTestContext(t.Name(), w, d)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better! the previous way was too complicated without any benefit.

runTestFlow(t, w, d)
})
}
}
}

func runTestFlow(t *testing.T) {
func runTestFlow(t *testing.T, w workloads.Workload, d deployers.Deployer) {
t.Helper()

testCtx, err := testcontext.GetTestContext(t.Name())
if err != nil {
t.Fatal(err)
if !d.IsWorkloadSupported(w) {
t.Skipf("Workload %s not supported by deployer %s, skip test", w.GetName(), d.GetName())
}

if !testCtx.Deployer.IsWorkloadSupported(testCtx.Workload) {
t.Skipf("Workload %s not supported by deployer %s, skip test", testCtx.Workload.GetName(), testCtx.Deployer.GetName())
}

if !t.Run("Deploy", DeployAction) {
t.Fatal("Deploy failed")
}
t.Run("Deploy", func(t *testing.T) {
if err := d.Deploy(w); err != nil {
t.Fatal("Deploy failed")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not improve the code. Being able to run a sub test defined elsewhere is nicer. It will make it easier to create more flows except this simple flow. I think #1598 is better in this case.

})

if !t.Run("Enable", EnableAction) {
t.Fatal("Enable failed")
}
t.Run("Enable", func(t *testing.T) {
if err := dractions.EnableProtection(w, d); err != nil {
t.Fatal("Enable failed")
}
})

if !t.Run("Failover", FailoverAction) {
t.Fatal("Failover failed")
}
t.Run("Failover", func(t *testing.T) {
if err := dractions.Failover(w, d); err != nil {
t.Fatal("Failover failed")
}
})

if !t.Run("Relocate", RelocateAction) {
t.Fatal("Relocate failed")
}
t.Run("Relocate", func(t *testing.T) {
if err := dractions.Relocate(w, d); err != nil {
t.Fatal("Relocate failed")
}
})

if !t.Run("Disable", DisableAction) {
t.Fatal("Disable failed")
}
t.Run("Disable", func(t *testing.T) {
if err := dractions.DisableProtection(w, d); err != nil {
t.Fatal("Disable failed")
}
})

if !t.Run("Undeploy", UndeployAction) {
t.Fatal("Undeploy failed")
}
t.Run("Undeploy", func(t *testing.T) {
if err := d.Undeploy(w); err != nil {
t.Fatal("Undeploy failed")
}
})
}
50 changes: 0 additions & 50 deletions e2e/testcontext/testcontext.go

This file was deleted.

Loading