blob: bb7082de480645979e6d098a4d95434e6236e55d [file] [log] [blame]
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01001package main
2
3import (
Adrian Villincee15aa2024-03-14 11:42:55 -04004 "reflect"
5 "runtime"
6 "strings"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +01007 "time"
Adrian Villincee15aa2024-03-14 11:42:55 -04008
9 . "github.com/onsi/ginkgo/v2"
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010010)
11
12type TapSuite struct {
13 HstSuite
14}
15
Adrian Villin681ff3a2024-06-07 06:45:48 -040016var tapTests = map[string][]func(s *TapSuite){}
17var tapSoloTests = map[string][]func(s *TapSuite){}
Adrian Villincee15aa2024-03-14 11:42:55 -040018
19func registerTapTests(tests ...func(s *TapSuite)) {
Adrian Villin681ff3a2024-06-07 06:45:48 -040020 tapTests[getTestFilename()] = tests
Adrian Villincee15aa2024-03-14 11:42:55 -040021}
22func registerTapSoloTests(tests ...func(s *TapSuite)) {
Adrian Villin681ff3a2024-06-07 06:45:48 -040023 tapSoloTests[getTestFilename()] = tests
Adrian Villincee15aa2024-03-14 11:42:55 -040024}
25
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010026func (s *TapSuite) SetupSuite() {
27 time.Sleep(1 * time.Second)
Filip Tehlar608d0062023-04-28 10:29:47 +020028 s.HstSuite.SetupSuite()
Maros Ondrejicka2908f8c2023-02-02 08:58:04 +010029 s.configureNetworkTopology("tap")
Maros Ondrejickadb823ed2022-12-14 16:30:04 +010030}
Adrian Villincee15aa2024-03-14 11:42:55 -040031
32var _ = Describe("TapSuite", Ordered, ContinueOnFailure, func() {
33 var s TapSuite
34 BeforeAll(func() {
35 s.SetupSuite()
36 })
37 BeforeEach(func() {
38 s.SetupTest()
39 })
40 AfterAll(func() {
41 s.TearDownSuite()
42 })
43 AfterEach(func() {
44 s.TearDownTest()
45 })
46
Adrian Villin681ff3a2024-06-07 06:45:48 -040047 for filename, tests := range tapTests {
48 for _, test := range tests {
49 test := test
50 pc := reflect.ValueOf(test).Pointer()
51 funcValue := runtime.FuncForPC(pc)
52 testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
53 It(testName, func(ctx SpecContext) {
54 s.log(testName + ": BEGIN")
55 test(&s)
56 }, SpecTimeout(suiteTimeout))
57 }
Adrian Villincee15aa2024-03-14 11:42:55 -040058 }
59})
60
61var _ = Describe("TapSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
62 var s TapSuite
63 BeforeAll(func() {
64 s.SetupSuite()
65 })
66 BeforeEach(func() {
67 s.SetupTest()
68 })
69 AfterAll(func() {
70 s.TearDownSuite()
71 })
72 AfterEach(func() {
73 s.TearDownTest()
74 })
75
Adrian Villin681ff3a2024-06-07 06:45:48 -040076 for filename, tests := range tapSoloTests {
77 for _, test := range tests {
78 test := test
79 pc := reflect.ValueOf(test).Pointer()
80 funcValue := runtime.FuncForPC(pc)
81 testName := filename + "/" + strings.Split(funcValue.Name(), ".")[2]
82 It(testName, Label("SOLO"), func(ctx SpecContext) {
83 s.log(testName + ": BEGIN")
84 test(&s)
85 }, SpecTimeout(suiteTimeout))
86 }
Adrian Villincee15aa2024-03-14 11:42:55 -040087 }
88})