Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -e
- set -o pipefail
- function find_in_docker_log {
- CONTAINER_NAME=$1
- TIMEOUT=$2
- SUBSTRING=$3
- COMMAND="docker logs -f $CONTAINER_NAME"
- expect -c "log_user 0; set timeout $TIMEOUT; spawn $COMMAND; expect \"$SUBSTRING\" { exit 0 } timeout { exit 1 }"
- }
- IMAGE_NAME=single_horizontal.jpg
- CONTAINER_NAME=alpr_test
- # Start the container
- docker run --name $CONTAINER_NAME -d flyingtophat/alpr
- http://127.0.0.1/$IMAGE_NAME \ # URL to poll for photo
- http://127.0.0.1/ \ # URL to post the results (not used for test)
- --verbose \ # Increase verbosity to ensure data that would be posted is printed to stdout
- --interval 1 # Small increment to speed up tests
- # Run the image with the localhost URL to poll
- docker run --name $CONTAINER_NAME -d flyingtophat/alpr http://127.0.0.1/$IMAGE_NAME http://127.0.0.1/ --verbose
- # Start web-server to serve test data
- docker exec -d $CONTAINER_NAME python -m SimpleHTTPServer 80
- # Copy test data to the working directory for Python's HTTP Server to serve
- docker cp ./test_files/$TEST_DATA_FILENAME $CONTAINER_NAME:/opt/docker-alpr/
- # Wait for license plate to appear in image's output
- find_in_docker_log $CONTAINER_NAME $TIMEOUT "WR62XDF"
- TEST_RESULT=$?
- # Report test status
- docker rm -f $CONTAINER_NAME
- if [ $TEST_RESULT == 0 ]; then
- echo "SUCCESS"
- else
- echo "FAILED"
- exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement