1+ #! /bin/bash
2+
3+ # Check for required arguments
4+ if [[ $# -ne 2 ]]; then
5+ echo " Usage: $0 <path_to_binary> <url_to_download>"
6+ exit 1
7+ fi
8+
9+ rm /tmp/response1.log /tmp/response2.log /tmp/nitro.log
10+
11+ BINARY_PATH=$1
12+ DOWNLOAD_URL=$2
13+
14+ # Start the binary file
15+ $BINARY_PATH > /tmp/nitro.log 2>&1 &
16+
17+ # Get the process id of the binary file
18+ pid=$!
19+
20+ if ! ps -p $pid > /dev/null; then
21+ echo " nitro failed to start. Logs:"
22+ cat /tmp/nitro.log
23+ exit 1
24+ fi
25+
26+ # Wait for a few seconds to let the server start
27+ sleep 5
28+
29+
30+
31+ # Check if /tmp/testmodel exists, if not, download it
32+ if [[ ! -f " /tmp/testmodel" ]]; then
33+ wget $DOWNLOAD_URL -O /tmp/testmodel
34+ fi
35+
36+ # Run the curl commands
37+ response1=$( curl -o /tmp/response1.log -s -w " %{http_code}" --location ' http://localhost:3928/inferences/llamacpp/loadModel' \
38+ --header ' Content-Type: application/json' \
39+ --data ' {
40+ "llama_model_path": "/tmp/testmodel",
41+ "ctx_len": 2048,
42+ "ngl": 32,
43+ "embedding": false
44+ }' 2>&1 )
45+
46+ response2=$( curl -o /tmp/response2.log -s -w " %{http_code}" --location ' http://localhost:3928/inferences/llamacpp/chat_completion' \
47+ --header ' Content-Type: application/json' \
48+ --header ' Accept: text/event-stream' \
49+ --header ' Access-Control-Allow-Origin: *' \
50+ --data ' {
51+ "messages": [
52+ {"content": "Hello there", "role": "assistant"},
53+ {"content": "Write a long and sad story for me", "role": "user"}
54+ ],
55+ "stream": true,
56+ "model": "gpt-3.5-turbo",
57+ "max_tokens": 2048,
58+ "stop": ["hello"],
59+ "frequency_penalty": 0,
60+ "presence_penalty": 0,
61+ "temperature": 0.7
62+ }' 2>&1
63+ )
64+
65+ error_occurred=0
66+ if [[ " $response1 " -ne 200 ]]; then
67+ echo " The first curl command failed with status code: $response1 "
68+ cat /tmp/response1.log
69+ error_occurred=1
70+ fi
71+
72+ if [[ " $response2 " -ne 200 ]]; then
73+ echo " The second curl command failed with status code: $response2 "
74+ cat /tmp/response2.log
75+ error_occurred=1
76+ fi
77+
78+ if [[ " $error_occurred " -eq 1 ]]; then
79+ echo " Nitro test run failed!!!!!!!!!!!!!!!!!!!!!!"
80+ echo " Nitro Error Logs:"
81+ cat /tmp/nitro.log
82+ kill $pid
83+ exit 1
84+ fi
85+
86+ echo " Nitro test run successfully!"
87+
88+ # Kill the server process
89+ kill $pid
0 commit comments