11#! /bin/bash
22set -e
33
4+ # NOTE(sd109): This script relies on docker host networking in order
5+ # to communicate from Gradio to ollama running on localhost. This means
6+ # it does not work on MacOS since docker host networking does not work.
7+ # It is intended to be run on a Linux machine and is primarily used in
8+ # GitHub runners as part of CI testing.
9+
410IMAGE_TAG=" ${1:- latest} "
511echo Testing image tag $IMAGE_TAG
612
@@ -41,10 +47,12 @@ test() {
4147
4248 if [[ -f $1 /test.py ]]; then
4349
44- DOCKER_NET_NAME=azimuth-llm-shared
45- if [[ ! $( docker network ls | grep $DOCKER_NET_NAME ) ]]; then
46- docker network create $DOCKER_NET_NAME
47- fi
50+ DOCKER_NET_NAME=host
51+
52+ # DOCKER_NET_NAME=azimuth-llm-shared
53+ # if [[ ! $(docker network ls | grep $DOCKER_NET_NAME) ]]; then
54+ # docker network create $DOCKER_NET_NAME
55+ # fi
4856
4957 # Ensure app image is available
5058 IMAGE=$( image_name $1 ) :$IMAGE_TAG
@@ -56,33 +64,41 @@ test() {
5664 fi
5765
5866 # Ensure Ollama instance is available
59- if [[ $( curl -s localhost:11434) == " Ollama is running" ]]; then
60- log " Using existing ollama process running on localhost:11434"
61- else
62- log " Ollama process not running - starting containerised server"
63- docker run --rm --network $DOCKER_NET_NAME -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
64- sleep 3
65- docker exec ollama ollama pull smollm2:135m
67+ if [[ $( curl -s localhost:11434) != " Ollama is running" ]]; then
68+ log " Ollama not running on localhost:11434 - aborting test"
69+ exit 1
70+ # log "Using existing ollama process running on localhost:11434"
71+ # else
72+ # log "Ollama process not running - starting containerised server"
73+ # docker run --rm --network $DOCKER_NET_NAME -d -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama
74+ # sleep 3
75+ # docker exec ollama ollama pull smollm2:135m
6676 fi
6777
6878 log " Starting Gradio app container"
6979 docker run --network $DOCKER_NET_NAME -d --name $1 -app $IMAGE
7080
7181 # Give the app time to start
72- sleep 3
82+ sleep 10
7383
7484 log " Running tests"
85+ # docker run --network $DOCKER_NET_NAME --rm \
86+ # --name $1-test-suite \
87+ # -e GRADIO_URL=http://$1-app:7860 --entrypoint python \
88+ # $IMAGE \
89+ # test.py
7590 docker run --network $DOCKER_NET_NAME --rm \
7691 --name $1 -test-suite \
77- -e GRADIO_URL=http:// $1 -app:7860 - -entrypoint python \
92+ --entrypoint python \
7893 $IMAGE \
7994 test.py
8095
8196 log " Removing containers:"
82- docker rm -f ollama $1 -app
97+ # docker rm -f ollama $1-app
98+ docker rm -f $1 -app
8399
84- log " Removing docker network:"
85- docker network rm $DOCKER_NET_NAME
100+ # log "Removing docker network:"
101+ # docker network rm $DOCKER_NET_NAME
86102
87103 echo
88104 echo " ----- Tests succeed -----"
0 commit comments