forked from livehybrid/splunk-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·100 lines (85 loc) · 2.75 KB
/
run_tests.sh
File metadata and controls
executable file
·100 lines (85 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Run tests with coverage and generate HTML report
# Set colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Parse arguments
USE_DOCKER=false
INSTALL_DEPS=false
USE_UV=false
# Determine which docker compose command to use
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
else
DOCKER_COMPOSE="docker-compose"
fi
while [[ "$#" -gt 0 ]]; do
case $1 in
--docker) USE_DOCKER=true ;;
--install) INSTALL_DEPS=true ;;
--uv) USE_UV=true ;;
*) echo "Unknown parameter: $1"; exit 1 ;;
esac
shift
done
echo -e "${YELLOW}==========================${NC}"
echo -e "${YELLOW}= Running Splunk MCP Tests =${NC}"
echo -e "${YELLOW}==========================${NC}"
echo ""
if [ "$USE_DOCKER" = true ]; then
echo -e "${YELLOW}Running tests in Docker...${NC}"
# Clean up any existing containers
$DOCKER_COMPOSE down
# Build and run tests
$DOCKER_COMPOSE up --build --abort-on-container-exit test
# Copy test results from container
docker cp $($DOCKER_COMPOSE ps -q test):/app/test-results ./
# Cleanup
$DOCKER_COMPOSE down
else
# Local testing
if [ "$INSTALL_DEPS" = true ]; then
echo -e "${YELLOW}Installing dependencies...${NC}"
# Check for UV first
if command -v uv &> /dev/null; then
echo -e "${GREEN}Using UV for dependency installation...${NC}"
uv sync --extra dev
USE_UV=true
elif command -v poetry &> /dev/null; then
echo -e "${YELLOW}UV not found, using Poetry...${NC}"
poetry install
else
echo -e "${RED}Neither UV nor Poetry found. Please install one of them.${NC}"
exit 1
fi
echo ""
fi
# Run standalone test script
echo -e "${YELLOW}Running standalone tests...${NC}"
if [ "$USE_UV" = true ]; then
uv run python test_endpoints.py
else
DEBUG=true python test_endpoints.py
fi
# Run pytest tests
echo -e "${YELLOW}Running pytest tests...${NC}"
if [ "$USE_UV" = true ]; then
uv run pytest tests/test_endpoints_pytest.py --cov=splunk_mcp -v
else
pytest tests/test_endpoints_pytest.py --cov=splunk_mcp -v
fi
# Generate coverage report
echo -e "${YELLOW}Generating HTML coverage report...${NC}"
if [ "$USE_UV" = true ]; then
uv run pytest tests/test_endpoints_pytest.py --cov=splunk_mcp --cov-report=html
else
pytest tests/test_endpoints_pytest.py --cov=splunk_mcp --cov-report=html
fi
fi
echo ""
echo -e "${GREEN}Tests completed!${NC}"
if [ "$USE_DOCKER" = false ]; then
echo -e "${GREEN}Coverage report is in htmlcov/index.html${NC}"
fi