aboutsummaryrefslogtreecommitdiffstats
path: root/extras/hs-test/hst_suite.go
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2023-04-28 10:29:47 +0200
committerFlorin Coras <florin.coras@gmail.com>2023-05-20 15:51:02 +0000
commit608d0069d98579b0635be978dea8e316f77a8841 (patch)
treeda6d23516d9b86818b577e457661c2ae58f7c776 /extras/hs-test/hst_suite.go
parent47f352710824c373f8130ba632022b47cb27505b (diff)
hs-test: support for multiple workers
Type: test Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Ie90e4b02c268bc3ca40171b03829f5686fb83162
Diffstat (limited to 'extras/hs-test/hst_suite.go')
-rw-r--r--extras/hs-test/hst_suite.go37
1 files changed, 35 insertions, 2 deletions
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go
index 042b4fe6b24..1fcffa42e00 100644
--- a/extras/hs-test/hst_suite.go
+++ b/extras/hs-test/hst_suite.go
@@ -14,13 +14,14 @@ import (
)
const (
- defaultNetworkNumber int = 1
+ DEFAULT_NETWORK_NUM int = 1
)
var isPersistent = flag.Bool("persist", false, "persists topology config")
var isVerbose = flag.Bool("verbose", false, "verbose test output")
var isUnconfiguring = flag.Bool("unconfigure", false, "remove topology")
var isVppDebug = flag.Bool("debug", false, "attach gdb to vpp")
+var nConfiguredCpus = flag.Int("cpus", 1, "number of CPUs assigned to vpp")
type HstSuite struct {
suite.Suite
@@ -30,6 +31,29 @@ type HstSuite struct {
netInterfaces map[string]*NetInterface
addresser *Addresser
testIds map[string]string
+ cpuAllocator *CpuAllocatorT
+ cpuContexts []*CpuContext
+ cpuPerVpp int
+}
+
+func (s *HstSuite) SetupSuite() {
+ var err error
+ s.cpuAllocator, err = CpuAllocator()
+ if err != nil {
+ s.FailNow("failed to init cpu allocator: %v", err)
+ }
+ s.cpuPerVpp = *nConfiguredCpus
+}
+
+func (s *HstSuite) AllocateCpus() []int {
+ cpuCtx, err := s.cpuAllocator.Allocate(s.cpuPerVpp)
+ s.assertNil(err)
+ s.AddCpuContext(cpuCtx)
+ return cpuCtx.cpus
+}
+
+func (s *HstSuite) AddCpuContext(cpuCtx *CpuContext) {
+ s.cpuContexts = append(s.cpuContexts, cpuCtx)
}
func (s *HstSuite) TearDownSuite() {
@@ -40,6 +64,9 @@ func (s *HstSuite) TearDownTest() {
if *isPersistent {
return
}
+ for _, c := range s.cpuContexts {
+ c.Release()
+ }
s.resetContainers()
s.removeVolumes()
}
@@ -66,7 +93,7 @@ func (s *HstSuite) setupVolumes() {
func (s *HstSuite) setupContainers() {
for _, container := range s.containers {
- if container.isOptional == false {
+ if !container.isOptional {
container.run()
}
}
@@ -130,6 +157,12 @@ func (s *HstSuite) skip(args ...any) {
s.T().SkipNow()
}
+func (s *HstSuite) SkipIfMultiWorker(args ...any) {
+ if *nConfiguredCpus > 1 {
+ s.skip("test case not supported with multiple vpp workers")
+ }
+}
+
func (s *HstSuite) resetContainers() {
for _, container := range s.containers {
container.stop()