Skip to content

Commit

Permalink
make+itest: fix timeouts and nodelete, use arg for optional
Browse files Browse the repository at this point in the history
Instead of having three make goals for the optional itests, we use an
argument (make itest optional=true), which also makes it easier for us
to increase test and postgres harness timeouts during those optional
tests.
  • Loading branch information
guggero committed Aug 18, 2023
1 parent 3eda56f commit 80e4b78
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
14 changes: 0 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,6 @@ itest-only-trace: aperture-dir
rm -rf itest/regtest; date
$(GOTEST) ./itest -v -tags="$(ITEST_TAGS)" $(TEST_FLAGS) $(ITEST_FLAGS) -loglevel=trace -btcdexec=./btcd-itest -logdir=regtest

optional-itest: build-itest optional-itest-only

optional-itest-trace: build-itest optional-itest-only-trace

optional-itest-only: aperture-dir
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/regtest; date
$(GOTEST) ./itest -v -tags="$(ITEST_TAGS)" $(TEST_FLAGS) $(ITEST_FLAGS) -optional -btcdexec=./btcd-itest -logdir=regtest

optional-itest-only-trace: aperture-dir
@$(call print, "Running integration tests with ${backend} backend.")
rm -rf itest/regtest; date
$(GOTEST) ./itest -v -tags="$(ITEST_TAGS)" $(TEST_FLAGS) $(ITEST_FLAGS) -optional -loglevel=trace -btcdexec=./btcd-itest -logdir=regtest

aperture-dir:
ifeq ($(UNAME_S),Linux)
mkdir -p $$HOME/.aperture
Expand Down
4 changes: 2 additions & 2 deletions itest/mint_batch_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ func testMintBatch100StressTest(t *harnessTest) {
}

func testMintBatch1kStressTest(t *harnessTest) {
mintBatchStressTest(t, 1000, defaultWaitTimeout*10)
mintBatchStressTest(t, 1000, defaultWaitTimeout*20)
}

func testMintBatch10kStressTest(t *harnessTest) {
mintBatchStressTest(t, 10000, defaultWaitTimeout*100)
mintBatchStressTest(t, 10000, defaultWaitTimeout*200)
}

func mintBatchStressTest(t *harnessTest, batchSize int,
Expand Down
16 changes: 12 additions & 4 deletions itest/tapd_harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ var (
// to use when starting a tap daemon.
dbbackend = flag.String("dbbackend", "sqlite", "Set the database "+
"backend to use when starting a tap daemon.")

// postgresTimeout is a command line flag for specifying the amount of
// time to allow the postgres fixture to run in total. Needs to be
// increased for long-running tests.
postgresTimeout = flag.Duration("postgrestimeout",
tapdb.DefaultPostgresFixtureLifetime, "The amount of time to "+
"allow the postgres fixture to run in total. Needs "+
"to be increased for long-running tests.")
)

const (
Expand Down Expand Up @@ -108,11 +116,11 @@ func newTapdHarness(ht *harnessTest, cfg tapdConfig,
// We use the default settings, nothing to change for SQLite.

case tapcfg.DatabaseBackendPostgres:
fixture := tapdb.NewTestPgFixture(
ht.t, tapdb.DefaultPostgresFixtureLifetime,
)
fixture := tapdb.NewTestPgFixture(ht.t, *postgresTimeout)
ht.t.Cleanup(func() {
fixture.TearDown(ht.t)
if !*noDelete {
fixture.TearDown(ht.t)
}
})
tapCfg.DatabaseBackend = tapcfg.DatabaseBackendPostgres
tapCfg.Postgres = fixture.GetConfig()
Expand Down
9 changes: 9 additions & 0 deletions make/testing_flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ ifneq ($(nodelete),)
ITEST_FLAGS += -nodelete
endif

# Run the optional tests.
ifneq ($(optional),)
ITEST_FLAGS += -optional -postgrestimeout=240m
endif

# Run itests with specified db backend.
ifneq ($(dbbackend),)
ITEST_FLAGS += -dbbackend=$(dbbackend)
Expand Down Expand Up @@ -69,8 +74,12 @@ endif
ifneq ($(timeout),)
TEST_FLAGS += -test.timeout=$(timeout)
else
ifneq ($(optional),)
TEST_FLAGS += -test.timeout=240m
else
TEST_FLAGS += -test.timeout=60m
endif
endif

GOLIST := go list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
GOLISTCOVER := $(shell go list -tags="$(DEV_TAGS)" -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
Expand Down

0 comments on commit 80e4b78

Please sign in to comment.