Skip to content

Mobile Trade: Tests run for too long in CI #22848

@jbazant

Description

@jbazant

All mobile trade based tests are now ignored in CI because they were causing unit tests pipeline to be stopped due the timeout.

What we know

  • module-trading tests take around 2 mins locally and around 12 minutes in CI.
  • All tests (including trading ones) run over 30 minutes. Which is causing pipeline to be canceled.
  • Pipeline often freezes for few minutes when running @suite-native/test-utils based tests for no obvious reason.
Image
  • Every @suite-native/test-utils based test allocates around 320MB of memory (caused mostly by redux-store initialization) and leaks ~32MB. This is causing cost on every other subsequent test initialization.
    • Setting workerIdleMemoryLimit: '1024MB' helps a bit, but does not resolves the problem with extremely slow pipeline.
    • Setting maxWorkers seems to not help at all.
Image
  • There is a circular dependency between state -> multiple modules -> test-utils -> state that cannot be solved, if we want to be able to test components dependant on redux. This might or might not cause some problems.
  • Setting workerIdleMemoryLimit: '1024MB' actually helped a lot and saved like 10 minutes of pipeline time, but pipeline get gradually slower recently. It seems that this slowdown is not caused by module-trading but some other changes. Possibly by upgrade of some module or nx cache?

Possible solutions

I have no idea if anything of this will help, but those are my most promising guesses so far.

Get rid of memory leaks

  • Including initStore causes memory leaks (and allocates 320MB before every tests suite)
  • Including FormatterProvider causes memory leaks (and allocates 90MB before every tests suite)

To run tests with heap usage reporting use

cd to_module_you_want_to_test
node --expose-gc ../../node_modules/.bin/jest --runInBand --logHeapUsage .

Make sure NX remote cache is not the cause of freezes

  • Try to run tests without nx cache, compare time required.

Do not use redux provider

  • initStore and @suite-native/state modules are the main eaters of memory. Not including them in tests may mitigate the problem.

Do not use testing-library/react-native

  • Maybe we should migrate to another testing framework as a extreme solution.

Use vitest instead of jest

  • vitest is known for better performance then jest, though using vitest with RN and testing-library/react-native might be not as straightforward.

Metadata

Metadata

Assignees

Labels

mobileSuite Lite issues and PRs

Type

Projects

Status

🎯 To do

Status

🏃‍♀️ In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions