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) |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 51 | testName := strings.Split(funcValue.Name(), ".")[2] |
| 52 | It(testName, func(ctx SpecContext) { |
| 53 | s.log(testName + ": BEGIN") |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 54 | test(&s) |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 55 | }, SpecTimeout(suiteTimeout)) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 56 | } |
| 57 | }) |
| 58 | |
| 59 | var _ = 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 Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 78 | testName := strings.Split(funcValue.Name(), ".")[2] |
| 79 | It(testName, Label("SOLO"), func(ctx SpecContext) { |
| 80 | s.log(testName + ": BEGIN") |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 81 | test(&s) |
Adrian Villin | 93974e2 | 2024-05-30 06:10:59 -0400 | [diff] [blame] | 82 | }, SpecTimeout(suiteTimeout)) |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 83 | } |
| 84 | }) |