-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·112 lines (93 loc) · 2.91 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·112 lines (93 loc) · 2.91 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
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Test script for Braintrust Helm chart
# Runs both unit tests and integration tests
set -e
# Get the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Change to the script's directory
cd "$SCRIPT_DIR" || exit 1
CHART_DIR="braintrust"
# Check if helm is installed
if ! command -v helm &> /dev/null; then
echo "❌ Helm is not installed. Please install Helm first."
exit 1
fi
# Check if helm-unittest is installed using helm plugin list
# Suppress stderr to avoid plugin loading errors from other plugins
HELM_UNITTEST_INSTALLED=false
if helm plugin list 2>/dev/null | grep -q "unittest"; then
HELM_UNITTEST_INSTALLED=true
fi
# If not found, try to install it
if [ "$HELM_UNITTEST_INSTALLED" = false ]; then
echo "⚠️ helm-unittest plugin not found. Installing..."
# Suppress plugin loading errors by redirecting stderr
helm plugin install https://github.com/helm-unittest/helm-unittest.git --verify=false 2>/dev/null || {
echo "❌ Failed to install helm-unittest plugin"
exit 1
}
HELM_UNITTEST_INSTALLED=true
fi
echo ""
echo "=========================================="
echo "1. Running Unit Tests (helm-unittest)"
echo "=========================================="
# Run helm unittest, suppressing plugin loading errors from stderr
if helm unittest "$CHART_DIR" 2>/dev/null; then
echo ""
echo "✅ Unit tests passed"
else
echo ""
echo "❌ Unit tests failed"
exit 1
fi
echo ""
echo "=========================================="
echo "2. Testing Chart Rendering"
echo "=========================================="
echo ""
# Test rendering with different values files
VALUES_FILES=(
"$CHART_DIR/ci/values-azure.yaml"
"$CHART_DIR/ci/values-google.yaml"
"$CHART_DIR/ci/values-aws.yaml"
"$CHART_DIR/ci/values-minimal.yaml"
)
RENDER_FAILED=false
for values_file in "${VALUES_FILES[@]}"; do
if [ -f "$values_file" ]; then
echo "Testing with $(basename "$values_file")..."
if helm template test-release "$CHART_DIR" --values "$values_file" > /dev/null 2>&1; then
echo " ✅ Rendered successfully"
else
echo " ❌ Failed to render"
RENDER_FAILED=true
fi
else
echo " ⚠️ Values file not found: $values_file"
fi
done
if [ "$RENDER_FAILED" = true ]; then
echo ""
echo "❌ Chart rendering tests failed"
exit 1
fi
echo ""
echo "✅ Chart rendering tests passed"
echo ""
echo "=========================================="
echo "3. Running Helm Lint"
echo "=========================================="
echo ""
if helm lint "$CHART_DIR" --strict; then
echo ""
echo "✅ Chart linting passed"
else
echo ""
echo "❌ Chart linting failed"
exit 1
fi
echo ""
echo "=========================================="
echo "✅ All tests passed!"
echo "=========================================="