Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more waitForTxImmutability #2708

Closed
wants to merge 5 commits into from

Conversation

Anviking
Copy link
Member

Issue Number

ADP-970 / #2428

Overview

Comments

Looking at recent HWWallet failures, they seem to come from just
a few locations. So we can easily switch them out to use the more
rollback-resistent waitForTxImmutability.

```
$ ./scripts/bors-stats.rb list 2428 --search "Wallets"  --count 300 --details true | grep "Wallets.hs:"
Ê | src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:153:26:
Ê | cardano-wallet             >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
src/Test/Integration/Scenario/API/Byron/Wallets.hs:187:59:
Ê | cardano-wallet             >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
Ê | cardano-wallet             >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
cardano-wallet                 >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
cardano-wallet             >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
cardano-wallet             >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
  src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:129:18:
cardano-wallet                 >   src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:152:26:
```
@Anviking Anviking self-assigned this Jun 11, 2021
@Anviking
Copy link
Member Author

bors try

iohk-bors bot added a commit that referenced this pull request Jun 11, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 11, 2021

try

Build failed:

Failures:

  src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:155:22:
  1) CLI Specifications, SHELLEY_CLI_HW_WALLETS, HW_WALLETS_01x - Restoration from account public key preserves funds
       While verifying ApiWallet {id = ApiT {getApiT = WalletId {getWalletId = 9a8353c9dac81855ee4dc9b35eddd6d6f690adfe}}, addressPoolGap = ApiT {getApiT = AddressPoolGap {getAddressPoolGap = 20}}, balance = ApiWalletBalance {available = Quantity {getQuantity = 0}, total = Quantity {getQuantity = 0}, reward = Quantity {getQuantity = 0}}, assets = ApiWalletAssetsBalance {available = ApiT {getApiT = TokenMap (fromList [])}, total = ApiT {getApiT = TokenMap (fromList [])}}, delegation = ApiWalletDelegation {active = ApiWalletDelegationNext {status = NotDelegating, target = Nothing, changesAt = Nothing}, next = []}, name = ApiT {getApiT = WalletName {getWalletName = "Wallet from pub key"}}, passphrase = Nothing, state = ApiT {getApiT = Syncing (Quantity {getQuantity = Percentage {getPercentage = 0 % 1}})}, tip = ApiBlockReference {absoluteSlotNumber = ApiT {getApiT = SlotNo 0}, slotId = ApiSlotId {epochNumber = ApiT {getApiT = EpochNo {unEpochNo = 0}}, slotNumber = ApiT {getApiT = SlotInEpoch {unSlotInEpoch = 0}}}, time = 2021-06-11 19:10:36 UTC, block = ApiBlockInfo {height = Quantity {getQuantity = 0}}}}
[cardano-wallet.network:Warning:50681] [2021-06-11 19:25:15.64 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:50735] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:51039] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:51104] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:51094] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:50666] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:51072] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
[cardano-wallet.network:Warning:50846] [2021-06-11 19:25:15.65 UTC] Connection lost with the node. Network.Socket.recvBuf: resource vanished (Connection reset by peer)
       expected: Quantity {getQuantity = 1000000}
        but got: Quantity {getQuantity = 0}

  To rerun use: --match "/CLI Specifications/SHELLEY_CLI_HW_WALLETS/HW_WALLETS_01x - Restoration from account public key preserves funds/"

Randomized with seed 39986283

Finished in 881.1427 seconds
808 examples, 1 failure, 12 pending

@rvl
Copy link
Contributor

rvl commented Jun 13, 2021

The test that failed above is one of the tests which got the waitForTxImmutability treatment.

It raises the question of whether this fix is an effective way of fixing the flaky integration tests.

I believe that waitForTxImmutability will prevent failed assertions due to rollback, and this failure is due to another problem: as you can see, there are Connection lost with the node messages. I don't think we know the cause of these yet. Nonetheless, such errors will cause some rollback by design, and the wallet might not yet be resynced when the wait timeout passes.

The pause/resume solution should be more robust, but these changes are probably still helpful in the meantime.

@rvl rvl force-pushed the anviking/ADP-970/waitForTxImmutability-2 branch 2 times, most recently from 531586d to 88125a5 Compare June 13, 2021 02:59
Copy link
Contributor

@rvl rvl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - this should help, even if we still get failures for different reasons.

I modified the DSL verify function to include a descriptive message, and also to pretty-show the value being checked.

@@ -122,13 +124,16 @@ spec = describe "SHELLEY_CLI_HW_WALLETS" $ do
_ <- expectValidJSON (Proxy @(ApiTransaction n)) op
cp `shouldBe` ExitSuccess

eventually "Wallet balance is as expected" $ do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that it would be a shame to lose these high-level functional descriptions of that conditions are being tested.

So I have added a verifyMsg function which includes such a description.

@rvl rvl force-pushed the anviking/ADP-970/waitForTxImmutability-2 branch from a482971 to 8f8dbc8 Compare June 14, 2021 09:14
@rvl rvl mentioned this pull request Jun 14, 2021
6 tasks
-- | A convenience wrapper type for pretty-showing test values.

module Test.Utils.Pretty
( Pretty (..)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍 I didn't see that it existed before in SelectionSpec

@@ -80,6 +83,9 @@ class ToText a where
-- | Encode the specified value as text.
toText :: a -> Text

default toText :: Buildable a => a -> Text
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

@Anviking
Copy link
Member Author

Awesome, thanks @rvl!

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 14, 2021
2708: Add more waitForTxImmutability r=Anviking a=Anviking

# Issue Number

ADP-970 / #2428 


# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Replace `eventually` with `waitForTxImmutability` in exactly the locations where we've seen failures (#2428 )


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!--
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
 ✓ Finally, in the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages.
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: Rodney Lorrimar <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 14, 2021

Build failed:


src/Test/Integration/Scenario/CLI/Shelley/HWWallets.hs:154:55:
--
&nbsp; | cardano-wallet             &gt;   1) CLI Specifications, SHELLEY_CLI_HW_WALLETS, HW_WALLETS_01x - Restoration from account public key preserves funds
&nbsp; | cardano-wallet             &gt;        Verifying Wallet balance is as expected for value:
&nbsp; | cardano-wallet             &gt;          ApiWallet
&nbsp; | cardano-wallet             &gt;              { id = ApiT
&nbsp; | cardano-wallet             &gt;                  { getApiT = WalletId { getWalletId = e99d22f346094572b2222e27e2621f924a783401 } }
&nbsp; | cardano-wallet             &gt;              , addressPoolGap = ApiT
&nbsp; | cardano-wallet             &gt;                  { getApiT = AddressPoolGap
&nbsp; | cardano-wallet             &gt;                      { getAddressPoolGap = 20 }
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , balance = ApiWalletBalance
&nbsp; | cardano-wallet             &gt;                  { available = Quantity
&nbsp; | cardano-wallet             &gt;                      { getQuantity = 0 }
&nbsp; | cardano-wallet             &gt;                  , total = Quantity
&nbsp; | cardano-wallet             &gt;                      { getQuantity = 0 }
&nbsp; | cardano-wallet             &gt;                  , reward = Quantity
&nbsp; | cardano-wallet             &gt;                      { getQuantity = 0 }
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , assets = ApiWalletAssetsBalance
&nbsp; | cardano-wallet             &gt;                  { available = ApiT
&nbsp; | cardano-wallet             &gt;                      { getApiT = TokenMap
&nbsp; | cardano-wallet             &gt;                          ( fromList [] )
&nbsp; | cardano-wallet             &gt;                      }
&nbsp; | cardano-wallet             &gt;                  , total = ApiT
&nbsp; | cardano-wallet             &gt;                      { getApiT = TokenMap
&nbsp; | cardano-wallet             &gt;                          ( fromList [] )
&nbsp; | cardano-wallet             &gt;                      }
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , delegation = ApiWalletDelegation
&nbsp; | cardano-wallet             &gt;                  { active = ApiWalletDelegationNext
&nbsp; | cardano-wallet             &gt;                      { status = NotDelegating
&nbsp; | cardano-wallet             &gt;                      , target = Nothing
&nbsp; | cardano-wallet             &gt;                      , changesAt = Nothing
&nbsp; | cardano-wallet             &gt;                      }
&nbsp; | cardano-wallet             &gt;                  , next = []
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , name = ApiT
&nbsp; | cardano-wallet             &gt;                  { getApiT = WalletName
&nbsp; | cardano-wallet             &gt;                      { getWalletName = "Wallet from pub key" }
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , passphrase = Nothing
&nbsp; | cardano-wallet             &gt;              , state = ApiT
&nbsp; | cardano-wallet             &gt;                  { getApiT = Syncing
&nbsp; | cardano-wallet             &gt;                      ( Quantity
&nbsp; | cardano-wallet             &gt;                          { getQuantity = Percentage
&nbsp; | cardano-wallet             &gt;                              { getPercentage = 0 % 1 }
&nbsp; | cardano-wallet             &gt;                          }
&nbsp; | cardano-wallet             &gt;                      )
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              , tip = ApiBlockReference
&nbsp; | cardano-wallet             &gt;                  { absoluteSlotNumber = ApiT
&nbsp; | cardano-wallet             &gt;                      { getApiT = SlotNo 0 }
&nbsp; | cardano-wallet             &gt;                  , slotId = ApiSlotId
&nbsp; | cardano-wallet             &gt;                      { epochNumber = ApiT
&nbsp; | cardano-wallet             &gt;                          { getApiT = EpochNo
&nbsp; | cardano-wallet             &gt;                              { unEpochNo = 0 }
&nbsp; | cardano-wallet             &gt;                          }
&nbsp; | cardano-wallet             &gt;                      , slotNumber = ApiT
&nbsp; | cardano-wallet             &gt;                          { getApiT = SlotInEpoch
&nbsp; | cardano-wallet             &gt;                              { unSlotInEpoch = 0 }
&nbsp; | cardano-wallet             &gt;                          }
&nbsp; | cardano-wallet             &gt;                      }
&nbsp; | cardano-wallet             &gt;                  , time = 2021 - 06 - 14 12 : 14 : 42 UTC
&nbsp; | cardano-wallet             &gt;                  , block = ApiBlockInfo
&nbsp; | cardano-wallet             &gt;                      { height = Quantity
&nbsp; | cardano-wallet             &gt;                          { getQuantity = 0 }
&nbsp; | cardano-wallet             &gt;                      }
&nbsp; | cardano-wallet             &gt;                  }
&nbsp; | cardano-wallet             &gt;              }
&nbsp; |cardano-wallet             &gt;        expected: Quantity {getQuantity = 1000000}
--
&nbsp; | cardano-wallet             &gt;         but got: Quantity {getQuantity = 0}


#2428

@Anviking
Copy link
Member Author

I believe that waitForTxImmutability will prevent failed assertions due to rollback, and this failure is due to another problem:

I thought so too, and was pretty confident, but with this immediate second failure I'm starting to wonder 🤔

@Anviking
Copy link
Member Author

was pretty confident

I do recall a case where it was successful in some TX_EXTERNAL tests, but don't recall the details / care to find link now

But this might be something new...

@Anviking
Copy link
Member Author

bors try

iohk-bors bot added a commit that referenced this pull request Jun 14, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 14, 2021

try

Build failed:

@Anviking
Copy link
Member Author

bors try

iohk-bors bot added a commit that referenced this pull request Jun 16, 2021
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 16, 2021

try

Build failed:

@Anviking
Copy link
Member Author

The fact that it is failing seemingly consistently is interesting...

@Anviking Anviking closed this Jun 17, 2021
iohk-bors bot added a commit that referenced this pull request Jun 18, 2021
2724: Add Test.Utils.Pretty and verifyMsg r=Anviking a=rvl

### Issue Number

ADP-970

### Overview

- Add a more descriptive `verifyMsg` function to the integration tests.
- Move the `Pretty` helper newtype into `Test.Utils.Pretty`.

### Comments

This code was rescued from #2708.


Co-authored-by: Rodney Lorrimar <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 21, 2021
2724: Add Test.Utils.Pretty and verifyMsg r=Anviking a=rvl

### Issue Number

ADP-970

### Overview

- Add a more descriptive `verifyMsg` function to the integration tests.
- Move the `Pretty` helper newtype into `Test.Utils.Pretty`.

### Comments

This code was rescued from #2708.


Co-authored-by: Rodney Lorrimar <[email protected]>
iohk-bors bot added a commit that referenced this pull request Jun 21, 2021
2724: Add Test.Utils.Pretty and verifyMsg r=Anviking a=rvl

### Issue Number

ADP-970

### Overview

- Add a more descriptive `verifyMsg` function to the integration tests.
- Move the `Pretty` helper newtype into `Test.Utils.Pretty`.

### Comments

This code was rescued from #2708.


Co-authored-by: Rodney Lorrimar <[email protected]>
@Anviking Anviking deleted the anviking/ADP-970/waitForTxImmutability-2 branch July 7, 2021 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants