Testing Guidelines
Comprehensive testing guide for catalog workloads.
Overview
Section titled “Overview”All workloads should be tested before submission to ensure they deploy correctly and function as expected.
Testing Workflow
Section titled “Testing Workflow”1. Local Catalog Testing
Section titled “1. Local Catalog Testing”Test with a local catalog copy:
# Clone documentation repositorygit clone https://github.com/getloko/getloko.github.io.gitcd getloko.github.io
# Create your workload branchgit checkout -b add-workload-myapp
# Add your workload definition# Edit public/catalog/workloads/<category>.yaml2. Deploy with Local Catalog
Section titled “2. Deploy with Local Catalog”# Point LoKO to your local catalogloko workloads add myapp --catalog=/path/to/getloko.github.io/public/catalog
# Enable and deployloko workloads enable myapp --now3. Verify Deployment
Section titled “3. Verify Deployment”# Check workload infoloko workloads info myapp
# Check podskubectl get pods -n loko-workloads -l app=myapp
# Check servicekubectl get svc -n loko-workloads -l app=myappTest Categories
Section titled “Test Categories”Deployment Tests
Section titled “Deployment Tests”Verify the workload deploys successfully.
Check pods are running:
kubectl get pods -n loko-workloads -l app.kubernetes.io/name=myappExpected output:
NAME READY STATUS RESTARTS AGEmyapp-7d4f8c9b5-xyz12 1/1 Running 0 2mCheck service is created:
kubectl get svc -n loko-workloads myappCheck ingress (if applicable):
kubectl get ingress -n loko-workloads myappConnectivity Tests
Section titled “Connectivity Tests”Verify endpoints are accessible.
TCP Services:
# Test port connectivitync -zv myapp.${LOKO_DOMAIN} 5432
# Or with telnettelnet myapp.${LOKO_DOMAIN} 5432HTTP/HTTPS Services:
# Test HTTP endpointcurl -I https://myapp.${LOKO_DOMAIN}
# Check response codecurl -w "%{http_code}" https://myapp.${LOKO_DOMAIN}Health Check Tests
Section titled “Health Check Tests”Verify health checks function correctly.
TCP Health Check:
# Manual TCP checknc -zv myapp.${LOKO_DOMAIN} 8080HTTP Health Check:
# Test health endpointcurl https://myapp.${LOKO_DOMAIN}/healthCommand Health Check:
# Run health check command manuallykubectl exec -n loko-workloads deployment/myapp -- \ /health-check-commandConnection String Tests
Section titled “Connection String Tests”Verify connection strings work correctly.
Database Connection:
# PostgreSQL examplepsql "postgresql://postgres:${PASSWORD}@postgres.${LOKO_DOMAIN}:5432/testdb"
# MySQL examplemysql -h mysql.${LOKO_DOMAIN} -P 3306 -u root -p${PASSWORD}
# MongoDB examplemongosh "mongodb://root:${PASSWORD}@mongodb.${LOKO_DOMAIN}:27017/testdb?authSource=admin"Application Connection:
# Test with Pythonimport psycopg2
conn = psycopg2.connect( host='postgres.${LOKO_DOMAIN}', port=5432, user='postgres', password='${PASSWORD}', database='testdb')
cursor = conn.cursor()cursor.execute('SELECT version()')print(cursor.fetchone())conn.close()Secret Generation Tests
Section titled “Secret Generation Tests”Verify secrets are generated correctly.
Check secret exists:
kubectl get secret -n loko-workloads myapp-passwordVerify secret content:
# Get password valuekubectl get secret -n loko-workloads myapp-password \ -o jsonpath='{.data.password}' | base64 -dTest secret in connection:
# Use secret in connection stringloko workloads connect myapp --show-passwordUI Tests
Section titled “UI Tests”For workloads with web UIs.
Access web UI:
# Open in browseropen https://myapp-ui.${LOKO_DOMAIN}Check login functionality:
- Verify credentials work
- Test basic navigation
- Verify data is accessible
Check linked workload:
# Verify UI workload is deployedloko workloads status myapp-ui
# Check it's linked to main workloadloko workloads info myappTest Scenarios
Section titled “Test Scenarios”Minimal System Workload
Section titled “Minimal System Workload”Test a simple system workload:
workloads: test-app: type: system category: test description: "Test application"
chart: repo: groundhog2k name: groundhog2k/nextcloud version: "0.20.6"
defaults: namespace: loko-workloads
presets: service: type: ClusterIP port: 80
ingress: enabled: true className: traefik hosts: - host: test-app.${LOKO_DOMAIN}Test steps:
- Deploy:
loko workloads add test-app --now - Verify:
curl https://test-app.${LOKO_DOMAIN} - Cleanup:
loko workloads remove test-app
TCP Service Workload
Section titled “TCP Service Workload”Test TCP port exposure:
workloads: test-db: type: system category: database description: "Test database"
chart: repo: groundhog2k name: groundhog2k/postgres version: "1.6.1"
defaults: namespace: loko-workloads ports: [5432]
secrets: - name: password type: password length: 16
presets: service: type: ClusterIP port: 5432Test steps:
- Deploy with port exposure
- Test TCP connectivity:
nc -zv test-db.${LOKO_DOMAIN} 5432 - Test connection string with password
- Cleanup
Linked Workload
Section titled “Linked Workload”Test workload with UI link:
workloads: main-app: links: - type: addon target: main-app-ui auto-deploy: true required: false lifecycle-binding: trueTest steps:
- Deploy main workload
- Verify UI auto-deploys
- Test both workloads accessible
- Remove main workload, verify UI is also removed
Automated Testing
Section titled “Automated Testing”Pre-Deployment Validation
Section titled “Pre-Deployment Validation”# Validate YAML syntaxyamllint public/catalog/workloads/myapp.yaml
# Validate with LoKO (dry-run)loko workloads add myapp --dry-runPost-Deployment Checks
Section titled “Post-Deployment Checks”#!/bin/bash# test-workload.sh
WORKLOAD=$1NAMESPACE=loko-workloads
echo "Testing workload: $WORKLOAD"
# Check deploymentecho "Checking deployment..."kubectl wait --for=condition=available \ deployment/$WORKLOAD -n $NAMESPACE --timeout=300s
# Check serviceecho "Checking service..."kubectl get svc $WORKLOAD -n $NAMESPACE
# Check podsecho "Checking pods..."kubectl get pods -n $NAMESPACE -l app.kubernetes.io/name=$WORKLOAD
# Test endpoint (HTTP)echo "Testing endpoint..."curl -f https://$WORKLOAD.${LOKO_DOMAIN} || echo "HTTP test failed"
echo "Tests complete!"Usage:
chmod +x test-workload.sh./test-workload.sh myappCommon Issues
Section titled “Common Issues”Pod Not Starting
Section titled “Pod Not Starting”Check pod status:
kubectl describe pod -n loko-workloads <pod-name>Common causes:
- Image pull failures
- Resource constraints
- Configuration errors
- Volume mount issues
Debug:
# Check eventskubectl get events -n loko-workloads --sort-by='.lastTimestamp'
# Check logskubectl logs -n loko-workloads <pod-name>Service Not Accessible
Section titled “Service Not Accessible”Check service:
kubectl get svc -n loko-workloads myappCheck endpoints:
kubectl get endpoints -n loko-workloads myappTest from within cluster:
kubectl run -it --rm debug --image=curlimages/curl --restart=Never -- \ curl http://myapp.loko-workloads.svc.cluster.local:8080Ingress Not Working
Section titled “Ingress Not Working”Check ingress:
kubectl describe ingress -n loko-workloads myappVerify Traefik routing:
# Check IngressRoute (for TCP services)kubectl get ingressroute -n loko-workloads
# Check Traefik logskubectl logs -n kube-system deployment/traefikSecret Issues
Section titled “Secret Issues”Verify secret exists:
kubectl get secrets -n loko-workloads | grep myappCheck secret is mounted:
kubectl describe pod -n loko-workloads <pod-name> | grep -A 5 MountsVerify secret values:
kubectl get secret myapp-password -n loko-workloads -o yamlPerformance Testing
Section titled “Performance Testing”Resource Usage
Section titled “Resource Usage”Monitor resource consumption:
# Pod resource usagekubectl top pods -n loko-workloads
# Node resource usagekubectl top nodes
# Detailed resource infokubectl describe pod -n loko-workloads <pod-name> | grep -A 10 ResourcesLoad Testing
Section titled “Load Testing”Simple load test for HTTP services:
# Using Apache Benchab -n 1000 -c 10 https://myapp.${LOKO_DOMAIN}/
# Using curl in loopfor i in {1..100}; do curl -s https://myapp.${LOKO_DOMAIN}/ > /dev/null echo "Request $i completed"doneCleanup
Section titled “Cleanup”Always clean up test workloads:
# Remove workloadloko workloads remove myapp
# Verify removalkubectl get all -n loko-workloads -l app.kubernetes.io/name=myapp
# Remove namespace (if testing in custom namespace)kubectl delete namespace test-workloadsTesting Checklist
Section titled “Testing Checklist”Before submitting your workload:
Deployment
Section titled “Deployment”- Workload deploys without errors
- Pods reach Running state within 5 minutes
- Service is created correctly
- Ingress/IngressRoute is configured (if applicable)
Connectivity
Section titled “Connectivity”- Service is accessible via connection string
- Web UI loads (if applicable)
- TCP ports are reachable (if applicable)
- TLS certificates are valid
Functionality
Section titled “Functionality”- Basic operations work correctly
- Secrets are generated and accessible
- Health checks pass
- Linked workloads auto-deploy (if applicable)
Documentation
Section titled “Documentation”- Connection strings are accurate
- Code examples work
- Endpoints are documented
- Known issues are noted
Cleanup
Section titled “Cleanup”- Workload removes cleanly
- No orphaned resources
- Linked workloads are removed (if lifecycle-binding)
Next Steps
Section titled “Next Steps”- Contributing Guidelines - How to contribute
- Schema Reference - Workload schema documentation
- Browse Workloads - Existing workloads