aboutsummaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-07-29 13:30:23 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-07-29 16:01:24 +0000
commitd464338c19346f8fd431e20df40d028accfdf2c9 (patch)
tree9634337e0df84a23056e7f684ab0a237cdff1a2f /extras
parentba9ea13e260fab758c3d0c87201f33748972662d (diff)
hs-test: save VPP logs with timestamps
Type: test Change-Id: Ia76d23a8d57dfb5570eaf44a9fdb3eabeba01a4d Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras')
-rw-r--r--extras/hs-test/infra/container.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/extras/hs-test/infra/container.go b/extras/hs-test/infra/container.go
index 7317499b15f..d8bddab211e 100644
--- a/extras/hs-test/infra/container.go
+++ b/extras/hs-test/infra/container.go
@@ -7,6 +7,7 @@ import (
"github.com/docker/go-units"
"os"
"os/exec"
+ "regexp"
"slices"
"strconv"
"strings"
@@ -181,9 +182,9 @@ func (c *Container) Create() error {
c.ctx,
&containerTypes.Config{
Hostname: c.Name,
- Image: c.Image,
- Env: c.getEnvVars(),
- Cmd: strings.Split(c.ExtraRunningArgs, " "),
+ Image: c.Image,
+ Env: c.getEnvVars(),
+ Cmd: strings.Split(c.ExtraRunningArgs, " "),
},
&containerTypes.HostConfig{
Resources: containerTypes.Resources{
@@ -469,7 +470,7 @@ func (c *Container) saveLogs() {
func (c *Container) log(maxLines int) (string, error) {
var logOptions containerTypes.LogsOptions
if maxLines == 0 {
- logOptions = containerTypes.LogsOptions{ShowStdout: true, ShowStderr: true, Details: true}
+ logOptions = containerTypes.LogsOptions{ShowStdout: true, ShowStderr: true, Details: true, Timestamps: true}
} else {
logOptions = containerTypes.LogsOptions{ShowStdout: true, ShowStderr: true, Details: true, Tail: strconv.Itoa(maxLines)}
}
@@ -491,12 +492,11 @@ func (c *Container) log(maxLines int) (string, error) {
stdout := stdoutBuf.String()
stderr := stderrBuf.String()
- stdout = strings.Join(strings.Split(stdout, "==> /dev/null <=="), "")
- stderr = strings.Join(strings.Split(stderr, "tail: cannot open '' for reading: No such file or directory"), "")
+ re := regexp.MustCompile("(?m)^.*==> /dev/null <==.*$[\r\n]+")
+ stdout = re.ReplaceAllString(stdout, "")
- // remove empty lines after deleting the above-mentioned messages
- stdout = strings.TrimSpace(stdout)
- stderr = strings.TrimSpace(stderr)
+ re = regexp.MustCompile("(?m)^.*tail: cannot open '' for reading: No such file or directory.*$[\r\n]+")
+ stderr = re.ReplaceAllString(stderr, "")
return stdout + stderr, err
}