-
Notifications
You must be signed in to change notification settings - Fork 29
/
ztp_suite_test.go
77 lines (63 loc) · 2.62 KB
/
ztp_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
package ztp
import (
"fmt"
"path"
"runtime"
"testing"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/openshift-kni/eco-goinfra/pkg/clients"
"github.com/openshift-kni/eco-goinfra/pkg/namespace"
"github.com/openshift-kni/eco-goinfra/pkg/reportxml"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/gitopsztp/internal/gitdetails"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/gitopsztp/internal/tsparams"
_ "github.com/openshift-kni/eco-gotests/tests/cnf/ran/gitopsztp/tests"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/rancluster"
. "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/raninittools"
"github.com/openshift-kni/eco-gotests/tests/internal/reporter"
)
var _, currentFile, _, _ = runtime.Caller(0)
func TestZtp(t *testing.T) {
_, reporterConfig := GinkgoConfiguration()
reporterConfig.JUnitReport = RANConfig.GetJunitReportPath(currentFile)
RegisterFailHandler(Fail)
RunSpecs(t, "RAN ZTP Suite", Label(tsparams.Labels...), reporterConfig)
}
var _ = BeforeSuite(func() {
By("checking that the required clusters are present")
if !rancluster.AreClustersPresent([]*clients.Settings{HubAPIClient, Spoke1APIClient}) {
Skip("not all of the required clusters are present")
}
err := gitdetails.GetArgoCdAppGitDetails()
Expect(err).ToNot(HaveOccurred(), "Failed to get current data from ArgoCD")
By("deleting and recreating ZTP test namespace to ensure a blank state")
err = namespace.NewBuilder(HubAPIClient, tsparams.TestNamespace).DeleteAndWait(5 * time.Minute)
Expect(err).ToNot(HaveOccurred(), "Failed to delete ZTP test namespace")
_, err = namespace.NewBuilder(HubAPIClient, tsparams.TestNamespace).Create()
Expect(err).ToNot(HaveOccurred(), "Failed to create ZTP test namespace")
})
var _ = AfterSuite(func() {
err := namespace.NewBuilder(HubAPIClient, tsparams.TestNamespace).DeleteAndWait(5 * time.Minute)
Expect(err).ToNot(HaveOccurred(), "Failed to delete ZTP test namespace")
})
var _ = JustAfterEach(func() {
var (
currentDir, currentFilename = path.Split(currentFile)
hubReportPath = fmt.Sprintf("%shub_%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)
}
})
var _ = ReportAfterSuite("", func(report Report) {
reportxml.Create(report, RANConfig.GetReportPath(), RANConfig.TCPrefix)
})