diff options
author | 2024-11-20 11:11:35 +0100 | |
---|---|---|
committer | 2024-11-22 22:24:37 +0000 | |
commit | d05f16d1247e27695a92b2e3e871ce42e94a08c4 (patch) | |
tree | 784221643c52dee29e9065603205eefd57c00147 /extras/hs-test/infra | |
parent | c990aae85a2ec456dad24944978b88f48faa8aa6 (diff) |
hs-test: added multithreaded vpp proxy tests
- if a test is named '...MTTest', 3 cpus will be allocated to vpp
- updated docs
Type: test
Change-Id: I756dfb6cdbff4368d606ca3abbc1a510cd1d6b51
Signed-off-by: Adrian Villin <avillin@cisco.com>
Diffstat (limited to 'extras/hs-test/infra')
-rw-r--r-- | extras/hs-test/infra/container.go | 2 | ||||
-rw-r--r-- | extras/hs-test/infra/cpu.go | 10 | ||||
-rw-r--r-- | extras/hs-test/infra/hst_suite.go | 40 | ||||
-rw-r--r-- | extras/hs-test/infra/suite_vpp_proxy.go | 2 |
4 files changed, 40 insertions, 14 deletions
diff --git a/extras/hs-test/infra/container.go b/extras/hs-test/infra/container.go index cc79a5cbb18..f6ccd88e118 100644 --- a/extras/hs-test/infra/container.go +++ b/extras/hs-test/infra/container.go @@ -214,7 +214,7 @@ func (c *Container) Create() error { func (c *Container) allocateCpus() { c.Suite.StartedContainers = append(c.Suite.StartedContainers, c) - c.AllocatedCpus = c.Suite.AllocateCpus() + c.AllocatedCpus = c.Suite.AllocateCpus(c.Name) c.Suite.Log("Allocated CPUs " + fmt.Sprint(c.AllocatedCpus) + " to container " + c.Name) } diff --git a/extras/hs-test/infra/cpu.go b/extras/hs-test/infra/cpu.go index 615f8a3f87d..7a29eb4a9c3 100644 --- a/extras/hs-test/infra/cpu.go +++ b/extras/hs-test/infra/cpu.go @@ -35,17 +35,17 @@ func iterateAndAppend(start int, end int, slice []int) []int { var cpuAllocator *CpuAllocatorT = nil -func (c *CpuAllocatorT) Allocate(containerCount int, nCpus int) (*CpuContext, error) { +func (c *CpuAllocatorT) Allocate(containerCount int, nCpus int, offset int) (*CpuContext, error) { var cpuCtx CpuContext // indexes, not actual cores var minCpu, maxCpu int if c.runningInCi { - minCpu = ((c.buildNumber) * c.maxContainerCount * nCpus) - maxCpu = ((c.buildNumber + 1) * c.maxContainerCount * nCpus) - 1 + minCpu = ((c.buildNumber) * c.maxContainerCount * nCpus) + offset + maxCpu = ((c.buildNumber + 1) * c.maxContainerCount * nCpus) - 1 + offset } else { - minCpu = ((GinkgoParallelProcess() - 1) * c.maxContainerCount * nCpus) - maxCpu = (GinkgoParallelProcess() * c.maxContainerCount * nCpus) - 1 + minCpu = ((GinkgoParallelProcess() - 1) * c.maxContainerCount * nCpus) + offset + maxCpu = (GinkgoParallelProcess() * c.maxContainerCount * nCpus) - 1 + offset } if len(c.cpus)-1 < maxCpu { diff --git a/extras/hs-test/infra/hst_suite.go b/extras/hs-test/infra/hst_suite.go index bf46dfdef7e..d6b4006a4e4 100644 --- a/extras/hs-test/infra/hst_suite.go +++ b/extras/hs-test/infra/hst_suite.go @@ -135,12 +135,38 @@ func (s *HstSuite) SetupSuite() { s.CpuCount = *NConfiguredCpus } -func (s *HstSuite) AllocateCpus() []int { - 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)) +func (s *HstSuite) AllocateCpus(containerName string) []int { + var cpuCtx *CpuContext + var err error + currentTestName := CurrentSpecReport().LeafNodeText + + if strings.Contains(currentTestName, "MTTest") { + prevContainerCount := s.CpuAllocator.maxContainerCount + if strings.Contains(containerName, "vpp") { + // CPU range is assigned based on the Ginkgo process index (or build number if + // running in the CI), *NConfiguredCpus and a maxContainerCount. + // maxContainerCount is set to 4 when CpuAllocator is initialized. + // 4 is not a random number - all of our suites use a maximum of 4 containers simultaneously, + // and it's also the maximum number of containers we can run with *NConfiguredCpus=2 (with CPU0=true) + // on processors with 8 threads. Currently, the CpuAllocator puts all cores into a slice, + // makes the length of the slice divisible by 4x*NConfiguredCpus, and then the minCpu and + // maxCpu (range) for each container is calculated. Then we just offset based on minCpu, + // the number of started containers and *NConfiguredCpus. This way, every container + // uses the correct CPUs, even if multiple NUMA nodes are available. + // However, because of this, if we want to assign different number of cores to different containers, + // we have to change maxContainerCount to manipulate the CPU range. Hopefully a temporary workaround. + s.CpuAllocator.maxContainerCount = 1 + cpuCtx, err = s.CpuAllocator.Allocate(1, 3, 0) + } else { + s.CpuAllocator.maxContainerCount = 3 + cpuCtx, err = s.CpuAllocator.Allocate(len(s.StartedContainers), s.CpuCount, 2) + } + s.CpuAllocator.maxContainerCount = prevContainerCount + } else { + cpuCtx, err = s.CpuAllocator.Allocate(len(s.StartedContainers), s.CpuCount, 0) } + + s.AssertNil(err) s.AddCpuContext(cpuCtx) return cpuCtx.cpus } @@ -369,8 +395,8 @@ func (s *HstSuite) SkipIfNotEnoughAvailableCpus() { if availableCpus < maxRequestedCpu { s.Skip(fmt.Sprintf("Test case cannot allocate requested cpus "+ - "(%d cpus * %d containers, %d available). Try using 'CPU0=true'", - s.CpuCount, s.CpuAllocator.maxContainerCount, availableCpus)) + "(%d containers * %d cpus, %d available). Try using 'CPU0=true'", + s.CpuAllocator.maxContainerCount, s.CpuCount, availableCpus)) } } diff --git a/extras/hs-test/infra/suite_vpp_proxy.go b/extras/hs-test/infra/suite_vpp_proxy.go index 16c6115bc23..d696109b31b 100644 --- a/extras/hs-test/infra/suite_vpp_proxy.go +++ b/extras/hs-test/infra/suite_vpp_proxy.go @@ -189,7 +189,7 @@ var _ = Describe("VppProxySuite", Ordered, ContinueOnFailure, func() { } }) -var _ = Describe("VppProxySuiteSolo", Ordered, ContinueOnFailure, func() { +var _ = Describe("VppProxySuiteSolo", Ordered, ContinueOnFailure, Serial, func() { var s VppProxySuite BeforeAll(func() { s.SetupSuite() |