testcontainers-node icon indicating copy to clipboard operation
testcontainers-node copied to clipboard

feat: one shot wait startegy

Open omerlh opened this issue 1 year ago • 6 comments
trafficstars

omerlh avatar Mar 17 '24 10:03 omerlh

Deploy Preview for testcontainers-node ready!

Name Link
Latest commit c228531674821c8ad739021c30dfaa6de3f568ad
Latest deploy log https://app.netlify.com/sites/testcontainers-node/deploys/661d33b8b3bd810007415f3e
Deploy Preview https://deploy-preview-730--testcontainers-node.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Mar 17 '24 10:03 netlify[bot]

@omerlh I think the issue is that the container runtime strategy is injected into the wait strategy before it is initialised. There is a complexity in that the runtime initialisation is lazy, and a user defines their wait strategy before any container is started. I reckon you want to get the container runtime strategy in the wait strategy itself instead of passing it in.

cristianrgreco avatar Mar 17 '24 11:03 cristianrgreco

I wasn't sure - I tried following the docs on creating a wait strategy that needs the container client, but seemed weird to me I need to pass it on the ctor. I guess you are saying I should not use StartupCheckStrategy here? Use AbstractWaitStrategy like log-wait-startegy?

omerlh avatar Mar 17 '24 12:03 omerlh

I let myself change StartupCheckStrategy to get the container runtime only when checking but it is still failing with the same error...

omerlh avatar Mar 17 '24 12:03 omerlh

I guess you are saying I should not use StartupCheckStrategy here? Use AbstractWaitStrategy like log-wait-startegy?

Yes that's right

cristianrgreco avatar Mar 18 '24 09:03 cristianrgreco

So look at my latest changes - I think I did that, but it still failing...

omerlh avatar Mar 20 '24 06:03 omerlh

Could you please add an example in the wait strategies doc?

cristianrgreco avatar Apr 04 '24 18:04 cristianrgreco

Tests are failing:

FAIL packages/testcontainers/src/wait-strategies/startup-check-strategy.test.ts
  ● Test suite failed to run

    packages/testcontainers/src/wait-strategies/startup-check-strategy.test.ts:26:8 - error TS2554: Expected 0 arguments, but got 1.

    26     })(client);
              ~~~~~~
    packages/testcontainers/src/wait-strategies/startup-check-strategy.test.ts:40:8 - error TS2554: Expected 0 arguments, but got 1.

    40     })(client);
              ~~~~~~
    packages/testcontainers/src/wait-strategies/startup-check-strategy.test.ts:58:8 - error TS2554: Expected 0 arguments, but got 1.

    58     })(client);

cristianrgreco avatar Apr 05 '24 20:04 cristianrgreco

Sure, I think I fixed both!

omerlh avatar Apr 07 '24 04:04 omerlh

Thanks for merging!

omerlh avatar Apr 16 '24 05:04 omerlh