-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathtalm_suite_test.go
78 lines (65 loc) · 2.45 KB
/
talm_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
package talm
import (
"fmt"
"path"
"runtime"
"testing"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
. "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/raninittools"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/talm/internal/setup"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/talm/internal/tsparams"
_ "github.com/openshift-kni/eco-gotests/tests/cnf/ran/talm/tests"
"github.com/openshift-kni/eco-gotests/tests/internal/reporter"
)
var _, currentFile, _, _ = runtime.Caller(0)
func TestTalm(t *testing.T) {
_, reporterConfig := GinkgoConfiguration()
reporterConfig.JUnitReport = RANConfig.GetJunitReportPath(currentFile)
RegisterFailHandler(Fail)
RunSpecs(t, "TALM Suite", Label(tsparams.Labels...), reporterConfig)
}
var _ = BeforeSuite(func() {
err := setup.VerifyTalmIsInstalled()
Expect(err).ToNot(HaveOccurred(), "Failed to verify that TALM is installed")
By("deleting and recreating TALM test namespace to ensure a blank slate")
err = setup.DeleteTalmTestNamespace()
Expect(err).ToNot(HaveOccurred(), "Failed to delete TALM test namespace")
err = setup.CreateTalmTestNamespace()
Expect(err).ToNot(HaveOccurred(), "Failed to create TALM test namespace")
})
var _ = AfterSuite(func() {
// Deleting the namespace after the suite finishes ensures all the CGUs created are deleted
err := setup.DeleteTalmTestNamespace()
Expect(err).ToNot(HaveOccurred(), "Failed to delete TALM test namespace")
})
var _ = JustAfterEach(func() {
var (
currentDir, currentFilename = path.Split(currentFile)
hubReportPath = fmt.Sprintf("%shub_%s", currentDir, currentFilename)
spoke2ReportPath = fmt.Sprintf("%sspoke2_%s", currentDir, currentFilename)
report = CurrentSpecReport()
)
reporter.ReportIfFailed(
report, currentFile, tsparams.ReporterSpokeNamespacesToDump, tsparams.ReporterSpokeCRsToDump)
if HubAPIClient != nil {
reporter.ReportIfFailedOnCluster(
RANConfig.HubKubeconfig,
report,
hubReportPath,
tsparams.ReporterHubNamespacesToDump,
tsparams.ReporterHubCRsToDump)
}
if Spoke2APIClient != nil {
reporter.ReportIfFailedOnCluster(
RANConfig.Spoke2Kubeconfig,
report,
spoke2ReportPath,
tsparams.ReporterSpokeNamespacesToDump,
tsparams.ReporterSpokeCRsToDump)
}
})
var _ = ReportAfterSuite("", func(report Report) {
reportxml.Create(report, RANConfig.GetReportPath(), RANConfig.TCPrefix)
})