Skip to content

Commit

Permalink
itest: use correct testing struct for t.Cleanup()
Browse files Browse the repository at this point in the history
It turns out that we used ht.t for the postgres harness, so the
ht.t.Cleanup() would only be triggered at the very end of the whole
integration test run and not after each individual test case.
This lead to many Postgres containers being created which the GitHub CI
didn't like (it killed our process).
By passing in the sub-test specific testing struct, we avoid this issue.
  • Loading branch information
guggero committed Sep 7, 2023
1 parent 99ef347 commit 92351ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions itest/tapd_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"path/filepath"
"sync"
"testing"
"time"

"github.com/btcsuite/btcd/chaincfg"
Expand Down Expand Up @@ -78,7 +79,7 @@ type tapdConfig struct {

// newTapdHarness creates a new tapd server harness with the given
// configuration.
func newTapdHarness(ht *harnessTest, cfg tapdConfig,
func newTapdHarness(t *testing.T, ht *harnessTest, cfg tapdConfig,
proofCourier proof.CourierHarness,
proofSendBackoffCfg *proof.BackoffCfg,
proofReceiverAckTimeout *time.Duration) (*tapdHarness, error) {
Expand Down Expand Up @@ -117,11 +118,11 @@ func newTapdHarness(ht *harnessTest, cfg tapdConfig,

case tapcfg.DatabaseBackendPostgres:
fixture := tapdb.NewTestPgFixture(
ht.t, *postgresTimeout, !*noDelete,
t, *postgresTimeout, !*noDelete,
)
ht.t.Cleanup(func() {
t.Cleanup(func() {
if !*noDelete {
fixture.TearDown(ht.t)
fixture.TearDown(t)
}
})
tapCfg.DatabaseBackend = tapcfg.DatabaseBackendPostgres
Expand Down
2 changes: 1 addition & 1 deletion itest/test_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func setupTapdHarness(t *testing.T, ht *harnessTest,
}

tapdHarness, err := newTapdHarness(
ht, tapdConfig{
t, ht, tapdConfig{
NetParams: harnessNetParams,
LndNode: node,
}, selectedProofCourier,
Expand Down

0 comments on commit 92351ac

Please sign in to comment.