From 57f3a2c595049be97a1230b4f962f3bddea3e281 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 14 May 2021 10:09:02 +0200 Subject: [PATCH 1/3] Travis: decrease Windows itest parallelism The Windows virtual machine that Travis runs the integration tests on seems to be slower than the other machines. We try to increase the stability of the tests by cutting the number of parallel running suites in half. This will come at the cost of longer execution time but hopefully with a better stability in return. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3d8bd27e..97b895da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,7 +77,9 @@ jobs: - name: Btcd Integration Windows script: - - make itest-parallel windows=1 + # The windows VM seems to be slower than the other Travis VMs. We only + # run 2 test suites in parallel instead of the default 4. + - make itest-parallel windows=1 ITEST_PARALLELISM=2 os: windows before_install: - choco upgrade --no-progress -y make netcat curl findutils From 702dda6448d2f60ef93c1b52fb63bdccc50583b0 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 14 May 2021 10:09:04 +0200 Subject: [PATCH 2/3] itest: reconnect nodes more quickly on SCB restore Since there is a lot of connecting and disconnecting between nodes in the channel backup tests, we try to speed up that process by lowering the min backoff from 1 second to 50 milliseconds. We also make sure we never wait more than 1 second if it does take multple attempts. This should sum up and hopefully speed up our tests a bit. --- lntest/itest/lnd_channel_backup_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index 437b924b..cc8e526b 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -825,9 +825,12 @@ func testChanRestoreScenario(t *harnessTest, net *lntest.NetworkHarness, ctxb := context.Background() - var nodeArgs []string + nodeArgs := []string{ + "--minbackoff=50ms", + "--maxbackoff=1s", + } if testCase.anchorCommit { - nodeArgs = commitTypeAnchors.Args() + nodeArgs = append(nodeArgs, commitTypeAnchors.Args()...) } // First, we'll create a brand new node we'll use within the test. If From e4873ac87808dc034a0ee52e58ca31863c6f182d Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 14 May 2021 10:09:05 +0200 Subject: [PATCH 3/3] lntest: re-use P2P ports during SCB recovery In some rare instances it can happen that the nodes don't find each other again after one of them has been re-created and the other one has been restarted in the SCB tests. By making sure the re-created has the same P2P port again as before, we make sure they can connect to each other again successfully for executing DLP. --- lntest/harness.go | 19 ++++++++++---- lntest/itest/lnd_channel_backup_test.go | 34 +++++++++++++++++-------- lntest/itest/log_error_whitelist.txt | 4 +++ lntest/node.go | 22 ++++++++++------ 4 files changed, 56 insertions(+), 23 deletions(-) diff --git a/lntest/harness.go b/lntest/harness.go index f83e7ae6..c0303c02 100644 --- a/lntest/harness.go +++ b/lntest/harness.go @@ -32,6 +32,9 @@ import ( // DefaultCSV is the CSV delay (remotedelay) we will start our test nodes with. const DefaultCSV = 4 +// NodeOption is a function for updating a node's configuration. +type NodeOption func(*NodeConfig) + // NetworkHarness is an integration testing harness for the lightning network. // The harness by default is created with two active nodes on the network: // Alice and Bob. @@ -427,10 +430,11 @@ func (n *NetworkHarness) newNodeWithSeed(name string, extraArgs []string, // be used for regular rpc operations. func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string, password []byte, mnemonic []string, recoveryWindow int32, - chanBackups *lnrpc.ChanBackupSnapshot) (*HarnessNode, error) { + chanBackups *lnrpc.ChanBackupSnapshot, + opts ...NodeOption) (*HarnessNode, error) { node, err := n.newNode( - name, extraArgs, true, password, n.embeddedEtcd, true, + name, extraArgs, true, password, n.embeddedEtcd, true, opts..., ) if err != nil { return nil, err @@ -461,10 +465,10 @@ func (n *NetworkHarness) RestoreNodeWithSeed(name string, extraArgs []string, // can be used immediately. Otherwise, the node will require an additional // initialization phase where the wallet is either created or restored. func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool, - password []byte, embeddedEtcd, wait bool) ( + password []byte, embeddedEtcd, wait bool, opts ...NodeOption) ( *HarnessNode, error) { - node, err := newNode(NodeConfig{ + cfg := &NodeConfig{ Name: name, LogFilenamePrefix: n.currentTestCase, HasSeed: hasSeed, @@ -474,7 +478,12 @@ func (n *NetworkHarness) newNode(name string, extraArgs []string, hasSeed bool, ExtraArgs: extraArgs, FeeURL: n.feeService.url, Etcd: embeddedEtcd, - }) + } + for _, opt := range opts { + opt(cfg) + } + + node, err := newNode(*cfg) if err != nil { return nil, err } diff --git a/lntest/itest/lnd_channel_backup_test.go b/lntest/itest/lnd_channel_backup_test.go index cc8e526b..1b299e29 100644 --- a/lntest/itest/lnd_channel_backup_test.go +++ b/lntest/itest/lnd_channel_backup_test.go @@ -63,7 +63,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover // the channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -89,7 +89,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // create a new nodeRestorer that will restore // using the on-disk channels.backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -124,6 +124,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { return net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, backupSnapshot, + copyPorts(oldNode), ) }, nil }, @@ -160,6 +161,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, nil, + copyPorts(oldNode), ) if err != nil { return nil, err @@ -206,7 +208,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { return func() (*lntest.HarnessNode, error) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, - 1000, nil, + 1000, nil, copyPorts(oldNode), ) if err != nil { return nil, fmt.Errorf("unable to "+ @@ -276,7 +278,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover // the channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -326,7 +328,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the channel backup. multi := chanBackup.MultiChanBackup.MultiChanBackup return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -353,7 +355,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // create a new nodeRestorer that will restore // using the on-disk channels.backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -384,7 +386,7 @@ func testChannelBackupRestore(net *lntest.NetworkHarness, t *harnessTest) { // the node from seed, then manually recover the // channel backup. return chanRestoreViaRPC( - net, password, mnemonic, multi, + net, password, mnemonic, multi, oldNode, ) }, }, @@ -1228,9 +1230,9 @@ func createLegacyRevocationChannel(net *lntest.NetworkHarness, t *harnessTest, // chanRestoreViaRPC is a helper test method that returns a nodeRestorer // instance which will restore the target node from a password+seed, then // trigger a SCB restore using the RPC interface. -func chanRestoreViaRPC(net *lntest.NetworkHarness, - password []byte, mnemonic []string, - multi []byte) (nodeRestorer, error) { +func chanRestoreViaRPC(net *lntest.NetworkHarness, password []byte, + mnemonic []string, multi []byte, + oldNode *lntest.HarnessNode) (nodeRestorer, error) { backup := &lnrpc.RestoreChanBackupRequest_MultiChanBackup{ MultiChanBackup: multi, @@ -1241,6 +1243,7 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness, return func() (*lntest.HarnessNode, error) { newNode, err := net.RestoreNodeWithSeed( "dave", nil, password, mnemonic, 1000, nil, + copyPorts(oldNode), ) if err != nil { return nil, fmt.Errorf("unable to "+ @@ -1260,3 +1263,14 @@ func chanRestoreViaRPC(net *lntest.NetworkHarness, return newNode, nil }, nil } + +// copyPorts returns a node option function that copies the ports of an existing +// node over to the newly created one. +func copyPorts(oldNode *lntest.HarnessNode) lntest.NodeOption { + return func(cfg *lntest.NodeConfig) { + cfg.P2PPort = oldNode.Cfg.P2PPort + cfg.RPCPort = oldNode.Cfg.RPCPort + cfg.RESTPort = oldNode.Cfg.RESTPort + cfg.ProfilePort = oldNode.Cfg.ProfilePort + } +} diff --git a/lntest/itest/log_error_whitelist.txt b/lntest/itest/log_error_whitelist.txt index 665b3266..f75e7cc0 100644 --- a/lntest/itest/log_error_whitelist.txt +++ b/lntest/itest/log_error_whitelist.txt @@ -1,5 +1,7 @@