From 5107d44ce96e846aa2967fd281644cbd0f1f1b49 Mon Sep 17 00:00:00 2001 From: Matthias Fasching <5011972+fasmat@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:07:59 +0000 Subject: [PATCH] Fixing flaky poet tests on windows (#5074) ## 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 - [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 --- activation/nipost_test.go | 3 ++- activation/poet_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/activation/nipost_test.go b/activation/nipost_test.go index d111cb6f07..a887044984 100644 --- a/activation/nipost_test.go +++ b/activation/nipost_test.go @@ -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 diff --git a/activation/poet_test.go b/activation/poet_test.go index 5599ed4a8b..ec83604d36 100644 --- a/activation/poet_test.go +++ b/activation/poet_test.go @@ -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)))