Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 0dd60ab

Browse files
committed
test: run OLM tests first, II
The previous approach was incomplete. We also need to avoid random ordering because of hash iteration and move other tests that registered themselves directly with Ginkgo.
1 parent 839b637 commit 0dd60ab

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

test/e2e/deploy/deploy.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,9 +1483,12 @@ var tests = map[string]map[string][]func(d *Deployment){}
14831483

14841484
// Describe remembers a certain test. The actual registration in
14851485
// Ginkgo happens in DefineTests, ordered such that all tests with the
1486-
// same "deployment" string are defined on after the after with the
1486+
// same "deployment" string are defined one after the after with the
14871487
// given "describe" string.
14881488
//
1489+
// An empty deployment is valid. Those tests will run after the ones
1490+
// which use deployments. Their callback is passed a nil Deployment.
1491+
//
14891492
// When "describe" is already unique, "what" can be left empty.
14901493
func Describe(deployment, describe, what string, f func(d *Deployment)) bool {
14911494
group := tests[deployment]
@@ -1509,12 +1512,26 @@ func Describe(deployment, describe, what string, f func(d *Deployment)) bool {
15091512

15101513
// DefineTests must be called to register all tests defined so far via Describe.
15111514
func DefineTests() {
1512-
for deploymentName, group := range tests {
1515+
all := allDeployments[:]
1516+
for deploymentName := range tests {
1517+
if !haveDeployment(all, deploymentName) {
1518+
all = append(all, deploymentName)
1519+
}
1520+
}
1521+
1522+
for _, deploymentName := range all {
1523+
group, ok := tests[deploymentName]
1524+
if !ok {
1525+
continue
1526+
}
15131527
deploymentName := deploymentName
15141528
for describe, funcs := range group {
15151529
funcs := funcs
15161530
ginkgo.Describe(describe, func() {
1517-
deployment := EnsureDeployment(deploymentName)
1531+
var deployment *Deployment
1532+
if deploymentName != "" {
1533+
deployment = EnsureDeployment(deploymentName)
1534+
}
15181535
for _, f := range funcs {
15191536
f(deployment)
15201537
}
@@ -1523,6 +1540,15 @@ func DefineTests() {
15231540
}
15241541
}
15251542

1543+
func haveDeployment(all []string, one string) bool {
1544+
for _, a := range all {
1545+
if a == one {
1546+
return true
1547+
}
1548+
}
1549+
return false
1550+
}
1551+
15261552
// waitForPodDeletion returns an error if it takes too long for the pod to fully terminate.
15271553
func waitForPodDeletion(c *Cluster, pod v1.Pod) error {
15281554
return wait.PollImmediate(2*time.Second, time.Minute, func() (bool, error) {

test/e2e/imagefile/imagefilee2e.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/onsi/ginkgo"
1515

1616
"github.com/intel/pmem-csi/pkg/imagefile/test"
17+
"github.com/intel/pmem-csi/test/e2e/deploy"
1718
)
1819

1920
type tImplementation struct {
@@ -39,7 +40,7 @@ func (t *tImplementation) Skipf(format string, args ...interface{}) {
3940
ginkgo.Skip(fmt.Sprintf(format, args...))
4041
}
4142

42-
var _ = ginkgo.Describe("imagefile", func() {
43+
var _ = deploy.Describe("", "imagefile", "", func(d *deploy.Deployment) {
4344
// Our Outer and Inner implementation do not need a valid pointer.
4445
test.ImageFile((*tImplementation)(nil))
4546
})

0 commit comments

Comments
 (0)