Skip to content

Commit 65c2ec1

Browse files
committed
test: ensure unique /tmp/ps test dirs
1 parent b561c3b commit 65c2ec1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/setup.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ func makeTestDataDir(t *testing.T) string {
4747
shortBase := "/tmp/ps"
4848
if err := os.MkdirAll(shortBase, 0o755); err == nil {
4949
// Use process ID and timestamp for uniqueness
50-
testDir := filepath.Join(shortBase, fmt.Sprintf("%d-%d", os.Getpid(), time.Now().UnixNano()%1000000))
50+
// NOTE: Avoid using a modulus on the timestamp here. These integration
51+
// tests run in parallel in CI, and collisions would cause different test
52+
// harnesses to share the same datadir (leading to flaky failures such as
53+
// "lightningd already running? Error locking PID file").
54+
testDir := filepath.Join(shortBase, fmt.Sprintf("%d-%d", os.Getpid(), time.Now().UnixNano()))
5155
if err := os.MkdirAll(testDir, 0o755); err == nil {
5256
t.Cleanup(func() {
5357
if err := os.RemoveAll(testDir); err != nil {

0 commit comments

Comments
 (0)