-
Notifications
You must be signed in to change notification settings - Fork 135
/
test_suite_test.go
129 lines (111 loc) · 4.29 KB
/
test_suite_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//go:build !unittests
// +build !unittests
package test_test
import (
"flag"
"log"
"os"
"path"
"strings"
"testing"
. "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/reporters"
"github.com/onsi/ginkgo/v2/types"
. "github.com/onsi/gomega"
"github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/pkg/features"
testutils "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/pkg/utils"
kniK8sReporter "github.com/openshift-kni/k8sreporter"
qe_reporters "kubevirt.io/qe-tools/pkg/ginkgo-reporters"
// Following imports are needed to run related Ginkgo specifications
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/bond"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/dpdk"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/fec"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/knmstate"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/multinetworkpolicy"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/ovs_qos"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/s2i"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/sctp"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/security"
_ "github.com/openshift-kni/cnf-features-deploy/cnf-tests/testsuites/e2esuite/vrf"
)
// TODO: we should refactor tests to use client from controller-runtime package
// see - https://github.com/openshift/cluster-api-actuator-pkg/blob/master/pkg/e2e/framework/framework.go
var (
junitPath *string
reportPath *string
reporter *kniK8sReporter.KubernetesReporter
err error
)
var suiteFixtureMap = map[string]features.SuiteFixture{
"performance": &features.PAOFixture{},
"sriov": &features.SriovFixture{},
"dpdk": &features.DPDKFixture{},
"bondcni": &features.BondcniFixture{},
"tuningcni": &features.TuningcniFixture{},
"fec": &features.FECFixture{},
"vrf": &features.VRFFixture{},
"ovs_qos": &features.OVSQOSFixture{},
"sctp": &features.SCTPFixture{},
"multinetworkpolicy": &features.MultiNetworkPolicyFixture{},
}
func init() {
junitPath = flag.String("junit", "", "the path for the junit format report")
reportPath = flag.String("report", "", "the path of the report file containing details for failed tests")
featuresVar := os.Getenv("FEATURES")
if featuresVar != "" {
for feature := range suiteFixtureMap {
if !strings.Contains(featuresVar, feature) {
delete(suiteFixtureMap, feature)
}
}
}
}
func TestTest(t *testing.T) {
RegisterFailHandler(
func(message string, callerSkip ...int) {
if reporter != nil {
reporter.Dump(testutils.LogsExtractDuration, CurrentSpecReport().LeafNodeText)
}
// Ensure failing line location is not affected by this wrapper
for i := range callerSkip {
callerSkip[i]++
}
Fail(message, callerSkip...)
})
if *reportPath != "" {
reportFile := path.Join(*reportPath, "cnftests_failure_report.log")
reporter, err = testutils.NewReporter(reportFile)
if err != nil {
log.Fatalf("Failed to create log reporter %s", err)
}
}
RunSpecs(t, "CNF Features e2e integration tests")
}
var _ = BeforeSuite(func() {
for _, feature := range suiteFixtureMap {
err := feature.Setup()
Expect(err).ToNot(HaveOccurred())
}
})
// We do the cleanup in AfterSuite because the failure reporter is triggered
// after a test fails. If we did it as part of the test body, the reporter would not
// find the items we want to inspect.
var _ = AfterSuite(func() {
for _, feature := range suiteFixtureMap {
err := feature.Cleanup()
Expect(err).ToNot(HaveOccurred())
}
})
var _ = ReportAfterSuite("cnftests", func(report types.Report) {
if *junitPath != "" {
junitFile := path.Join(*junitPath, "junit_cnftests.xml")
reporters.GenerateJUnitReportWithConfig(report, junitFile, reporters.JunitReportConfig{
OmitTimelinesForSpecState: types.SpecStatePassed | types.SpecStateSkipped,
OmitLeafNodeType: true,
OmitSuiteSetupNodes: true,
})
}
if qe_reporters.Polarion.Run {
reporters.ReportViaDeprecatedReporter(&qe_reporters.Polarion, report)
}
})