hs-test: container logging improvements

- Reduced the amount of error messages while obtaining container logs
  when a test fails by keeping track of started containers. NginxPerf
  tests still have those error messages, because wrk/ab containers shut
  themselves down before the test ends.

Type: test

Change-Id: I40a193345e5b46aec1834774f23aebc822eee885
Signed-off-by: Adrian Villin <avillin@cisco.com>
This commit is contained in:
Adrian Villin
2024-05-31 06:46:52 -04:00
parent d1a5161200
commit fd366b4da6
3 changed files with 18 additions and 19 deletions

View File

@ -162,7 +162,7 @@ func (c *Container) create() error {
} }
func (c *Container) allocateCpus() { func (c *Container) allocateCpus() {
c.suite.containerCount += 1 c.suite.startedContainers = append(c.suite.startedContainers, c)
c.allocatedCpus = c.suite.AllocateCpus() c.allocatedCpus = c.suite.AllocateCpus()
c.suite.log("Allocated CPUs " + fmt.Sprint(c.allocatedCpus) + " to container " + c.name) c.suite.log("Allocated CPUs " + fmt.Sprint(c.allocatedCpus) + " to container " + c.name)
} }

View File

@ -31,7 +31,7 @@ var vppSourceFileDir = flag.String("vppsrc", "", "vpp source file directory")
type HstSuite struct { type HstSuite struct {
containers map[string]*Container containers map[string]*Container
containerCount int startedContainers []*Container
volumes []string volumes []string
netConfigs []NetConfig netConfigs []NetConfig
netInterfaces map[string]*NetInterface netInterfaces map[string]*NetInterface
@ -62,7 +62,7 @@ func (s *HstSuite) SetupSuite() {
} }
func (s *HstSuite) AllocateCpus() []int { func (s *HstSuite) AllocateCpus() []int {
cpuCtx, err := s.cpuAllocator.Allocate(s.containerCount, s.cpuPerVpp) cpuCtx, err := s.cpuAllocator.Allocate(len(s.startedContainers), s.cpuPerVpp)
s.assertNil(err) s.assertNil(err)
s.AddCpuContext(cpuCtx) s.AddCpuContext(cpuCtx)
return cpuCtx.cpus return cpuCtx.cpus
@ -96,7 +96,7 @@ func (s *HstSuite) skipIfUnconfiguring() {
func (s *HstSuite) SetupTest() { func (s *HstSuite) SetupTest() {
s.log("Test Setup") s.log("Test Setup")
s.containerCount = 0 s.startedContainers = s.startedContainers[:0]
s.skipIfUnconfiguring() s.skipIfUnconfiguring()
s.setupVolumes() s.setupVolumes()
s.setupContainers() s.setupContainers()
@ -152,11 +152,11 @@ func (s *HstSuite) logVppInstance(container *Container, maxLines int) {
} }
func (s *HstSuite) hstFail() { func (s *HstSuite) hstFail() {
s.log("Containers: " + fmt.Sprint(s.containers)) for _, container := range s.startedContainers {
for _, container := range s.containers {
out, err := container.log(20) out, err := container.log(20)
if err != nil { if err != nil {
s.log("An error occured while obtaining '" + container.name + "' container logs: " + fmt.Sprint(err)) s.log("An error occured while obtaining '" + container.name + "' container logs: " + fmt.Sprint(err))
s.log("The container might not be running - check logs in " + container.getLogDirPath())
continue continue
} }
s.log("\nvvvvvvvvvvvvvvv " + s.log("\nvvvvvvvvvvvvvvv " +

View File

@ -257,7 +257,6 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
args += " -r" args += " -r"
args += " http://" + serverAddress + ":80/64B.json" args += " http://" + serverAddress + ":80/64B.json"
abCont.extraRunningArgs = args abCont.extraRunningArgs = args
time.Sleep(time.Second * 10)
o, err := abCont.combinedOutput() o, err := abCont.combinedOutput()
rps := parseString(o, "Requests per second:") rps := parseString(o, "Requests per second:")
s.log(rps) s.log(rps)