Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented Aug 24, 2019

While working on #1781 (and it is all about the ultra fast tests) I noticed that the port checks take quite some time.

This change will:

  1. Make external port checks run in parallel
  2. Make internal port checks run as a single docker exec command rather than NUM_PORTS * NUM_STRATEGIES commands (3, 6, 9...)

Measurements

Even for 1 port, it is:

Before (1,443ms):

22:32:02.699 INFO  🐳 [nginx:1.9.4] - Creating container for image: nginx:1.9.4
22:32:02.875 INFO  🐳 [nginx:1.9.4] - Starting container with ID: 28a8774b9f299851811fcd8bc900910f9a6cf148c95aa88bc3b57d69f0f50939
22:32:03.562 INFO  🐳 [nginx:1.9.4] - Container nginx:1.9.4 is starting: 28a8774b9f299851811fcd8bc900910f9a6cf148c95aa88bc3b57d69f0f50939
22:32:03.583 DEBUG org.testcontainers.containers.ExecInContainerPattern - /interesting_knuth: Running "exec" command: /bin/sh -c cat /proc/net/tcp{,6} | awk '{print $2}' | grep -i :1f90
22:32:03.767 DEBUG org.testcontainers.containers.ExecInContainerPattern - /interesting_knuth: Running "exec" command: /bin/sh -c nc -vz -w 1 localhost 8080
22:32:03.950 DEBUG org.testcontainers.containers.ExecInContainerPattern - /interesting_knuth: Running "exec" command: /bin/bash -c </dev/tcp/localhost/8080
22:32:04.142 INFO  🐳 [nginx:1.9.4] - Container nginx:1.9.4 started

After (1,060ms):

22:31:27.313 INFO  🐳 [nginx:1.9.4] - Creating container for image: nginx:1.9.4
22:31:27.497 INFO  🐳 [nginx:1.9.4] - Starting container with ID: 2ab798d807aed3dc15afead9ff7aef82e6ff5f95087d9bf1866893f5587cf553
22:31:28.180 INFO  🐳 [nginx:1.9.4] - Container nginx:1.9.4 is starting: 2ab798d807aed3dc15afead9ff7aef82e6ff5f95087d9bf1866893f5587cf553
22:31:28.204 DEBUG org.testcontainers.containers.ExecInContainerPattern - /flamboyant_chaum: Running "exec" command: /bin/sh -c true &&  (cat /proc/net/tcp{,6} | awk '{print $2}' | grep -i :1f90 || nc -vz -w 1 localhost 8080 || /bin/bash -c '</dev/tcp/localhost/8080')
22:31:28.373 INFO  🐳 [nginx:1.9.4] - Container nginx:1.9.4 started

@bsideup bsideup added this to the next milestone Aug 24, 2019
@bsideup bsideup requested a review from a team August 24, 2019 20:35
@bsideup bsideup requested review from kiview and rnorth as code owners August 24, 2019 20:35
final Set<Integer> externalLivenessCheckPorts = getLivenessCheckPorts();
if (externalLivenessCheckPorts.isEmpty()) {
log.debug("Liveness check ports of {} is empty. Not waiting.", waitStrategyTarget.getContainerInfo().getName());
if (log.isDebugEnabled()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

waitStrategyTarget.getContainerInfo() will call Docker API in case of Docker Compose, and, if debug is disabled, it is unnecessary

@bsideup bsideup mentioned this pull request Aug 25, 2019
2 tasks
@bsideup bsideup merged commit 137c510 into master Aug 26, 2019
@delete-merged-branch delete-merged-branch bot deleted the faster_port_checks branch August 26, 2019 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants