blob: ebf0f9b3cbc288a7d2d45ff3937334ec52ff5fa4 [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)
Adrian Villin637edda2024-05-06 06:55:34 -040051 testName := strings.Split(funcValue.Name(), ".")[2]
52 It(testName, func(ctx SpecContext) {
53 s.log(testName + ": BEGIN")
Adrian Villincee15aa2024-03-14 11:42:55 -040054 test(&s)
55 }, SpecTimeout(time.Minute*5))
56 }
57})
58
59var _ = Describe("TapSuiteSolo", Ordered, ContinueOnFailure, Serial, func() {
60 var s TapSuite
61 BeforeAll(func() {
62 s.SetupSuite()
63 })
64 BeforeEach(func() {
65 s.SetupTest()
66 })
67 AfterAll(func() {
68 s.TearDownSuite()
69 })
70 AfterEach(func() {
71 s.TearDownTest()
72 })
73
74 for _, test := range tapSoloTests {
75 test := test
76 pc := reflect.ValueOf(test).Pointer()
77 funcValue := runtime.FuncForPC(pc)
Adrian Villin637edda2024-05-06 06:55:34 -040078 testName := strings.Split(funcValue.Name(), ".")[2]
79 It(testName, Label("SOLO"), func(ctx SpecContext) {
80 s.log(testName + ": BEGIN")
Adrian Villincee15aa2024-03-14 11:42:55 -040081 test(&s)
82 }, SpecTimeout(time.Minute*5))
83 }
84})