Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 4 | "reflect" |
| 5 | "runtime" |
| 6 | "strings" |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 7 | "time" |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 8 | |
| 9 | . "github.com/onsi/ginkgo/v2" |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 10 | ) |
| 11 | |
| 12 | type TapSuite struct { |
| 13 | HstSuite |
| 14 | } |
| 15 | |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 16 | var tapTests = []func(s *TapSuite){} |
| 17 | var tapSoloTests = []func(s *TapSuite){} |
| 18 | |
| 19 | func registerTapTests(tests ...func(s *TapSuite)) { |
| 20 | tapTests = append(tapTests, tests...) |
| 21 | } |
| 22 | func registerTapSoloTests(tests ...func(s *TapSuite)) { |
| 23 | tapSoloTests = append(tapSoloTests, tests...) |
| 24 | } |
| 25 | |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 26 | func (s *TapSuite) SetupSuite() { |
| 27 | time.Sleep(1 * time.Second) |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 28 | s.HstSuite.SetupSuite() |
Maros Ondrejicka | 2908f8c | 2023-02-02 08:58:04 +0100 | [diff] [blame] | 29 | s.configureNetworkTopology("tap") |
Maros Ondrejicka | db823ed | 2022-12-14 16:30:04 +0100 | [diff] [blame] | 30 | } |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 31 | |
| 32 | var _ = 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 | |
| 57 | var _ = 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 | }) |