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

improve docker_* test speed #53417

Merged
merged 2 commits into from
Mar 6, 2019
Merged

Conversation

felixfontein
Copy link
Contributor

SUMMARY

Trying to speed up docker_* tests. The longest are (taken from a CI run on RHEL7):

  • docker_container: ~8 minutes
  • docker_node: ~7 minutes
  • docker_swarm_service: ~5 minutes
  • docker_network: ~3.5 minutes

First try: using resolve_image: no for docker_swarm_service, which should stop registry lookups for the image (with a new enough docker daemon).

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

docker_swarm_service

@felixfontein
Copy link
Contributor Author

docker_swarm_service is now down to 2 1/2 minutes, docker_node to 30 seconds. I'll try to see whether I can improve docker_network and docker_container tomorrow.

@felixfontein
Copy link
Contributor Author

The problem with docker_network is that creating a network with IPAM config takes 15 seconds. Happens both on my local machine and on the RHEL7 CI VM. Here's a profile_tasks result for the docker_network tests:

Wednesday 06 March 2019  22:23:05 +0100 (0:00:00.019)       0:03:01.707 ******* 
=============================================================================== 
Change subnet of network with deprecated custom IPAM config ------------------------------------------------------------------------------ 16.04s
Change subnet of network with IPv6 IPAM config ------------------------------------------------------------------------------------------- 15.99s
Remove IPv6 from network with custom IPv4 and IPv6 IPAM config --------------------------------------------------------------------------- 15.99s
Change subnet, gateway, iprange and auxiliary addresses of network with custom IPAM config ----------------------------------------------- 15.94s
Create network with IPv6 and custom IPv4 IPAM config ------------------------------------------------------------------------------------- 15.88s
Create network with IPv6 IPAM config ----------------------------------------------------------------------------------------------------- 15.86s
Create network with deprecated custom IPAM config ---------------------------------------------------------------------------------------- 15.81s
Create network with custom IPAM config --------------------------------------------------------------------------------------------------- 15.80s
Create containers ------------------------------------------------------------------------------------------------------------------------- 4.14s
Make sure all networks are removed -------------------------------------------------------------------------------------------------------- 3.96s
Delete containers ------------------------------------------------------------------------------------------------------------------------- 3.11s
Cleanup ----------------------------------------------------------------------------------------------------------------------------------- 1.40s
Make sure all containers are removed ------------------------------------------------------------------------------------------------------ 1.39s
Gathering Facts --------------------------------------------------------------------------------------------------------------------------- 1.37s
swarm ------------------------------------------------------------------------------------------------------------------------------------- 1.36s
swarm ------------------------------------------------------------------------------------------------------------------------------------- 1.29s
Cleanup ----------------------------------------------------------------------------------------------------------------------------------- 1.06s
Create network ---------------------------------------------------------------------------------------------------------------------------- 1.02s
Connect network to container 3 ------------------------------------------------------------------------------------------------------------ 0.94s
Connect network to containers 1 and 2 ----------------------------------------------------------------------------------------------------- 0.92s

As you can see, by far the most time was eaten by creating networks with IPAM config. I'm not sure we can really improve this (except by removing tests).

@felixfontein felixfontein changed the title [WIP] improve docker_* test speed improve docker_* test speed Mar 6, 2019
@ansibot
Copy link
Contributor

ansibot commented Mar 6, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud community_review In order to be merged, this PR must follow the community review workflow. docker needs_triage Needs a first human triage before being processed. small_patch support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. labels Mar 6, 2019
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Mar 6, 2019
@mattclay mattclay merged commit a904bc7 into ansible:devel Mar 6, 2019
@felixfontein felixfontein deleted the docker-speed-up-tests branch March 7, 2019 05:38
@felixfontein
Copy link
Contributor Author

@WojciechowskiPiotr @dariko @hannseman @jwitko FYI: we merged this pretty quickly because a) tests were still passing, and b) tests ran a lot faster, so hopefully there won't be a timeout on the nightly coverage test this time. Please still take a look at these changes if they are OK from your point of view! If not, we can always change some of them back :)

@WojciechowskiPiotr I think the change to module_utils/docker/swarm.py should be harmless: it simply leves the last sleep away in case the node is not down; this sleep was executed before returning, and no further check was done after it, so I don't think skipping it should have any impact, except that the module feels much faster now in most situations (since it usually takes 5 seconds less time).

@dariko @hannseman @jwitko I've added resolve_image: no to almost all docker_swarm_service tests. On my machine, with docker >= 3.2, this improves runtime a lot. With docker >= 3.2 and resolve_image: yes, essentially the module looks up the image at the registry's side to determine whether it needs to be updated. Which obviously takes a bit of time, and which isn't needed during the integration tests (and which actually is counterproductive: in case the image changes during the tests, the service might be updated/restarted during some idemptence check where the tests want to make sure it's not changed). The only place where I didn't add it are the tests for resolve_image itself. I hope I didn't break anything with this.

@dariko
Copy link
Contributor

dariko commented Mar 7, 2019

@felixfontein Looks good, thank you!

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud community_review In order to be merged, this PR must follow the community review workflow. docker small_patch support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants