diff --git a/t/000setup.t b/t/000setup.t index 038afb7..866a3f5 100755 --- a/t/000setup.t +++ b/t/000setup.t @@ -8,17 +8,19 @@ PLAN 14 # clean out any old containers docker rm -f go-jira-test -# start newt jira service -RUNS docker run --detach --name go-jira-test --publish 8080:8080 go-jira-test:latest +RUNS docker build . -t go-jira-test -# wait a few seconds for it to bind to port 8080 -RUNS sleep 10 +# start newt jira service, cache the users m2 directory to make startup faster +RUNS docker run --detach -v $HOME/.m2/repository:/root/.m2/repository --name go-jira-test --publish 8080:8080 go-jira-test:latest -# wait for healthchecks to pass, curl will retry 60 times over 5 min waiting -RUNS curl -q -L --retry 360 --retry-delay 1 -f -s "http://localhost:8080/rest/api/2/serverInfo?doHealthCheck=1" +echo "# Waiting for jira service to be listening on port 8080" +docker exec -i go-jira-test tail -f screenlog.0 | grep -m 1 'jira started successfully' | sed 's/^/# /' + +# wait for healthchecks to pass, curl will retry 900 times over 15 min waiting +RUNS curl -q -L --retry 900 --retry-delay 1 -f -s "http://localhost:8080/rest/api/2/serverInfo?doHealthCheck=1" # login to jira as admin user -echo "admin123" | RUNS $jira login +echo "admin" | RUNS $jira login # create gojira user RUNS $jira req -M POST /rest/api/2/user '{"name":"gojira","password":"gojira123","emailAddress":"gojira@example.com","displayName":"Go Jira"}' diff --git a/t/Dockerfile b/t/Dockerfile new file mode 100644 index 0000000..2570e14 --- /dev/null +++ b/t/Dockerfile @@ -0,0 +1,20 @@ +FROM alpine:latest +RUN apk --update add openjdk8-jre curl screen && \ + curl -s -L https://marketplace.atlassian.com/download/plugins/atlassian-plugin-sdk-tgz | tar xzf - && \ + ln -s /atlassian* /atlassian + +ENV PATH=/bin:/usr/bin:/atlassian/bin + +# Copy in the serivce and also the root .m2 settings to force cache everything. +# We also copy in /root/.java settings to prevent the dumb spam prompt from +# the atlas-run command: +# Would you like to subscribe to the Atlassian developer mailing list? (Y/y/N/n) Y: : +COPY dockerroot / +WORKDIR /jiratestservice + +EXPOSE 8080 + +# we wrap the command with screen so that the dumb atlas-run has a tty to watch. Without screen +# there is no tty so atlas-run will immediately read an EOF (aka CTRL-D) and interpret that to +# mean we want the service to begin the "graceful shutdown" and exit +CMD ["screen", "-DmL", "atlas-run", "--http-port", "8080", "--context-path", "ROOT", "--server", "localhost"] diff --git a/t/Dockerfile.inc b/t/Dockerfile.inc deleted file mode 100644 index 8d11222..0000000 --- a/t/Dockerfile.inc +++ /dev/null @@ -1,3 +0,0 @@ -RUN curl -Ls https://raw.githubusercontent.com/cptactionhank/docker-atlassian-jira-software/master/docker-entrypoint.sh -o /docker-entrypoint.sh \ - && chmod 755 /docker-entrypoint.sh \ - && echo jira.websudo.is.disabled = true >> /var/atlassian/jira/jira-config.properties \ No newline at end of file diff --git a/t/Dockerfile.pre b/t/Dockerfile.pre deleted file mode 100644 index 23cd4c6..0000000 --- a/t/Dockerfile.pre +++ /dev/null @@ -1,3 +0,0 @@ -INCLUDE MERGE -VOLUME -COPY \ - https://raw.githubusercontent.com/cptactionhank/docker-atlassian-jira-software/master/Dockerfile \ - Dockerfile.inc \ No newline at end of file diff --git a/t/README.md b/t/README.md index c361aa1..5b1b141 100644 --- a/t/README.md +++ b/t/README.md @@ -2,39 +2,6 @@ The test are written using the `osht` bash testing framework. Please read the [documentation](https://github.com/coryb/osht/blob/master/README.md) for `osht`. -## Setup -These tests assume there is a jira service running at 127.0.0.1:8080 with user "gojira" and password "gojira123". -There should also be a poweruser "admin" with password "admin123" - -The test Jira was setup following the instructions [here](https://github.com/cptactionhank/docker-atlassian-jira). - - -### build base docker image -``` -docker run --rm -i -v $(pwd):/root:ro coryb/dfpp:1.0.2 Dockerfile.pre | docker build -t go-jira-base:latest - -``` - -### Initialize container -``` -docker run --detach --name go-jira-test --publish 8080:8080 go-jira-base:latest -``` - -### create admin user -``` -open http://localhost:8080 -``` -Then follow UI workflow to create "admin" user, skip intro and project creation. - -### snapshot docker container -``` -docker commit go-jira-test go-jira-test:latest -``` - -### Destroy base container -``` -docker rm -f go-jira-test -``` - ## Running Test: From the top level of the project you can run: @@ -46,8 +13,24 @@ make prove ``` +### Running individual tests +To run a specific test you can run it directly like: +``` +./100basic.t +``` +There is a useful `-v` option to make the test more verbose and an `-a` option to casue the test to abort after the first failure. + +The tests all require the jira service to be running from the docker container, so you will have to manually run the setup script: +``` +./000setup.t +``` + +After than you can run the other tests over and over. The jira service is just a test instance started for local development. It comes with +a temporary license (I think it is 8 hours) so you will have to run the `./000setup.t` script at least once daily. + ## API Documentation: https://docs.atlassian.com/jira/REST/cloud/ +https://docs.atlassian.com/jira-software/REST/cloud ## projectTempalteKey missing documentation https://answers.atlassian.com/questions/36176301/jira-api-7.1.0-create-project diff --git a/t/dockerroot/jiratestservice/LICENSE b/t/dockerroot/jiratestservice/LICENSE new file mode 100644 index 0000000..9c6ab63 --- /dev/null +++ b/t/dockerroot/jiratestservice/LICENSE @@ -0,0 +1,6 @@ +To avoid future confusion, we recommend that you include a license with your plugin. +This file is simply a reminder. + +For a template license you can have a look at: http://www.opensource.org/licenses/ + +Atlassian releases most of its modules under the Apache2 license: http://opensource.org/licenses/Apache-2.0 diff --git a/t/dockerroot/jiratestservice/README b/t/dockerroot/jiratestservice/README new file mode 100644 index 0000000..94e6a43 --- /dev/null +++ b/t/dockerroot/jiratestservice/README @@ -0,0 +1,13 @@ +You have successfully created an Atlassian Plugin! + +Here are the SDK commands you'll use immediately: + +* atlas-run -- installs this plugin into the product and starts it on localhost +* atlas-debug -- same as atlas-run, but allows a debugger to attach at port 5005 +* atlas-cli -- after atlas-run or atlas-debug, opens a Maven command line window: + - 'pi' reinstalls the plugin into the running product instance +* atlas-help -- prints description for all commands in the SDK + +Full documentation is always available at: + +https://developer.atlassian.com/display/DOCS/Introduction+to+the+Atlassian+Plugin+SDK diff --git a/t/dockerroot/jiratestservice/pom.xml b/t/dockerroot/jiratestservice/pom.xml new file mode 100644 index 0000000..8381260 --- /dev/null +++ b/t/dockerroot/jiratestservice/pom.xml @@ -0,0 +1,185 @@ + + + + + 4.0.0 + com.netflixskunkworks + jiratestservice + 1.0 + + + Example Company + http://www.example.com/ + + + jiratestservice + This is the com.netflixskunkworks:jiratestservice plugin for Atlassian JIRA. + atlassian-plugin + + + + com.atlassian.jira + jira-api + ${jira.version} + provided + + + + + + junit + junit + 4.10 + test + + + + com.atlassian.plugin + atlassian-spring-scanner-annotation + ${atlassian.spring.scanner.version} + compile + + + + com.atlassian.plugin + atlassian-spring-scanner-runtime + ${atlassian.spring.scanner.version} + runtime + + + + javax.inject + javax.inject + 1 + provided + + + + + com.atlassian.plugins + atlassian-plugins-osgi-testrunner + ${plugin.testrunner.version} + test + + + javax.ws.rs + jsr311-api + 1.1.1 + provided + + + com.google.code.gson + gson + 2.2.2-atlassian-1 + + + + + + + + + + + com.atlassian.maven.plugins + maven-jira-plugin + ${amps.version} + true + + + + jira-software + ${jira.version} + + + ${jira.version} + ${jira.version} + + + true + false + + + + + ${atlassian.plugin.key} + + + + com.netflixskunkworks.api, + + + + + org.springframework.osgi.*;resolution:="optional", + org.eclipse.gemini.blueprint.*;resolution:="optional", + * + + + + * + + + + + + com.atlassian.plugin + atlassian-spring-scanner-maven-plugin + ${atlassian.spring.scanner.version} + + + + atlassian-spring-scanner + + process-classes + + + + + + com.atlassian.plugin + atlassian-spring-scanner-external-jar + + + false + + + + + + + 7.2.0 + 6.2.6 + 1.2.3 + 1.2.13 + + ${project.groupId}.${project.artifactId} + + 6.3.11 + + + diff --git a/t/dockerroot/root/.java/.userPrefs/.user.lock.root b/t/dockerroot/root/.java/.userPrefs/.user.lock.root new file mode 100644 index 0000000..e69de29 diff --git a/t/dockerroot/root/.java/.userPrefs/.userRootModFile.root b/t/dockerroot/root/.java/.userPrefs/.userRootModFile.root new file mode 100644 index 0000000..e69de29 diff --git a/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/prefs.xml b/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/prefs.xml new file mode 100644 index 0000000..98d2351 --- /dev/null +++ b/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/prefs.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/util/prefs.xml b/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/util/prefs.xml new file mode 100644 index 0000000..c5b0e69 --- /dev/null +++ b/t/dockerroot/root/.java/.userPrefs/com/atlassian/maven/plugins/amps/util/prefs.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/t/dockerroot/root/.m2/settings.xml b/t/dockerroot/root/.m2/settings.xml new file mode 100755 index 0000000..e92ecb3 --- /dev/null +++ b/t/dockerroot/root/.m2/settings.xml @@ -0,0 +1,77 @@ + + + + + + defaultProfile + + true + + + + + atlassian-public + https://maven.atlassian.com/repository/public + + true + never + warn + + + true + warn + never + + + + atlassian-plugin-sdk + file://${env.ATLAS_HOME}/repository + + true + never + + + true + warn + never + + + + + + + atlassian-public + https://maven.atlassian.com/repository/public + + true + warn + never + + + never + warn + + + + atlassian-plugin-sdk + file://${env.ATLAS_HOME}/repository + + true + warn + never + + + true + never + + + + + true + true + + + +