Skip to content

Commit f6b1bfb

Browse files
committed
cleanup and changelog
1 parent 92b422e commit f6b1bfb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## Fixed
8+
9+
- Cap generated test ids to 255 characters to avoid file system errors ([#35]).
10+
11+
[#35]: https://github.com/stackabletech/beku.py/pull/35
12+
713
## 0.0.10 - 2024-11-06
814

915
## Added

src/beku/kuttl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def make_test_source_with_context(
9696

9797

9898
def tid_short_hash(tid: str) -> str:
99+
"""Take the first 10 chars of the hash of the given `tid`."""
99100
return hashlib.sha256(tid.encode()).hexdigest()[:10]
100101

101102

@@ -118,6 +119,9 @@ def tid(self) -> str:
118119
"""Return the test id. Used as destination folder name for the generated test case.
119120
The result is part of a full directory name of the test case. Therefore, the OS filesystem
120121
directory separator is replaced with underscore.
122+
123+
Since the result is also used as a folder name, we restrict it's length to 255 characters.
124+
This is because some filesystems complain if the name is longer that that.
121125
"""
122126
name = re.sub(
123127
f"[{os.sep}:]",
@@ -129,9 +133,10 @@ def tid(self) -> str:
129133
)
130134
),
131135
)
132-
if len(name) > 255:
133-
hash = tid_short_hash(name)
134-
return f"{name[:244]}_{hash}"
136+
max_len = 255
137+
if len(name) > max_len:
138+
name_hash = tid_short_hash(name)
139+
return f"{name[: max_len - len(name_hash) - 1]}_{name_hash}"
135140
else:
136141
return name
137142

0 commit comments

Comments
 (0)