Skip to content

Commit a923fce

Browse files
ivanmatmatioktalz
authored andcommitted
TEST: modification of custom resource poc integration test
1 parent 57aff86 commit a923fce

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

deploy/tests/integration/customresources/customresource_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ package customresources
1616

1717
import (
1818
"github.com/stretchr/testify/assert"
19-
20-
"github.com/haproxytech/kubernetes-ingress/deploy/tests/e2e"
2119
)
2220

2321
func (suite *CustomResourceSuite) TestGlobalCR() {
@@ -28,21 +26,23 @@ func (suite *CustomResourceSuite) TestGlobalCR() {
2826
t := suite.T()
2927

3028
suite.Run("Adding a global CR creates global and logTargets objects", func() {
29+
eventProcessedChan := make(chan struct{})
30+
globalCREvt.EventProcessed = eventProcessedChan
3131
eventChan <- globalCREvt
32-
suite.Require().Eventually(func() bool {
33-
return assert.Len(t, globals, 1, "Should find one and only one Global CR") ||
34-
assert.Len(t, logtrargets, 1, "Should find one and only one LogTargets CR") ||
35-
assert.Containsf(t, globals, globalCREvt.Name, "Global CR of name '%s' not found", globalCREvt.Name)
36-
}, e2e.WaitDuration, e2e.TickDuration)
32+
<-eventProcessedChan
33+
assert.Len(t, globals, 1, "Should find one and only one Global CR")
34+
assert.Len(t, logtrargets, 1, "Should find one and only one LogTargets CR")
35+
assert.Containsf(t, globals, globalCREvt.Name, "Global CR of name '%s' not found", globalCREvt.Name)
3736
})
3837

3938
suite.Run("Deleting a global CR removes global and logTargets objects", func() {
4039
globalCREvt.Data = nil
40+
eventProcessedChan := make(chan struct{})
41+
globalCREvt.EventProcessed = eventProcessedChan
4142
eventChan <- globalCREvt
42-
suite.Require().Eventually(func() bool {
43-
return assert.Len(t, globals, 0, "No Global CR should be present") ||
44-
assert.Len(t, logtrargets, 0, "No LogTargets should be present")
45-
}, e2e.WaitDuration, e2e.TickDuration)
43+
<-eventProcessedChan
44+
assert.Len(t, globals, 0, "No Global CR should be present")
45+
assert.Len(t, logtrargets, 0, "No LogTargets should be present")
4646
})
4747

4848
close(eventChan)

deploy/tests/integration/customresources/suite_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package customresources
1616

1717
import (
1818
"io/ioutil"
19+
"os"
1920
"path/filepath"
2021
"testing"
2122

@@ -52,6 +53,7 @@ func (suite *CustomResourceSuite) BeforeTest(suiteName, testName string) {
5253
suite.T().Fatalf("Suite '%s': Test '%s' : error : %s", suiteName, testName, err)
5354
}
5455
suite.test.TempDir = tempDir
56+
suite.T().Logf("temporary configuration dir %s", suite.test.TempDir)
5557
}
5658

5759
var haproxyConfig = `global
@@ -94,9 +96,13 @@ frontend stats
9496

9597
func (suite *CustomResourceSuite) GlobalCRFixture() (eventChan chan k8s.SyncDataEvent, s store.K8s, globalCREvt k8s.SyncDataEvent) {
9698
var osArgs utils.OSArgs
99+
os.Args = []string{os.Args[0], "-e", "-t", "--config-dir=" + suite.test.TempDir}
97100
parser := flags.NewParser(&osArgs, flags.IgnoreUnknown)
98-
_, _ = parser.Parse()
99-
osArgs.Test = true
101+
_, errParsing := parser.Parse()
102+
if errParsing != nil {
103+
suite.T().Fatal(errParsing)
104+
}
105+
100106
eventChan = make(chan k8s.SyncDataEvent, watch.DefaultChanSize*6)
101107
s = store.NewK8sStore(osArgs)
102108
globalCREvt = k8s.SyncDataEvent{

0 commit comments

Comments
 (0)