Azure / pytest-azurepipelines

Plugin for pytest that makes it simple to work with Azure Pipelines
MIT License
113 stars 35 forks source link

Docker-in-docker breaks paths to test results #40

Open egrubbs opened 5 years ago

egrubbs commented 5 years ago

The changes for detecting docker mounts (issue #24) works fine when the Azure Pipelines agent is running on the host, and the docker container is just running the tests. However, if you want to use docker-in-docker or docker siblings, the Azure Pipelines agent will be running in a docker container, so it is not expecting the file path to be converted for the host. https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/

Unfortunately, I can't just disable it with pytest --no-docker-discovery because it won't print ##vso[results.publish type=NUnit... if that option is used. https://github.com/tonybaloney/pytest-azurepipelines/blob/02e6685f8a20e52fda7242dd01f6ca1eabd368cd/pytest_azurepipelines.py#L88

You don't actually need to run two docker containers to cause the agent to fail to find the test results file. If you just use docker volume create and mount it over /azp, then apply_docker_mappings() will modify the paths.

tonybaloney commented 5 years ago

@timgates42 can you have a look at this please?

timgates42 commented 4 years ago

Sure thing will have a look (sorry for the late response)

SGStino commented 4 years ago

Any ideas for a workaround? I'm guessing it's just the path detection that's broken. If I set --no-docker-discovery, it won't update the paths and tests run fine. This means, if I were to figure out where the xmls are, i could just print those lines ##vso[results.publish.. manually?

To clarify my case (which to me, looks the same as @egrubbs's case): I run pytest tests/ --no-docker-discovery, which prints somewhere in it's output: --------------- generated xml file: /_work/2/6/s/test-output.xml ---------------

But as /_work is a mounted SAN volume, the docker detection strips it from the path, resultng in /2/6/s/test-output.xml, which the VSTS agent of course can't find anymore.

Currently I'm not using the plugin, and I'm wondering what functionality is missing because of it:

      pip install pytest 
      pytest tests/ --junitxml=$PWD/test-results.xml
      echo "##vso[results.publish type=JUnit;resultFiles=$PWD/test-results.xml]"