Skip to content

Jbabb docker #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions docker/Dockerfile
@@ -0,0 +1,15 @@
FROM python:2.7

RUN pip install robotframework-requests \
&& mkdir /opt/app \
&& cd /opt/app \
&& git clone https://github.internet2.edu/internet2/md-query-saml-uat.git /opt/app

WORKDIR /opt/app

# Copy in run-it script and a user included variables.py
COPY . /opt/app

CMD ["/bin/bash", "/opt/app/run-it.sh"]


102 changes: 102 additions & 0 deletions docker/README.md
@@ -0,0 +1,102 @@
# md-query-saml-uat

Docker Container for running User acceptance tests for a service implementing the SAML metadata profile of the Metadata Query Protocol.

See also:

* [Metadata Query Protocol](https://tools.ietf.org/html/draft-young-md-query-09)
* [SAML Profile for the Metadata Query Protocol](https://tools.ietf.org/html/draft-young-md-query-saml-09)


## Usage

### Build

Copy in your variables.py file to this directory. The docker build will copy in the file on build. If you do not provide one, a default example file will be used if none exists (variables.py.example from the parent directory)

Build your docker container
```
docker build . -t mdq-tests
```

### Run

Run your docker container attached to STDIN to answer the questions
```
docker run -it mdq-tests
```

Example Run
```
$ docker run -it mdq-tests
No variables.py file found. Copying example...
Do you want to exclude aggregate tests?
1) Yes -- Skip Aggregate Tests
2) No -- Do not Skip Aggregate Tests
#? 1
==============================================================================
App
==============================================================================
App.InCommon
==============================================================================
URL-Style Entity ID :: GET an entity with a URL-style entityID | PASS |
------------------------------------------------------------------------------
URN-Style Entity ID :: GET an entity with a URN-style entityID | PASS |
------------------------------------------------------------------------------
App.InCommon | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
...output truncated from readme...
==============================================================================
Output: /opt/app/output.xml
Log: /opt/app/log.html
Report: /opt/app/report.html

Container still running if you want to copy out any output files
Container name: 6f60f5b17e17
Example: docker cp 6f60f5b17e17:/opt/app/report.html \~/mdq_test_report.html
Press any key to exit...
```

### Getting Reports

If you want, you can copy out the output, log, or report after the container has run.
Alternatively, you could volume mount in those files to have them written straight out of your container.

```
touch /path/to/out.xml
docker run -it -v /path/to/out.xml:/opt/app/output.xml mdq-tests
```

### Non-interactive Mode

To run the container non-interactively:

```
docker run -it -e SKIP_AGGREGATE=YES mdq-tests
```

Set SKIP_AGGREGATE to YES to skip aggregate tests or NO to run aggregate tests. This value is case-sensitive

### docker-compose

A docker-compose file has been provided for your convenience

```
docker-compose up --build
```

Uncomment any volume mounts you want in docker-compose.yml. Set the SKIP_AGGREGATE variable to whichever value you want.


## To Do

???

## Contributing

1. Clone the repository
2. Create a new feature branch
3. Commit your changes and push to the repository
4. Create a pull request from your feature branch against the `master` branch
5. After your changes have been merged, you may delete your feature branch
13 changes: 13 additions & 0 deletions docker/docker-compose.yml
@@ -0,0 +1,13 @@
version: '3'
services:
mdq-tests:
build:
context: .
command: /bin/bash /opt/app/run-it.sh
environment:
#- SKIP_AGGREGATE=NO
- SKIP_AGGREGATE=YES
#volumes:
#- /path/to/output.xml:/opt/app/output.xml
#- /path/to/log.html:/opt/app/log.html
#- /path/to/report.html:/opt/app/report.html
40 changes: 40 additions & 0 deletions docker/run-it.sh
@@ -0,0 +1,40 @@
#!/bin/bash

YES="Yes -- Skip Aggregate Tests"
NO="No -- Do not Skip Aggregate Tests"

# Make sure there is a variables.py file. If not, copy one in
if [ ! -f /opt/app/variables.py ]; then
echo "No variables.py file found. Copying example..."
cp /opt/app/variables.py.example /opt/app/variables.py
fi

# Test for environment variable to run non-interactive
if [ -n "$SKIP_AGGREGATE" ]; then
if [ "$SKIP_AGGREGATE" == "YES" ]; then
robot --noncritical optional --exclude aggregate /opt/app
elif [ "$SKIP_AGGREGATE" == "NO" ]; then
robot --noncritical optional /opt/app
else
echo "Bad value for SKIP_AGGREGATE. Should be YES/NO. Set to $SKIP_AGGREGATE"
fi
else
# Prompt for long running tests
echo "Do you want to exclude aggregate tests?"
select yn in "$YES" "$NO"; do
case $yn in
"$YES" ) robot --noncritical optional --exclude aggregate /opt/app; break;;
"$NO" ) robot --noncritical optional /opt/app; break;;
esac
echo "Pick a number:"
done

echo ""

# Keep the container open in case someone wants to copy out the output files
echo "Container still running if you want to copy out any output files"
echo "Container name: `cat /etc/hostname`"
echo " Example: docker cp `cat /etc/hostname`:/opt/app/report.html ~/mdq_test_report.html"
read -p "Press any key to exit..."

fi