hs-test: add tests repeat option
[vpp.git] / extras / hs-test / suite_tap_test.go
1 package main
2
3 import (
4         "reflect"
5         "runtime"
6         "strings"
7         "time"
8
9         . "github.com/onsi/ginkgo/v2"
10 )
11
12 type TapSuite struct {
13         HstSuite
14 }
15
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
26 func (s *TapSuite) SetupSuite() {
27         time.Sleep(1 * time.Second)
28         s.HstSuite.SetupSuite()
29         s.configureNetworkTopology("tap")
30 }
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 })