Skip to content

Commit e064dac

Browse files
rdimitrovLuke Hinds
authored and
Luke Hinds
committed
Enable the integration tests for Ollama (#802)
* Add integration tests for Ollama Signed-off-by: Radoslav Dimitrov <[email protected]> * Set the CODEGATE_OLLAMA_URL explicitly Signed-off-by: Radoslav Dimitrov <[email protected]> --------- Signed-off-by: Radoslav Dimitrov <[email protected]>
1 parent ba6d8b5 commit e064dac

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

.github/workflows/integration-tests.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ jobs:
5858
echo "Running container from image: $DOCKER_IMAGE"
5959
6060
# Run the container
61-
docker run --name $CONTAINER_NAME -d -p 8989:8989 -p 9090:9090 \
62-
-p 8990:8990 \
61+
docker run --name $CONTAINER_NAME -d --network host \
6362
-v "$(pwd)"/codegate_volume:/app/codegate_volume \
6463
-e CODEGATE_APP_LOG_LEVEL=DEBUG \
64+
-e CODEGATE_OLLAMA_URL=http://localhost:11434 \
6565
--restart unless-stopped $DOCKER_IMAGE
6666
6767
# Confirm the container started
@@ -146,6 +146,41 @@ jobs:
146146
run: |
147147
poetry run python tests/integration/integration_tests.py
148148
149+
- name: Run Ollama
150+
run: |
151+
docker run -d -v ollama:/root/.ollama --network host --name ollama ollama/ollama
152+
docker ps -f name=ollama
153+
echo "Loop until the endpoint responds successfully"
154+
while ! curl --silent --fail --get "http://localhost:11434" >/dev/null; do
155+
echo "Ollama not available yet. Retrying in 2 seconds..."
156+
sleep 2
157+
done
158+
echo "Ollama is now available!"
159+
docker exec -d ollama ollama run qwen2.5-coder:0.5b
160+
161+
sleep 120 # Sleep for 2 minutes to allow Ollama to download the model. TODO: Improve this
162+
docker logs ollama
163+
164+
# Verify the Ollama API is working
165+
curl http://localhost:11434/api/generate -d '{
166+
"model": "qwen2.5-coder:0.5b",
167+
"prompt": "Why is the sky blue?",
168+
"stream": false
169+
}'
170+
171+
docker logs ollama
172+
173+
- name: Run integration tests - Ollama
174+
env:
175+
CODEGATE_PROVIDERS: "ollama"
176+
run: |
177+
poetry run python tests/integration/integration_tests.py
178+
179+
- name: Print the Ollama container logs (useful for debugging)
180+
if: always()
181+
run: |
182+
docker logs ollama
183+
149184
- name: Print the container logs (useful for debugging)
150185
if: always()
151186
run: |

tests/integration/testcases.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ headers:
44
openai:
55
Authorization: Bearer ENV_OPENAI_KEY
66
ollama:
7+
Content-Type: application/json
78
llamacpp:
89
anthropic:
910
x-api-key: ENV_ANTHROPIC_KEY
@@ -275,20 +276,20 @@ testcases:
275276
"role":"user"
276277
}
277278
],
278-
"model":"qwen2.5-coder:latest",
279+
"model":"qwen2.5-coder:0.5b",
279280
"stream":true,
280281
"temperature":0
281282
}
282283
likes: |
283-
Hello! How can I assist you today? If you have any questions or need guidance on secure coding practices, software security, package analysis, or anything else related to cybersecurity, feel free to ask!
284+
Hello! How can I assist you today?
284285
285286
ollama_fim:
286287
name: Ollama FIM
287288
provider: ollama
288289
url: http://127.0.0.1:8989/ollama/api/generate
289290
data: |
290291
{
291-
"model": "qwen2.5-coder:latest",
292+
"model": "qwen2.5-coder:0.5b",
292293
"max_tokens": 4096,
293294
"temperature": 0,
294295
"stream": true,

0 commit comments

Comments
 (0)