cekit / behave-test-steps

MIT License
0 stars 22 forks source link

Make behave tests to start containers with port-forward to run tests in non-Linux machines #51

Open ricardozanini opened 9 months ago

ricardozanini commented 9 months ago

Describe the solution you'd like As youn may know, host networking driver won't work on Windows or Mac:

The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

Hence, behave tests requiring checks like check that page is served won't work since the client won't connect to the container.

A simple workaround we could implement is adding a --port-forwarding to the command line to make Cekit start the container in a random port by default (to avoid clashing when running in parallel).

Additional context An implementation idea:

cekit --descriptor image.yaml test behave --port-forwarding :8080

Would forward a local random port to 8080.

cekit --descriptor image.yaml test behave --port-forwarding 9090:8080

Would forward the local 9090 port to 8080.

I can send a PR if you agree to implement this feature.

Cheers!

rnc commented 8 months ago

PRs are always welcome! @jmtd - you use Behave tests a lot - any comments on this please?

jmtd commented 7 months ago

I wonder if this could be a fix in https://github.com/cekit/behave-test-steps instead. Tests such as check that page is served could do a port forward in all cases, if it works on all platforms, then there'd be no need for a new cekit flag, or for the user to have any knowledge that the test suite had particular behavioural problems on different platforms.

ricardozanini commented 7 months ago

+1, @jmtd I also think that if we can add port-forward in all cases should be the way to go.

jmtd commented 7 months ago

Cool OK.

We (RH OpenJDK container images) don't make use of the check that page is served step yet; but we do use check that port {port} is open. From what I can tell, this should fail in the same scenarios as the page check. Can you confirm for me please whether that's the case?

ricardozanini commented 4 days ago

@jmtd Sorry for the long winter. Yes, it also fails since the container network is not available locally.