Files
homelab-configs/quick-test-opencode.sh
T
jgitta 290aedf82d Add complete homelab documentation and configurations
Documentation:
- OpenCode + LiteLLM integration guide
- LiteLLM complete setup with 16 models
- Gitea centralized configuration guide
- Testing procedures and verification
- API keys setup instructions

Configurations:
- OpenCode config pointing to LiteLLM
- Updated LiteLLM config with all models
- Nextcloud docker-compose template

Scripts:
- Gitea setup automation
- OpenCode testing script

Infrastructure:
- Gitea: 192.168.88.200:3000
- LiteLLM: 192.168.88.27:4000
- Nextcloud: 192.168.88.62
2026-04-25 10:56:21 -05:00

158 lines
5.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
################################################################################
# Quick Test Script - OpenCode + LiteLLM Integration
#
# Run this on your Nextcloud VM (next @ 192.168.88.62)
# to verify the entire setup is working
################################################################################
set -e
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
NC='\033[0m'
PASS_COUNT=0
FAIL_COUNT=0
# Helper functions
pass() {
echo -e "${GREEN}$1${NC}"
((PASS_COUNT++))
}
fail() {
echo -e "${RED}$1${NC}"
((FAIL_COUNT++))
}
info() {
echo -e "${BLUE}$1${NC}"
}
section() {
echo ""
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
}
# Main tests
section "OpenCode + LiteLLM Integration Tests"
# Test 1: Config File
section "Test 1: Configuration File"
if [ -f ~/.opencode/config.json ]; then
pass "Config file exists at ~/.opencode/config.json"
# Check for correct API base
if cat ~/.opencode/config.json | grep -q "192.168.88.27:4000"; then
pass "Config points to LiteLLM gateway (192.168.88.27:4000)"
else
fail "Config does not point to LiteLLM gateway"
fi
# Check for correct API provider
if cat ~/.opencode/config.json | grep -q "openai"; then
pass "Config uses OpenAI-compatible API provider"
else
fail "Config does not use OpenAI provider"
fi
else
fail "Config file does not exist at ~/.opencode/config.json"
info "Try restarting: docker-compose restart opencode"
fi
# Test 2: Docker Container
section "Test 2: Docker Container Status"
if docker ps | grep -q opencode; then
pass "OpenCode container is running"
else
fail "OpenCode container is not running"
info "Start it: docker-compose up -d opencode"
fi
# Test 3: LiteLLM Gateway Access
section "Test 3: LiteLLM Gateway Connectivity"
if timeout 5 docker exec opencode curl -s http://192.168.88.27:4000/models \
-H "Authorization: Bearer litellm-local-key-change-in-production" > /dev/null 2>&1; then
MODEL_COUNT=$(docker exec opencode curl -s http://192.168.88.27:4000/models \
-H "Authorization: Bearer litellm-local-key-change-in-production" | grep -o '"id"' | wc -l)
if [ "$MODEL_COUNT" -eq 16 ]; then
pass "LiteLLM gateway is accessible with all 16 models"
else
fail "LiteLLM gateway returned $MODEL_COUNT models (expected 16)"
fi
else
fail "Cannot reach LiteLLM gateway at 192.168.88.27:4000"
info "Check: curl http://192.168.88.27:4000/models"
fi
# Test 4: Gitea Accessibility
section "Test 4: Gitea Repository Connectivity"
if timeout 5 docker exec opencode curl -s http://192.168.88.200:3000/api/v1/version > /dev/null 2>&1; then
pass "Gitea is accessible at 192.168.88.200:3000"
GITEA_VERSION=$(docker exec opencode curl -s http://192.168.88.200:3000/api/v1/version | grep -o '"version":"[^"]*"' | cut -d'"' -f4)
info "Gitea version: $GITEA_VERSION"
else
fail "Cannot reach Gitea at 192.168.88.200:3000"
info "Check Gitea status on docker-server"
fi
# Test 5: API Call Test (with placeholder keys)
section "Test 5: API Gateway Routing"
info "Attempting test call to LiteLLM gateway..."
info "(Expected to fail with 401 - testing placeholder keys)"
RESPONSE=$(curl -s -X POST http://192.168.88.27:4000/chat/completions \
-H "Authorization: Bearer litellm-local-key-change-in-production" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "test"}]}')
if echo "$RESPONSE" | grep -q "401\|Incorrect API key\|invalid_api_key"; then
pass "API gateway is routing correctly (401 = placeholder keys are expected)"
info "This is GOOD - it means the system is working!"
info "Once you add real API keys, you'll get actual responses"
elif echo "$RESPONSE" | grep -q "error"; then
fail "API returned an unexpected error: $(echo $RESPONSE | head -c 100)..."
else
pass "Unexpected successful response (may have real keys configured)"
fi
# Summary
section "Test Summary"
TOTAL=$((PASS_COUNT + FAIL_COUNT))
echo ""
echo -e "${GREEN}Passed: $PASS_COUNT/$TOTAL${NC}"
if [ $FAIL_COUNT -gt 0 ]; then
echo -e "${RED}Failed: $FAIL_COUNT/$TOTAL${NC}"
echo ""
echo -e "${YELLOW}⚠️ Some tests failed. Check the troubleshooting guide:${NC}"
echo " opencode-testing-guide.md"
exit 1
else
echo -e "${GREEN}All tests passed!${NC}"
echo ""
echo -e "${GREEN}✨ Your setup is working correctly!${NC}"
echo ""
echo "Next steps:"
echo " 1. Add real API keys to /opt/litellm/.env on docker-server"
echo " 2. Restart LiteLLM: cd /opt/litellm && docker-compose restart"
echo " 3. Test again: bash /path/to/quick-test-opencode.sh"
echo " 4. Start using OpenCode with full LiteLLM integration!"
echo ""
fi