Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6baa3c

Browse files
authored
fix: stop running tests that exec sh scripts in parallel (#11834)
Ok, so my last attempt at a fix here failedhttps://github.com/coder/coder/actions/runs/7666229961/job/20893608286I have a new theory: it's not the `terraform` binary that's busy, it's actually `fake_cancel.sh` and it gets marked busy when we `exec` it from the script we write.Use of `exec` also replaces the executing code in place, rather than starting a new process/shell, so that's why the error we get says `terraform` is busy.
1 parent0ba035a commitd6baa3c

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

‎provisioner/terraform/provision_test.go

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"runtime"
1515
"sort"
1616
"strings"
17-
"syscall"
1817
"testing"
1918
"time"
2019

@@ -126,8 +125,10 @@ func sendApply(sess proto.DRPCProvisioner_SessionClient, transition proto.Worksp
126125
}}})
127126
}
128127

128+
// below we exec fake_cancel.sh, which causes the kernel to execute it, and if more than
129+
// one process tries to do this simultaneously, it can cause "text file busy"
130+
// nolint: paralleltest
129131
funcTestProvision_Cancel(t*testing.T) {
130-
t.Parallel()
131132
ifruntime.GOOS=="windows" {
132133
t.Skip("This test uses interrupts and is not supported on Windows")
133134
}
@@ -158,24 +159,16 @@ func TestProvision_Cancel(t *testing.T) {
158159
}
159160
for_,tt:=rangetests {
160161
tt:=tt
162+
// below we exec fake_cancel.sh, which causes the kernel to execute it, and if more than
163+
// one process tries to do this, it can cause "text file busy"
164+
// nolint: paralleltest
161165
t.Run(tt.name,func(t*testing.T) {
162-
t.Parallel()
163-
164166
dir:=t.TempDir()
165167
binPath:=filepath.Join(dir,"terraform")
166168

167169
// Example: exec /path/to/terrafork_fake_cancel.sh 1.2.1 apply "$@"
168170
content:=fmt.Sprintf("#!/bin/sh\nexec %q %s %s\"$@\"\n",fakeBin,terraform.TerraformVersion.String(),tt.mode)
169-
170-
// golang's standard OS library can sometimes leave the file descriptor open even after
171-
// "Closing" the file (which can then lead to a "text file busy" error, so we bypass this
172-
// and use syscall directly).
173-
fd,err:=syscall.Open(binPath,syscall.O_WRONLY|syscall.O_CREAT,0o755)
174-
require.NoError(t,err)
175-
n,err:=syscall.Write(fd, []byte(content))
176-
require.NoError(t,err)
177-
require.Equal(t,len(content),n)
178-
err=syscall.Close(fd)
171+
err:=os.WriteFile(binPath, []byte(content),0o755)//#nosec
179172
require.NoError(t,err)
180173
t.Logf("wrote fake terraform script to %s",binPath)
181174

@@ -228,8 +221,10 @@ func TestProvision_Cancel(t *testing.T) {
228221
}
229222
}
230223

224+
// below we exec fake_cancel_hang.sh, which causes the kernel to execute it, and if more than
225+
// one process tries to do this, it can cause "text file busy"
226+
// nolint: paralleltest
231227
funcTestProvision_CancelTimeout(t*testing.T) {
232-
t.Parallel()
233228
ifruntime.GOOS=="windows" {
234229
t.Skip("This test uses interrupts and is not supported on Windows")
235230
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp