diff --git a/test/e2e/internal/framework/dump.go b/test/e2e/internal/framework/dump.go index 2b7c6284cf..5a7710f293 100644 --- a/test/e2e/internal/framework/dump.go +++ b/test/e2e/internal/framework/dump.go @@ -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, "____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. // @@ -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.