blob: 25c1e25a21569abf134a6a05ad0e8964eccbda92 [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 Villincee15aa2024-03-14 11:42:55 -040016var tapTests = []func(s *TapSuite){}
17var tapSoloTests = []func(s *TapSuite){}
18
19func registerTapTests(tests ...func(s *TapSuite)) {
20 tapTests = append(tapTests, tests...)
21}
22func registerTapSoloTests(tests ...func(s *TapSuite)) {
23 tapSoloTests = append(tapSoloTests, tests...)
24}
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
47 for _, test := range tapTests {
48 test := test
49 pc := reflect.ValueOf(test).Pointer()
50 funcValue := runtime.FuncForPC(pc)
51 It(strings.Split(funcValue.Name(), ".")[2], func(ctx SpecContext) {
52 test(&s)
53 }, SpecTimeout(time.Minute*5))
54 }
55})
56
57var _ = Describe("TapSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
58 var s TapSuite
59 BeforeAll(func() {
60 s.SetupSuite()
61 })
62 BeforeEach(func() {
63 s.SetupTest()
64 })
65 AfterAll(func() {
66 s.TearDownSuite()
67 })
68 AfterEach(func() {
69 s.TearDownTest()
70 })
71
72 for _, test := range tapSoloTests {
73 test := test
74 pc := reflect.ValueOf(test).Pointer()
75 funcValue := runtime.FuncForPC(pc)
76 It(strings.Split(funcValue.Name(), ".")[2], Label("SOLO"), func(ctx SpecContext) {
77 test(&s)
78 }, SpecTimeout(time.Minute*5))
79 }
80})