-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathpowermanagement_suite_test.go
59 lines (46 loc) · 2.22 KB
/
powermanagement_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
package powermanagement
import (
"runtime"
"testing"
"github.com/golang/glog"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"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/internal/raninittools"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/ranparam"
"github.com/openshift-kni/eco-gotests/tests/cnf/ran/powermanagement/internal/tsparams"
_ "github.com/openshift-kni/eco-gotests/tests/cnf/ran/powermanagement/tests"
"github.com/openshift-kni/eco-gotests/tests/internal/reporter"
)
var _, currentFile, _, _ = runtime.Caller(0)
func TestPowerSave(t *testing.T) {
_, reporterConfig := GinkgoConfiguration()
reporterConfig.JUnitReport = RANConfig.GetJunitReportPath(currentFile)
RegisterFailHandler(Fail)
RunSpecs(t, "Power Management Test Suite", Label(tsparams.Labels...), reporterConfig)
}
var _ = BeforeSuite(func() {
// Cleanup and create test namespace
testNamespace := namespace.NewBuilder(Spoke1APIClient, tsparams.TestingNamespace).
WithLabel("pod-security.kubernetes.io/enforce", "baseline")
glog.V(ranparam.LogLevel).Infof("Deleting test namespace ", tsparams.TestingNamespace)
err := testNamespace.DeleteAndWait(tsparams.PowerSaveTimeout)
Expect(err).ToNot(HaveOccurred(), "Failed to delete namespace ", tsparams.TestingNamespace)
glog.V(ranparam.LogLevel).Infof("Creating test namespace ", tsparams.TestingNamespace)
_, err = testNamespace.Create()
Expect(err).ToNot(HaveOccurred(), "Failed to create namespace ", tsparams.TestingNamespace)
})
var _ = AfterSuite(func() {
testNamespace := namespace.NewBuilder(Spoke1APIClient, tsparams.TestingNamespace)
glog.V(ranparam.LogLevel).Infof("Deleting test namespace", tsparams.TestingNamespace)
err := testNamespace.DeleteAndWait(tsparams.PowerSaveTimeout)
Expect(err).ToNot(HaveOccurred(), "Failed to delete namespace ", tsparams.TestingNamespace)
})
var _ = JustAfterEach(func() {
reporter.ReportIfFailed(
CurrentSpecReport(), currentFile, tsparams.ReporterNamespacesToDump, tsparams.ReporterCRsToDump)
})
var _ = ReportAfterSuite("", func(report Report) {
reportxml.Create(report, RANConfig.GetReportPath(), RANConfig.TCPrefix)
})