Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows per test directory for generated files on failure #10579

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is a solo-project issue but gloo is essentially private now.... is this ok?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its been done

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
Loading