Skip to content

Commit 1a2cd45

Browse files
committed
Add debug capability to F3 itests to print current progress
To aid debugging failing tests add option to print progress of all nodes at every eventual assertion, disabled by default.
1 parent d50d94b commit 1a2cd45

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

itests/f3_test.go

+16-31
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type testEnv struct {
3737
m *manifest.Manifest
3838
t *testing.T
3939
testCtx context.Context
40+
debug bool
4041
}
4142

4243
// Test that checks that F3 is enabled successfully,
@@ -100,7 +101,6 @@ func TestF3_PauseAndRebootstrap(t *testing.T) {
100101
e.ms.UpdateManifest(&cpy)
101102

102103
e.waitTillManifestChange(&cpy, 20*time.Second)
103-
e.waitTillF3Instance(0, 200*time.Second)
104104
e.waitTillF3Rebootstrap(20 * time.Second)
105105
}
106106

@@ -121,7 +121,7 @@ func TestF3_Bootstrap(t *testing.T) {
121121
e.waitTillManifestChange(&dynamicManif, 20*time.Second)
122122
e.waitTillF3Instance(2, 20*time.Second)
123123
e.waitTillManifestChange(staticManif, 20*time.Second)
124-
e.waitTillF3Instance(2, 20*time.Second)
124+
e.waitTillF3Instance(2, 200*time.Second)
125125

126126
// Try to switch back, we should ignore the manifest update.
127127
e.ms.UpdateManifest(&dynamicManif)
@@ -196,23 +196,26 @@ func (e *testEnv) waitFor(f func(n *kit.TestFullNode) bool, timeout time.Duratio
196196
e.t.Helper()
197197
require.Eventually(e.t, func() bool {
198198
e.t.Helper()
199-
for _, n := range e.minerFullNodes {
200-
if !f(n) {
199+
defer func() {
200+
if e.debug {
201201
var wg sync.WaitGroup
202-
printProgress := func(n *kit.TestFullNode) {
202+
printProgress := func(index int, n *kit.TestFullNode) {
203203
defer wg.Done()
204-
id, err := n.ID(e.testCtx)
205-
require.NoError(e.t, err)
206-
207-
progress, err := n.F3GetProgress(e.testCtx)
208-
require.NoError(e.t, err)
209-
e.t.Logf("###### %s -> %v", id, progress)
204+
if progress, err := n.F3GetProgress(e.testCtx); err != nil {
205+
e.t.Logf("Node #%d progress: err: %v", index, err)
206+
} else {
207+
e.t.Logf("Node #%d progress: %v", index, progress)
208+
}
210209
}
211-
for _, n := range e.minerFullNodes {
210+
for i, n := range e.minerFullNodes {
212211
wg.Add(1)
213-
go printProgress(n)
212+
go printProgress(i, n)
214213
}
215214
wg.Wait()
215+
}
216+
}()
217+
for _, n := range e.minerFullNodes {
218+
if !f(n) {
216219
return false
217220
}
218221
}
@@ -227,12 +230,6 @@ func (e *testEnv) waitFor(f func(n *kit.TestFullNode) bool, timeout time.Duratio
227230
// a miner. The last return value is the manifest sender for the network.
228231
func setup(t *testing.T, blocktime time.Duration) *testEnv {
229232
manif := lf3.NewManifest(BaseNetworkName+"/1", DefaultFinality, DefaultBootstrapEpoch, blocktime, cid.Undef)
230-
manif.Gpbft.Delta = 250 * time.Millisecond
231-
manif.Gpbft.DeltaBackOffExponent = 1.3
232-
manif.Gpbft.RebroadcastBackoffBase = manif.Gpbft.Delta * 2
233-
manif.Gpbft.RebroadcastBackoffMax = manif.Gpbft.RebroadcastBackoffBase * 2
234-
manif.Gpbft.RebroadcastBackoffExponent = manif.Gpbft.DeltaBackOffExponent
235-
manif.Gpbft.RebroadcastBackoffSpread = 0.2
236233

237234
return setupWithStaticManifest(t, manif, false)
238235
}
@@ -300,18 +297,6 @@ func setupWithStaticManifest(t *testing.T, manif *manifest.Manifest, testBootstr
300297
require.NoError(t, err)
301298
}
302299

303-
m.CertificateExchange.MinimumPollInterval = 200 * time.Millisecond
304-
m.CertificateExchange.MaximumPollInterval = 1 * time.Second
305-
m.Gpbft.Delta = 250 * time.Millisecond
306-
m.Gpbft.DeltaBackOffExponent = 1.3
307-
m.Gpbft.RebroadcastBackoffBase = m.Gpbft.Delta * 2
308-
m.Gpbft.RebroadcastBackoffMax = m.Gpbft.RebroadcastBackoffBase * 2
309-
m.Gpbft.RebroadcastBackoffExponent = m.Gpbft.DeltaBackOffExponent
310-
m.Gpbft.RebroadcastBackoffSpread = 0.2
311-
312-
e.ms.UpdateManifest(m)
313-
e.waitTillManifestChange(m, 30*time.Second)
314-
315300
errgrp.Go(func() error {
316301
defer func() {
317302
require.NoError(t, manifestServerHost.Close())

0 commit comments

Comments
 (0)