Make unit tests run in parallel again #814

Open
opened 2026-04-01 09:01:13 +00:00 by decentral1se · 1 comment
Owner

Following #810 there is now a coherent way to set up and teardown unit tests. However, I have had to disable parallel testing (-p 1):

Makefile Line 43 in d88b478503
@go test ./... -cover -v -p 1

We need to generate a unique $ABRA_DIR per unit test to ensure that the parallel running tests do not destroy each others test data while running. My best guess for how to make this work is:

  1. test.Setup generates a unique path /home/.abra_<uuid> and returns that path (uniqueAbraDir)
  2. this uniqueAbraDir is passed and injected into all further invocations in the test itself
  3. all test logic which references $ABRA_DIR probably needs to be converted into a function which injects uniqueAbraDir

Other options and proposals are welcome 🙏

Following https://git.coopcloud.tech/toolshed/abra/pulls/810 there is now a coherent way to set up and teardown unit tests. However, I have had to disable parallel testing (`-p 1`): https://git.coopcloud.tech/toolshed/abra/src/commit/d88b478503f969c2b6b72992bf2327d7fad6dc22/Makefile#L43 We need to generate a unique `$ABRA_DIR` per unit test to ensure that the parallel running tests do not destroy each others test data while running. My best guess for how to make this work is: 1. `test.Setup` generates a unique path `/home/.abra_<uuid>` and returns that path (`uniqueAbraDir`) 2. this `uniqueAbraDir` is passed and injected into all further invocations in the test itself 3. all test logic which references `$ABRA_DIR` probably needs to be converted into a function which injects `uniqueAbraDir` Other options and proposals are welcome 🙏
decentral1se added the
test
label 2026-04-01 09:01:13 +00:00
Author
Owner

Also, @p4u1 TestCancelGitClone seems to be flaky still but only on the CI.

pkg/git/clone_test.go Lines 60 to 84 in d88b478503
func TestCancelGitClone(t *testing.T) {
setup()
t.Cleanup(func() { teardown() })
dir := path.Join(config.RECIPES_DIR, "gitea")
os.RemoveAll(dir)
go func() {
p, err := os.FindProcess(os.Getpid())
if err != nil {
t.Fatalf("unable to find current process: %s", err)
}
p.Signal(syscall.SIGINT)
}()
gitURL := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "gitea")
if err := Clone(dir, gitURL); err == nil {
t.Fatal("cloning should have been interrupted")
}
if _, err := os.Stat(dir); err != nil && !os.IsNotExist(err) {
t.Fatal("recipe repo was not deleted")
}
}

I suspect it has something to do with the os.FindProcess(os.Getpid()) which seems to work fine locally but it varies in the CI environment. Any ideas how to stabilise that one? We could also just scrap the test if it's too awkward to maintain.

Also, @p4u1 `TestCancelGitClone` seems to be flaky still but only on the CI. https://git.coopcloud.tech/toolshed/abra/src/commit/d88b478503f969c2b6b72992bf2327d7fad6dc22/pkg/git/clone_test.go#L60-L84 I suspect it has something to do with the `os.FindProcess(os.Getpid())` which seems to work fine locally but it varies in the CI environment. Any ideas how to stabilise that one? We could also just scrap the test if it's too awkward to maintain.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#814
No description provided.