Skip to content

Commit

Permalink
Allows per test directory For generated files on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-fong committed Jan 21, 2025
1 parent 4f8afe2 commit f1a2110
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NON_USER_FACING
issueLink: https://github.com/solo-io/solo-projects/issues/7634
resolvesIssue: false
description: >-
Added optional option for PreFailHandler for dumping into per test directory
10 changes: 9 additions & 1 deletion test/kubernetes/e2e/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/fs"
"os"
"path"
"path/filepath"
"runtime"
"testing"
Expand Down Expand Up @@ -235,12 +236,19 @@ func (i *TestInstallation) UninstallGlooGateway(ctx context.Context, uninstallFn
i.Assertions.EventuallyUninstallationSucceeded(ctx)
}

type PreFailHandlerOption struct {
TestName string
}

// PreFailHandler is the function that is invoked if a test in the given TestInstallation fails
func (i *TestInstallation) PreFailHandler(ctx context.Context) {
func (i *TestInstallation) PreFailHandler(ctx context.Context, options ...PreFailHandlerOption) {
// The idea here is we want to accumulate ALL information about this TestInstallation into a single directory
// That way we can upload it in CI, or inspect it locally

failureDir := i.GeneratedFiles.FailureDir
if len(options) > 0 && len(options[0].TestName) > 0 {
failureDir = path.Join(failureDir, options[0].TestName)
}
err := os.Mkdir(failureDir, os.ModePerm)
// We don't want to fail on the output directory already existing. This could occur
// if multiple tests running in the same cluster from the same installation namespace
Expand Down

0 comments on commit f1a2110

Please sign in to comment.