Skip to content

Commit

Permalink
test: Collect sysdump as part of artifacts
Browse files Browse the repository at this point in the history
Once we have a sysdump in the test artifacts a lot of files we collect
will become duplicates. This commit however doesn't remove all those
duplicate files from the test artifacts. Let's wait a bit and confirm
the sysdump collection always work before cleaning things up.

The sysdump collection was tested by making a test fail on purpose.

Signed-off-by: Paul Chaignon <paul@cilium.io>
  • Loading branch information
pchaigno authored and aditighag committed May 16, 2023
1 parent a555148 commit e93fdd8
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion test/helpers/kubectl.go
Expand Up @@ -3297,7 +3297,7 @@ func (kub *Kubectl) CiliumReport(commands ...string) {
defer cancel()

var wg sync.WaitGroup
wg.Add(2)
wg.Add(3)

go func() {
defer wg.Done()
Expand All @@ -3309,6 +3309,11 @@ func (kub *Kubectl) CiliumReport(commands ...string) {
kub.DumpCiliumCommandOutput(ctx, CiliumNamespace)
}()

go func() {
defer wg.Done()
kub.CollectSysdump(ctx)
}()

kub.CiliumCheckReport(ctx)

pods, err := kub.GetCiliumPodsContext(ctx, CiliumNamespace)
Expand All @@ -3335,6 +3340,24 @@ func (kub *Kubectl) CiliumReport(commands ...string) {
}
}

func (kub *Kubectl) CollectSysdump(ctx context.Context) {
testPath, err := CreateReportDirectory()
if err != nil {
log.WithError(err).Errorf("cannot create test result path '%s'", testPath)
return
}

logsPath := filepath.Join(kub.BasePath(), testPath)

// We need to get into the root directory because the CLI doesn't yet
// support absolute path. Once https://github.com/cilium/cilium-cli/pull/1552
// is installed in test VM images, we can remove this.
res := kub.ExecContext(ctx, fmt.Sprintf("cd / && cilium-cli sysdump --output-filename %s/cilium-sysdump", logsPath))
if !res.WasSuccessful() {
log.WithError(res.GetError()).Errorf("failed to collect sysdump")
}
}

// CiliumCheckReport prints a few checks on the Junit output to provide more
// context to users. The list of checks that prints are the following:
// - Number of Kubernetes and Cilium policies installed.
Expand Down

0 comments on commit e93fdd8

Please sign in to comment.