mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
test: change to explicitly compiling dbcleaner on posix (#20206)
relates to: https://github.com/coder/internal/issues/1026 On POSIX systems (macOS and Linux) we compile the dbcleaner binary into a temp directory. This allows us to explicitly separate the compilation step and report the time it takes. We suspect this might be a contributing factor in the above linked flakes we see on macOS. This doesn't work on Windows because Go tests clean up the temp directory at the end of the test and the dbcleaner binary will still be executing. On Windows you cannot delete a file being executed nor the directory. However, we are not seeing any flakes on Windows so the old behavior seems to be OK.
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
@@ -39,8 +38,8 @@ func init() {
|
||||
|
||||
// startCleaner starts the cleaner in a subprocess. holdThis is an opaque reference that needs to be kept from being
|
||||
// garbage collected until we are done with all test databases (e.g. the end of the process).
|
||||
func startCleaner(ctx context.Context, parentUUID uuid.UUID, dsn string) (holdThis any, err error) {
|
||||
cmd := exec.Command("go", "run", "github.com/coder/coder/v2/coderd/database/dbtestutil/cleanercmd")
|
||||
func startCleaner(ctx context.Context, t TBSubset, parentUUID uuid.UUID, dsn string) (holdThis any, err error) {
|
||||
cmd := cleanerCmd(t)
|
||||
cmd.Env = append(os.Environ(),
|
||||
fmt.Sprintf("%s=%s", envCleanerParentUUID, parentUUID.String()),
|
||||
fmt.Sprintf("%s=%s", envCleanerDSN, dsn),
|
||||
|
||||
Reference in New Issue
Block a user