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

Flaky E2E tests #2065

Open
lidel opened this issue Nov 15, 2022 · 2 comments
Open

Flaky E2E tests #2065

lidel opened this issue Nov 15, 2022 · 2 comments
Labels
kind/bug A bug in existing code (including security flaws) kind/maintenance Work required to avoid breaking changes or harm to project's status quo kind/test Testing work P1 High: Likely tackled by core team if no one steps up

Comments

@lidel
Copy link
Member

lidel commented Nov 15, 2022

This is a tracking issue for removing flakiness of E2E tests, as this impacts other repos.

I've been running tests locally in a loop until they fail (while npm test; do :; done) and identified 4 types of failures.

Pain points

(1)

[test:e2e  ]
[test:e2e  ]
[test:e2e  ] Running 31 tests using 4 workers
[test:e2e  ]
[test:e2e  ] Error: ENOENT: no such file or directory, open '/home/lidel/project/ipfs-webui/test/e2e/setup/ipfs-backend.json'
[test:e2e  ]
[test:e2e  ]    at setup/global-setup.js:7
[test:e2e  ]
[test:e2e  ]    5 | module.exports = async config => {
[test:e2e  ]    6 |   // Read and expose backend info in env availables inside of test() blocks
[test:e2e  ] >  7 |   const { rpcAddr, id, agentVersion } = JSON.parse(fs.readFileSync(path.join(__dirname, 'ipfs-backend.json')))
[test:e2e  ]      |                                                       ^
[test:e2e  ]    8 |   process.env.IPFS_RPC_ADDR = rpcAddr
[test:e2e  ]    9 |   process.env.IPFS_RPC_ID = id
[test:e2e  ]   10 |   process.env.IPFS_RPC_VERSION = agentVersion
[test:e2e  ]
[test:e2e  ]     at module.exports (/home/lidel/project/ipfs-webui/test/e2e/setup/global-setup.js:7:55)
[test:e2e  ]
[test:e2e  ]
[test:e2e  ]   31 skipped
[test:e2e  ]   1 error was not a part of any test, see above for details

(2)

[test:e2e  ]   ✘  5 ipns.test.js:28:5 › IPNS publishing › Settings screen › should list IPNS keys (30s)
[test:e2e  ]
[test:e2e  ]
[test:e2e  ]   1) ipns.test.js:28:5 › IPNS publishing › Settings screen › should list IPNS keys =================
[test:e2e  ]
[test:e2e  ]     Test timeout of 30000ms exceeded.
[test:e2e  ]
[test:e2e  ]     page.waitForSelector: Target closed
[test:e2e  ]     =========================== logs ===========================
[test:e2e  ]     waiting for selector "text=k51qzi5uqu5dlgkafkat85zoo7y2sfn66e9288hnvhiy7foqpics2zm8g19lm9" to be visible
[test:e2e  ]     ============================================================
[test:e2e  ]
[test:e2e  ]       135 |   for (const { id, name } of await ipfs.key.list()) {
[test:e2e  ]       136 |     if (name.startsWith('rm-key-test-')) continue // avoid race with removal tests
[test:e2e  ]     > 137 |     await page.waitForSelector(`text=${id}`)
[test:e2e  ]           |                ^
[test:e2e  ]       138 |     await page.waitForSelector(`text=${name}`)
[test:e2e  ]       139 |   }
[test:e2e  ]       140 | }
[test:e2e  ]
[test:e2e  ]         at waitForIPNSKeyList (/home/lidel/project/ipfs-webui/test/e2e/ipns.test.js:137:16)
[test:e2e  ]         at /home/lidel/project/ipfs-webui/test/e2e/ipns.test.js:30:7
[test:e2e  ]
[test:e2e  ]     Pending operations:
[test:e2e  ]       - page.waitForSelector at test/e2e/ipns.test.js:137:16
[test:e2e  ]
[test:e2e  ]
[test:e2e  ]
[test:e2e  ]   1 failed
[test:e2e  ]     ipns.test.js:28:5 › IPNS publishing › Settings screen › should list IPNS keys ==================
[test:e2e  ]   30 passed (38s)

(3)

4x more often than the rest

[test:unit ] FAIL src/bundles/peer-bandwidth.test.js
[test:unit ]   ● should sync added and removed peers
[test:unit ]
[test:unit ]     expect(received).toBe(expected) // Object.is equality
[test:unit ]
[test:unit ]     Expected: 149
[test:unit ]     Received: 97
[test:unit ]
[test:unit ]       161 |   bwPeers = store.selectPeerBandwidthPeers()
[test:unit ]       162 |
[test:unit ]     > 163 |   expect(bwPeers.length).toBe(nextPeers.length)
[test:unit ]           |                          ^
[test:unit ]       164 |
[test:unit ]       165 |   bwPeers.forEach(({ id }) => {
[test:unit ]       166 |     expect(nextPeers.some(p => p.peer === id)).toBe(true)
[test:unit ]
[test:unit ]       at Object.<anonymous> (src/bundles/peer-bandwidth.test.js:163:26)
[test:unit ]
[test:unit ] PASS src/bundles/node-bandwidth-chart.test.js
[test:unit ] PASS src/bundles/peer-locations.test.js
[test:unit ] PASS src/lib/dnd-backend.test.js
[test:unit ] PASS src/bundles/analytics.test.js
[test:unit ] PASS src/bundles/notify.test.js
[test:unit ] PASS src/bundles/files.test.js
[test:unit ] PASS src/lib/files.test.js
[test:unit ] PASS src/loader/AsyncRequestLoader.test.js
[test:unit ] PASS src/lib/count-dirs.test.js
[test:unit ]
[test:unit ] Test Suites: 1 failed, 1 skipped, 10 passed, 11 of 12 total
[test:unit ] Tests:       1 failed, 4 skipped, 59 passed, 64 total
[test:unit ] Snapshots:   0 total
[test:unit ] Time:        6.553 s
[test:unit ] Ran all test suites.
[test:e2e  ] [WebServer] (node:5070) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
[test:e2e  ] (Use `node --trace-deprecation ...` to show where the warning was created)

(4)

[test:unit ] Test Suites: 1 skipped, 11 passed, 11 of 12 total
[test:unit ] Tests:       4 skipped, 60 passed, 64 total
[test:unit ] Snapshots:   0 total
[test:unit ] Time:        7.077 s
[test:unit ] Ran all test suites.
[test:e2e  ] [WebServer] (node:6795) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
[test:e2e  ] (Use `node --trace-deprecation ...` to show where the warning was created)
  190.55s user 15.34s system 211% cpu 1:37.42 total
[test:unit ] PASS src/bundles/peer-bandwidth.test.js
[test:unit ] PASS src/bundles/identity.test.js
[test:unit ] PASS src/bundles/node-bandwidth-chart.test.js
[test:unit ] PASS src/bundles/peer-locations.test.js
[test:unit ] PASS src/bundles/analytics.test.js
[test:unit ] PASS src/loader/AsyncRequestLoader.test.js
[test:unit ] PASS src/bundles/notify.test.js
[test:unit ] PASS src/bundles/files.test.js
[test:unit ] PASS src/lib/files.test.js
[test:unit ] PASS src/lib/dnd-backend.test.js
[test:unit ] PASS src/lib/count-dirs.test.js
[test:unit ]
[test:unit ] Test Suites: 1 skipped, 11 passed, 11 of 12 total
[test:unit ] Tests:       4 skipped, 60 passed, 64 total
[test:unit ] Snapshots:   0 total
[test:unit ] Time:        7.163 s
[test:unit ] Ran all test suites.
[test:e2e  ] [WebServer] (node:10041) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
[test:e2e  ] (Use `node --trace-deprecation ...` to show where the warning was created)
ERROR: "test:e2e" exited with 1.
@lidel lidel added kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up kind/test Testing work kind/maintenance Work required to avoid breaking changes or harm to project's status quo labels Nov 15, 2022
@lidel
Copy link
Member Author

lidel commented Nov 15, 2022

I'll try to bump playwright libs and re-run while npm test; do :; done see if it improves things or if the above problems still appear.

@lidel
Copy link
Member Author

lidel commented Nov 15, 2022

Seems that #2066 stabilized test:e2e run via playwright, but we still have flaky test:unit tests:

[test:unit ] FAIL src/bundles/peer-bandwidth.test.js
[test:unit ]   ● should get bandwidth for added peers
[test:unit ]
[test:unit ]     expect(received).toBeTruthy()
[test:unit ]
[test:unit ]     Received: undefined
[test:unit ]
[test:unit ]       201 |   expect(bwPeers.length).toBe(peers.length)
[test:unit ]       202 |
[test:unit ]     > 203 |   bwPeers.forEach(({ bw }) => expect(bw).toBeTruthy())
[test:unit ]           |                                          ^
[test:unit ]       204 | })
[test:unit ]       205 |
[test:unit ]       206 | it('should periodically update bandwidth for peers', async () => {
[test:unit ]
[test:unit ]       at forEach (src/bundles/peer-bandwidth.test.js:203:42)
[test:unit ]           at Array.forEach (<anonymous>)
[test:unit ]       at Object.<anonymous> (src/bundles/peer-bandwidth.test.js:203:11)
[test:unit ]

The underlying problem with unit tests is that they don't do smart await until specific data is available, they just sleep for a specified amount:

// Wait for all the bandwdith stats to come in
await sleep(30)

lidel added a commit that referenced this issue Nov 15, 2022
This is a quick band-aid to stop sleep from sometimes failing on CI
#2065 (comment)
lidel added a commit that referenced this issue Nov 15, 2022
This is a quick band-aid to stop sleep from sometimes failing on CI
#2065 (comment)
ipfs-gui-bot pushed a commit that referenced this issue Dec 9, 2022
## [2.21.0](v2.20.0...v2.21.0) (2022-12-09)

 CID `bafybeiequgo72mrvuml56j4gk7crewig5bavumrrzhkqbim6b3s2yqi7ty`

 ---

### Features

* use direct links to download all files ([#1894](#1894)) ([d1bcbbf](d1bcbbf))

### Bug Fixes

* support /quic-v1 ([#2073](#2073)) ([04eb7b3](04eb7b3))

### Trivial Changes

* bump playwright deps ([#2066](#2066)) ([f138960](f138960))
* **ci:** fix flaky unit test ([#2068](#2068)) ([bd038cd](bd038cd)), closes [/github.com//issues/2065#issuecomment-1315933342](https://github.com/ipfs//github.com/ipfs/ipfs-webui/issues/2065/issues/issuecomment-1315933342)
* Pull transifex translations ([#2069](#2069)) ([36f3641](36f3641))
* revert [#2032](#2032) ([#2064](#2064)) ([9473d7d](9473d7d)), closes [/github.com//pull/2032#issuecomment-1278928440](https://github.com/ipfs//github.com/ipfs/ipfs-webui/pull/2032/issues/issuecomment-1278928440)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) kind/maintenance Work required to avoid breaking changes or harm to project's status quo kind/test Testing work P1 High: Likely tackled by core team if no one steps up
Projects
No open projects
Status: Needs Grooming
Development

No branches or pull requests

1 participant