diff options
author | Adrian Villin <avillin@cisco.com> | 2024-07-17 14:38:48 +0200 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2024-07-17 16:10:29 +0000 |
commit | b69ee00c34ede374dad78f33106b39cf75087d5a (patch) | |
tree | d7f741ee85c4e9cddf973a03c3bbdf33c302fb5f /extras/hs-test/infra/hst_suite.go | |
parent | aedfd7ca3d2f5b17cfd20d4dc3919fe765adb27a (diff) |
hs-test: minor cpu pinning suite improvements
- added max cpu check for CI
- added a check for Ip4AddrAllocator: fixes a case where teardown panics
if a test crashes before allocator gets initialized
Type: test
Change-Id: Ica12366cd79d77801964dfbdc8ee7c9969b4a9ce
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/infra/hst_suite.go')
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index 41c8d29f84a..ac255b9fd44 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -47,7 +47,7 @@ type HstSuite struct { TestIds map[string]string CpuAllocator *CpuAllocatorT CpuContexts []*CpuContext - CpuPerVpp int + CpuCount int Ppid string ProcessIndex string Logger *log.Logger @@ -75,11 +75,11 @@ func (s *HstSuite) SetupSuite() { if err != nil { Fail("failed to init cpu allocator: " + fmt.Sprint(err)) } - s.CpuPerVpp = *NConfiguredCpus + s.CpuCount = *NConfiguredCpus } func (s *HstSuite) AllocateCpus() []int { - cpuCtx, err := s.CpuAllocator.Allocate(len(s.StartedContainers), s.CpuPerVpp) + cpuCtx, err := s.CpuAllocator.Allocate(len(s.StartedContainers), s.CpuCount) // using Fail instead of AssertNil to make error message more readable if err != nil { Fail(fmt.Sprint(err)) @@ -105,7 +105,10 @@ func (s *HstSuite) TearDownTest() { } s.ResetContainers() s.RemoveVolumes() - s.Ip4AddrAllocator.DeleteIpAddresses() + + if s.Ip4AddrAllocator != nil { + s.Ip4AddrAllocator.DeleteIpAddresses() + } } func (s *HstSuite) SkipIfUnconfiguring() { @@ -247,11 +250,17 @@ func (s *HstSuite) SkipIfMultiWorker(args ...any) { } } -func (s *HstSuite) SkipIfNotEnoughAvailableCpus(containerCount int, nCpus int) bool { - MaxRequestedCpu := (GinkgoParallelProcess() * containerCount * nCpus) +func (s *HstSuite) SkipIfNotEnoughAvailableCpus() bool { + var MaxRequestedCpu int + + if s.CpuAllocator.runningInCi { + MaxRequestedCpu = ((s.CpuAllocator.buildNumber + 1) * s.CpuAllocator.maxContainerCount * s.CpuCount) + } else { + MaxRequestedCpu = (GinkgoParallelProcess() * s.CpuAllocator.maxContainerCount * s.CpuCount) + } if len(s.CpuAllocator.cpus)-1 < MaxRequestedCpu { - s.Skip(fmt.Sprintf("test case cannot allocate requested cpus (%d cpus * %d containers)", nCpus, containerCount)) + s.Skip(fmt.Sprintf("test case cannot allocate requested cpus (%d cpus * %d containers)", s.CpuCount, s.CpuAllocator.maxContainerCount)) } return true |