Skip to content
Open
Changes from all commits
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
23 changes: 21 additions & 2 deletions test/e2e/internal/framework/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,25 @@ import (
"github.com/deckhouse/virtualization/test/e2e/internal/kubectl"
)

const d8vContainerPrefix = "d8v"
const (
d8vContainerPrefix = "d8v"
// maxTestNameLen is the maximum length of the test name portion in a dump filename.
// Linux filesystems (ext4/xfs) limit filenames to 255 bytes. We reserve ~70 bytes
// for the "e2e_failed__" prefix, "__<namespace>__events.yaml" suffix, and directory path.
maxTestNameLen = 180
ellipsis = "..."
)

// truncateTestName shortens s to at most maxLen bytes while keeping the text
// human-readable: it preserves a prefix and a suffix separated by ellipsis.
func truncateTestName(s string, maxLen int) string {
if len(s) <= maxLen {
return s
}
available := maxLen - len(ellipsis)
half := available / 2
return s[:half] + ellipsis + s[len(s)-(available-half):]
}

// SaveTestCaseDump dump some resources, logs and descriptions that may help in further diagnostic.
//
Expand Down Expand Up @@ -72,7 +90,8 @@ func GetFormattedTestCaseFullText() string {
"`", "",
"'", "",
)
return replacer.Replace(strings.ToLower(CurrentSpecReport().FullText()))
result := replacer.Replace(strings.ToLower(CurrentSpecReport().FullText()))
return truncateTestName(result, maxTestNameLen)
}

// GetTMPDir returns the temporary directory used for the test case resource dump.
Expand Down
Loading