summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Villin <avillin@cisco.com>2024-05-31 06:46:52 -0400
committerAdrian Villin <avillin@cisco.com>2024-05-31 06:46:52 -0400
commitfd366b4da620ad92626129ea65b5c7fc14f95c86 (patch)
tree8b1608a42335f44b3933a2fc4badc54dcfe11260
parentd1a5161200bfe424f147c0556a49492d6603b9c7 (diff)
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>
-rw-r--r--extras/hs-test/container.go2
-rw-r--r--extras/hs-test/hst_suite.go34
-rw-r--r--extras/hs-test/http_test.go1
3 files changed, 18 insertions, 19 deletions
diff --git a/extras/hs-test/container.go b/extras/hs-test/container.go
index 83693f47d78..44d84d5fe65 100644
--- a/extras/hs-test/container.go
+++ b/extras/hs-test/container.go
@@ -162,7 +162,7 @@ func (c *Container) create() error {
}
func (c *Container) allocateCpus() {
- c.suite.containerCount += 1
+ c.suite.startedContainers = append(c.suite.startedContainers, c)
c.allocatedCpus = c.suite.AllocateCpus()
c.suite.log("Allocated CPUs " + fmt.Sprint(c.allocatedCpus) + " to container " + c.name)
}
diff --git a/extras/hs-test/hst_suite.go b/extras/hs-test/hst_suite.go
index b8c0a424d58..26dcf4e5a2b 100644
--- a/extras/hs-test/hst_suite.go
+++ b/extras/hs-test/hst_suite.go
@@ -30,19 +30,19 @@ var nConfiguredCpus = flag.Int("cpus", 1, "number of CPUs assigned to vpp")
var vppSourceFileDir = flag.String("vppsrc", "", "vpp source file directory")
type HstSuite struct {
- containers map[string]*Container
- containerCount int
- volumes []string
- netConfigs []NetConfig
- netInterfaces map[string]*NetInterface
- ip4AddrAllocator *Ip4AddressAllocator
- testIds map[string]string
- cpuAllocator *CpuAllocatorT
- cpuContexts []*CpuContext
- cpuPerVpp int
- pid string
- logger *log.Logger
- logFile *os.File
+ containers map[string]*Container
+ startedContainers []*Container
+ volumes []string
+ netConfigs []NetConfig
+ netInterfaces map[string]*NetInterface
+ ip4AddrAllocator *Ip4AddressAllocator
+ testIds map[string]string
+ cpuAllocator *CpuAllocatorT
+ cpuContexts []*CpuContext
+ cpuPerVpp int
+ pid string
+ logger *log.Logger
+ logFile *os.File
}
func (s *HstSuite) SetupSuite() {
@@ -62,7 +62,7 @@ func (s *HstSuite) SetupSuite() {
}
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.AddCpuContext(cpuCtx)
return cpuCtx.cpus
@@ -96,7 +96,7 @@ func (s *HstSuite) skipIfUnconfiguring() {
func (s *HstSuite) SetupTest() {
s.log("Test Setup")
- s.containerCount = 0
+ s.startedContainers = s.startedContainers[:0]
s.skipIfUnconfiguring()
s.setupVolumes()
s.setupContainers()
@@ -152,11 +152,11 @@ func (s *HstSuite) logVppInstance(container *Container, maxLines int) {
}
func (s *HstSuite) hstFail() {
- s.log("Containers: " + fmt.Sprint(s.containers))
- for _, container := range s.containers {
+ for _, container := range s.startedContainers {
out, err := container.log(20)
if err != nil {
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
}
s.log("\nvvvvvvvvvvvvvvv " +
diff --git a/extras/hs-test/http_test.go b/extras/hs-test/http_test.go
index ba0fdb31a1a..4f7ed939d11 100644
--- a/extras/hs-test/http_test.go
+++ b/extras/hs-test/http_test.go
@@ -257,7 +257,6 @@ func runNginxPerf(s *NoTopoSuite, mode, ab_or_wrk string) error {
args += " -r"
args += " http://" + serverAddress + ":80/64B.json"
abCont.extraRunningArgs = args
- time.Sleep(time.Second * 10)
o, err := abCont.combinedOutput()
rps := parseString(o, "Requests per second:")
s.log(rps)