pycontribs / jira

Python Jira library. Development chat available on https://matrix.to/#/#pycontribs:matrix.org
https://jira.readthedocs.io
BSD 2-Clause "Simplified" License
1.95k stars 863 forks source link

Test setup needs extra docker arguments on Linux #1187

Open durka opened 2 years ago

durka commented 2 years ago

On Linux (specifically Ubuntu 20.04), docker containers don't get internet access by default. But the test container provided by this projects needs internet access to download dependencies.

The log when running it as suggested:

$ docker run --rm -dit -p 2990:2990 --name jira addono/jira-software-standalone
252e7033b059ba511d8aed16a5d6feb34f46a370a51adbd9e6bb0eecc4109c59
$ docker logs -f jira
[INFO] Project POM found
[INFO] Resolving plugin info, may take a while on the first run.
[INFO] Scanning for projects...
[INFO] Downloading from atlassian-public: https://maven.atlassian.com/repository/public/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[INFO] Downloading from atlassian-plugin-sdk: file:///usr/share/atlassian-plugin-sdk-8.2.8/repository/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/atlassian/maven/plugins/jira-maven-plugin/8.0.2/jira-maven-plugin-8.0.2.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Unresolveable build extension: Plugin com.atlassian.maven.plugins:jira-maven-plugin:8.0.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.atlassian.maven.plugins:jira-maven-plugin:jar:8.0.2 @ 
[ERROR] Unknown packaging: atlassian-plugin @ line 19, column 16
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project mygroup:myartifact:1.0.0-SNAPSHOT (/pom.xml) has 2 errors
[ERROR]     Unresolveable build extension: Plugin com.atlassian.maven.plugins:jira-maven-plugin:8.0.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.atlassian.maven.plugins:jira-maven-plugin:jar:8.0.2: Could not transfer artifact com.atlassian.maven.plugins:jira-maven-plugin:pom:8.0.2 from/to atlassian-public (https://maven.atlassian.com/repository/public): maven.atlassian.com: Name or service not known: Unknown host maven.atlassian.com: Name or service not known -> [Help 2]
[ERROR]     Unknown packaging: atlassian-plugin @ line 19, column 16
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/PluginManagerException

Supposedly the best way to fix it is to create a new bridge network as shown here:

$ docker network create --driver bridge jirabridge
$ docker run --rm -dit -p 2990:2990 --name jira --network=jirabridge addono/jira-software-standalone

But though that allows the test server to start, tox still can't reach it, which is a theme I've noticed with docker -- 99% of the time, the most straightforward solution for something simply doesn't work. The only solution I found is to use --network=host (which is discouraged since the container isn't really isolated from the host anymore, but in which case you don't need -p 2990:2990).

It still takes a really long time to start up, so you may also want to include a hint to watch the docker logs before trying to run tests, but once it downloads the ten million dependencies, tox works :confetti_ball:

adehad commented 2 years ago

Further comments on how to better document the use of the docker image:

https://github.com/pycontribs/jira/pull/1448#issuecomment-1208514608