Skip to content

Commit

Permalink
Fixing flaky poet tests on windows (#5074)
Browse files Browse the repository at this point in the history
## Motivation
A few PoET test fail on windows because the test cleanup fails to remove temporary directories created during the test. For instance here: https://github.com/spacemeshos/go-spacemesh/actions/runs/6297761414/job/17095365624

```
=== RUN   TestAdminEvents
...
    testing.go:1225: TempDir RemoveAll cleanup: remove C:\Users\RUNNER~1\AppData\Local\Temp\TestAdminEvents2616476190\001\poet\db\proofs\000001.log: The process cannot access the file because it is being used by another process.
--- FAIL: TestAdminEvents (69.10s)
```

## Changes
- Ensure PoET Service is closed before the test ends.

## Test Plan
existing tests pass

## TODO
<!-- This section should be removed when all items are complete -->
- [x] Explain motivation or link existing issue(s)
- [x] Test changes and document test plan
- [x] Update documentation as needed
- [ ] Update [changelog](../CHANGELOG.md) as needed
  • Loading branch information
fasmat committed Sep 25, 2023
1 parent 23f65a2 commit 5107d44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion activation/nipost_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ func spawnPoet(tb testing.TB, opts ...HTTPPoetOpt) *HTTPPoetTestHarness {
eg.Wait()
})
eg.Go(func() error {
return poetProver.Service.Start(ctx)
err := poetProver.Service.Start(ctx)
return errors.Join(err, poetProver.Service.Close())
})

return poetProver
Expand Down
3 changes: 2 additions & 1 deletion activation/poet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ func TestHTTPPoet(t *testing.T) {
r.NotNil(c)

eg.Go(func() error {
return c.Service.Start(ctx)
err := c.Service.Start(ctx)
return errors.Join(err, c.Service.Close())
})

client, err := NewHTTPPoetClient(c.RestURL().String(), DefaultPoetConfig(), WithLogger(zaptest.NewLogger(t)))
Expand Down

0 comments on commit 5107d44

Please sign in to comment.