Some checks failed
Build / Code Quality Checks (push) Successful in 15m11s
Build / Build & Push Docker Images (worker) (push) Successful in 13m44s
Build / Build & Push Docker Images (frontend) (push) Successful in 5m8s
Build / Build & Push Docker Images (chat) (push) Failing after 30m7s
Build / Build & Push Docker Images (api) (push) Failing after 21m39s
144 lines
4.8 KiB
Bash
Executable File
144 lines
4.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Test script for Helm chart validation
|
|
# Usage: ./test-chart.sh
|
|
|
|
set -e
|
|
|
|
CHART_DIR="datacenter-docs"
|
|
RELEASE_NAME="test-datacenter-docs"
|
|
|
|
echo "=========================================="
|
|
echo "Helm Chart Testing Script"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Check if helm is installed
|
|
if ! command -v helm &> /dev/null; then
|
|
echo "ERROR: helm is not installed. Please install Helm first."
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Helm version: $(helm version --short)"
|
|
echo ""
|
|
|
|
# Lint the chart
|
|
echo "=========================================="
|
|
echo "Step 1: Linting Chart"
|
|
echo "=========================================="
|
|
helm lint ${CHART_DIR}
|
|
echo "✓ Lint passed"
|
|
echo ""
|
|
|
|
# Template rendering with default values
|
|
echo "=========================================="
|
|
echo "Step 2: Template Rendering (default values)"
|
|
echo "=========================================="
|
|
helm template ${RELEASE_NAME} ${CHART_DIR} > /tmp/rendered-default.yaml
|
|
echo "✓ Template rendering successful"
|
|
echo " Output: /tmp/rendered-default.yaml"
|
|
echo ""
|
|
|
|
# Template rendering with development values
|
|
echo "=========================================="
|
|
echo "Step 3: Template Rendering (development values)"
|
|
echo "=========================================="
|
|
helm template ${RELEASE_NAME} ${CHART_DIR} -f ${CHART_DIR}/values-development.yaml > /tmp/rendered-dev.yaml
|
|
echo "✓ Template rendering successful"
|
|
echo " Output: /tmp/rendered-dev.yaml"
|
|
echo ""
|
|
|
|
# Template rendering with production values
|
|
echo "=========================================="
|
|
echo "Step 4: Template Rendering (production values)"
|
|
echo "=========================================="
|
|
helm template ${RELEASE_NAME} ${CHART_DIR} -f ${CHART_DIR}/values-production.yaml > /tmp/rendered-prod.yaml
|
|
echo "✓ Template rendering successful"
|
|
echo " Output: /tmp/rendered-prod.yaml"
|
|
echo ""
|
|
|
|
# Dry run installation
|
|
echo "=========================================="
|
|
echo "Step 5: Dry Run Installation"
|
|
echo "=========================================="
|
|
helm install ${RELEASE_NAME} ${CHART_DIR} --dry-run --debug > /tmp/dry-run.log 2>&1
|
|
echo "✓ Dry run successful"
|
|
echo " Output: /tmp/dry-run.log"
|
|
echo ""
|
|
|
|
# Test with disabled components
|
|
echo "=========================================="
|
|
echo "Step 6: Template with Disabled Components"
|
|
echo "=========================================="
|
|
helm template ${RELEASE_NAME} ${CHART_DIR} \
|
|
--set mongodb.enabled=false \
|
|
--set redis.enabled=false \
|
|
--set api.enabled=false \
|
|
--set frontend.enabled=false \
|
|
> /tmp/rendered-minimal.yaml
|
|
echo "✓ Minimal template rendering successful"
|
|
echo " Output: /tmp/rendered-minimal.yaml"
|
|
echo ""
|
|
|
|
# Test with all components enabled
|
|
echo "=========================================="
|
|
echo "Step 7: Template with All Components"
|
|
echo "=========================================="
|
|
helm template ${RELEASE_NAME} ${CHART_DIR} \
|
|
--set chat.enabled=true \
|
|
--set worker.enabled=true \
|
|
> /tmp/rendered-full.yaml
|
|
echo "✓ Full template rendering successful"
|
|
echo " Output: /tmp/rendered-full.yaml"
|
|
echo ""
|
|
|
|
# Validate Kubernetes manifests (if kubectl is available)
|
|
if command -v kubectl &> /dev/null; then
|
|
echo "=========================================="
|
|
echo "Step 8: Kubernetes Manifest Validation"
|
|
echo "=========================================="
|
|
|
|
if kubectl version --client &> /dev/null; then
|
|
kubectl apply --dry-run=client -f /tmp/rendered-default.yaml > /dev/null 2>&1
|
|
echo "✓ Kubernetes manifest validation passed"
|
|
else
|
|
echo "⚠ kubectl not connected to cluster, skipping validation"
|
|
fi
|
|
echo ""
|
|
else
|
|
echo "⚠ kubectl not found, skipping Kubernetes validation"
|
|
echo ""
|
|
fi
|
|
|
|
# Package the chart
|
|
echo "=========================================="
|
|
echo "Step 9: Packaging Chart"
|
|
echo "=========================================="
|
|
helm package ${CHART_DIR} -d /tmp/
|
|
echo "✓ Chart packaged successfully"
|
|
echo " Output: /tmp/datacenter-docs-*.tgz"
|
|
echo ""
|
|
|
|
# Summary
|
|
echo "=========================================="
|
|
echo "All Tests Passed! ✓"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Generated files:"
|
|
echo " - /tmp/rendered-default.yaml (default values)"
|
|
echo " - /tmp/rendered-dev.yaml (development values)"
|
|
echo " - /tmp/rendered-prod.yaml (production values)"
|
|
echo " - /tmp/rendered-minimal.yaml (minimal components)"
|
|
echo " - /tmp/rendered-full.yaml (all components)"
|
|
echo " - /tmp/dry-run.log (dry run output)"
|
|
echo " - /tmp/datacenter-docs-*.tgz (packaged chart)"
|
|
echo ""
|
|
echo "To install the chart locally:"
|
|
echo " helm install my-release ${CHART_DIR}"
|
|
echo ""
|
|
echo "To install with development values:"
|
|
echo " helm install dev ${CHART_DIR} -f ${CHART_DIR}/values-development.yaml"
|
|
echo ""
|
|
echo "To install with production values (customize first!):"
|
|
echo " helm install prod ${CHART_DIR} -f ${CHART_DIR}/values-production.yaml"
|
|
echo ""
|