Skip to content

Commit

Permalink
export logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinsonneau committed Sep 17, 2024
1 parent a97b021 commit 37daf55
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions e2e/capture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestFlowCapture(t *testing.T) {
err = os.WriteFile(path.Join("output", StartupDate+"-flowOutput"), output, 0666)
assert.Nil(t, err)

// export logs to get eBPF agents running logs
testCluster.ExportLogs()

str := string(output)
assert.NotEmpty(t, str)
// ensure script setup is fine
Expand Down Expand Up @@ -120,6 +123,9 @@ func TestPacketCapture(t *testing.T) {
err = os.WriteFile(path.Join("output", StartupDate+"-packetOutput"), output, 0666)
assert.Nil(t, err)

// export logs to get eBPF agents running logs
testCluster.ExportLogs()

str := string(output)
assert.NotEmpty(t, str)
// ensure script setup is fine
Expand Down
4 changes: 2 additions & 2 deletions e2e/cluster/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ func (k *Kind) Run(m *testing.M) {
klog.Info("starting kind setup")
code := k.testEnv.Setup(envFuncs...).
Finish(
k.exportLogs(),
k.ExportLogs(),
k.deleteNamespace(),
envfuncs.DestroyCluster(k.clusterName),
).Run(m)
klog.WithField("returnCode", code).Info("tests finished run")
}

// export logs into the e2e-logs folder of the base directory.
func (k *Kind) exportLogs() env.Func {
func (k *Kind) ExportLogs() env.Func {
return func(ctx context.Context, config *envconf.Config) (context.Context, error) {
logsDir := path.Join(k.baseDir, logsSubDir)
klog.WithField("directory", logsDir).Info("exporting cluster logs")
Expand Down

0 comments on commit 37daf55

Please sign in to comment.