skeleton-testkit

module
v0.0.0-...-1fafc1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2025 License: MIT

README ΒΆ

Skeleton-Testkit

Go Version License Go Report Card Coverage Status Build Status Documentation

A comprehensive testing framework for skeleton-based applications

Skeleton-Testkit is a specialized testing framework designed to provide robust, containerized testing environments for applications built on the Skeleton Framework. It offers production-like testing scenarios, comprehensive verification strategies, and reusable testing infrastructure.

🎯 Purpose

The Skeleton-Testkit bridges the gap between unit testing and production deployment by providing:

  • Container-First Testing: Realistic testing environments using Docker containers
  • Skeleton-Aware Testing: Deep integration with skeleton component architecture
  • Production-Like Scenarios: Testing that mirrors real-world deployment conditions
  • Comprehensive Verification: Health monitoring, state verification, and behavior validation
  • Developer Experience: Streamlined testing workflows and clear feedback

πŸ—οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Skeleton-Testkit                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Testing Layer                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Verification  β”‚  β”‚   Container     β”‚  β”‚   Health    β”‚ β”‚
β”‚  β”‚   Strategies    β”‚  β”‚   Management    β”‚  β”‚   Monitoringβ”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                 Skeleton Framework                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Components    β”‚  β”‚   Plugins       β”‚  β”‚   Services  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                 Container Runtime                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚     Docker      β”‚  β”‚   PostgreSQL    β”‚  β”‚    Redis    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites
Installation
# Clone the repository
git clone https://github.com/fintechain/skeleton-testkit.git
cd skeleton-testkit

# Setup development environment
make setup-dev

# Verify installation
make validate
Basic Usage
package main

import (
    "context"
    "testing"
    
    "github.com/fintechain/skeleton-testkit/pkg/testkit"
    "github.com/fintechain/skeleton-testkit/pkg/container"
)

func TestSkeletonApplication(t *testing.T) {
    // Create a new testkit instance
    tk := testkit.New(t)
    defer tk.Cleanup()
    
    // Start a skeleton application container
    app, err := tk.StartSkeletonApp(context.Background(), &container.SkeletonConfig{
        Image: "my-skeleton-app:latest",
        Env: map[string]string{
            "DATABASE_URL": "postgres://test:test@localhost:5432/testdb",
        },
    })
    if err != nil {
        t.Fatalf("Failed to start skeleton app: %v", err)
    }
    
    // Wait for application to be ready
    if err := app.WaitForReady(context.Background()); err != nil {
        t.Fatalf("Application failed to become ready: %v", err)
    }
    
    // Verify application behavior
    verifier := tk.NewVerifier()
    if err := verifier.VerifyHealthy(app); err != nil {
        t.Fatalf("Health verification failed: %v", err)
    }
    
    // Test application functionality
    response, err := app.HTTPClient().Get("/api/health")
    if err != nil {
        t.Fatalf("Health check failed: %v", err)
    }
    defer response.Body.Close()
    
    if response.StatusCode != 200 {
        t.Errorf("Expected status 200, got %d", response.StatusCode)
    }
}

πŸ“ Project Structure

skeleton-testkit/
β”œβ”€β”€ cmd/                    # Command-line tools
β”‚   β”œβ”€β”€ testkit-cli/       # CLI for testkit operations
β”‚   └── examples/          # Example applications
β”œβ”€β”€ pkg/                   # Public API packages
β”‚   β”œβ”€β”€ testkit/          # Core testkit functionality
β”‚   β”œβ”€β”€ container/        # Container management
β”‚   β”œβ”€β”€ verification/     # Verification strategies
β”‚   └── health/           # Health monitoring
β”œβ”€β”€ internal/             # Internal implementation
β”‚   β”œβ”€β”€ domain/           # Domain models and interfaces
β”‚   β”œβ”€β”€ infrastructure/   # Infrastructure implementations
β”‚   └── adapters/         # External service adapters
β”œβ”€β”€ test/                 # Test suites
β”‚   β”œβ”€β”€ integration/      # Integration tests
β”‚   β”œβ”€β”€ unit/            # Unit tests
β”‚   └── fixtures/        # Test fixtures and data
β”œβ”€β”€ examples/             # Usage examples
β”‚   β”œβ”€β”€ basic/           # Basic usage examples
β”‚   β”œβ”€β”€ advanced/        # Advanced scenarios
β”‚   └── benchmarks/      # Performance examples
β”œβ”€β”€ docs/                # Documentation
β”‚   β”œβ”€β”€ architecture/    # Architecture documentation
β”‚   β”œβ”€β”€ api/            # API documentation
β”‚   └── guides/         # User guides
β”œβ”€β”€ deployments/         # Deployment configurations
β”‚   β”œβ”€β”€ docker/         # Docker configurations
β”‚   └── k8s/           # Kubernetes manifests
β”œβ”€β”€ scripts/            # Build and utility scripts
β”œβ”€β”€ configs/            # Configuration files
└── Makefile           # Build automation

πŸ› οΈ Development

Available Make Targets

The project includes a comprehensive Makefile with organized targets:

# Show all available targets
make help

# Development workflow
make dev                    # Full development cycle
make setup-dev             # Setup development environment
make test-watch            # Run tests in watch mode

# Testing
make test                  # Run all tests
make test-unit            # Unit tests only
make test-integration     # Integration tests (requires Docker)
make test-performance     # Performance benchmarks
make coverage             # Generate coverage report

# Code quality
make lint                 # Run linter
make fmt                  # Format code
make vet                  # Run go vet

# CI/CD
make ci                   # Fast CI pipeline
make ci-integration       # Full CI with integration tests
make validate             # Quick validation
Testing Strategy

The testkit implements a comprehensive testing strategy:

Unit Tests
  • Fast execution (< 30 seconds)
  • No external dependencies
  • High coverage of business logic
  • Isolated components
make test-unit
Integration Tests
  • Container-based testing environments
  • Real database connections
  • Network communication testing
  • End-to-end scenarios
make test-integration
Performance Tests
  • Startup time benchmarks
  • Resource usage monitoring
  • Throughput measurements
  • Scalability testing
make test-performance
Code Quality Standards
  • Go fmt: Consistent code formatting
  • Go vet: Static analysis for common errors
  • golangci-lint: Comprehensive linting
  • Test coverage: Minimum 80% coverage
  • Documentation: Comprehensive godoc comments

πŸ”§ Configuration

Environment Variables
Variable Description Default
TESTKIT_LOG_LEVEL Logging level (debug, info, warn, error) info
TESTKIT_TIMEOUT Default timeout for operations 30s
TESTKIT_DOCKER_HOST Docker daemon host unix:///var/run/docker.sock
TESTKIT_CLEANUP_CONTAINERS Auto-cleanup containers after tests true
TESTKIT_PARALLEL_TESTS Enable parallel test execution true
Configuration Files
# configs/testkit.yaml
testkit:
  timeout: 30s
  log_level: info
  docker:
    host: unix:///var/run/docker.sock
    cleanup: true
  containers:
    postgres:
      image: postgres:15-alpine
      env:
        POSTGRES_DB: testdb
        POSTGRES_USER: test
        POSTGRES_PASSWORD: test
    redis:
      image: redis:7-alpine

πŸ“š Documentation

Core Concepts
API Reference
Examples

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow
  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests (make test)
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request
Code Standards
  • Follow Go Code Review Comments
  • Write comprehensive tests for new features
  • Update documentation for API changes
  • Ensure all CI checks pass

πŸ“Š Performance

Benchmarks
Operation Duration Memory Allocations
Container Startup ~2.5s 45MB 1,234
Health Check ~50ms 2MB 45
Verification ~100ms 5MB 123
Cleanup ~1s 10MB 234
Resource Requirements
  • Memory: 512MB minimum, 2GB recommended
  • CPU: 2 cores minimum, 4 cores recommended
  • Disk: 10GB for container images and test data
  • Network: Internet access for pulling container images

πŸ”’ Security

Security Considerations
  • Container Isolation: Tests run in isolated Docker containers
  • Network Security: Containers use isolated networks
  • Credential Management: Test credentials are ephemeral
  • Resource Limits: Containers have resource constraints
Reporting Security Issues

Please report security vulnerabilities to security@fintechain.com.

πŸ“ˆ Roadmap

Short-term (Q1 2024)
  • Enhanced CI/CD integration
  • Performance optimization
  • Extended container support
  • Improved documentation
Medium-term (Q2-Q3 2024)
  • Kubernetes testing support
  • Advanced verification strategies
  • Monitoring and observability
  • Plugin system
Long-term (Q4 2024+)
  • Cloud provider integration
  • Distributed testing
  • AI-powered test generation
  • Community ecosystem

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support


Built with ❀️ by the Fintechain Team

Directories ΒΆ

Path Synopsis
internal
pkg
container
Package container provides public API wrappers for container management.
Package container provides public API wrappers for container management.
health
Package health provides health monitoring capabilities for skeleton applications.
Package health provides health monitoring capabilities for skeleton applications.
testkit
Package testkit provides the main entry point for the skeleton-testkit framework.
Package testkit provides the main entry point for the skeleton-testkit framework.
verification
Package verification provides verification strategies for testing skeleton applications.
Package verification provides verification strategies for testing skeleton applications.
test
fixtures
Package fixtures provides test fixtures and constants for skeleton-testkit integration tests.
Package fixtures provides test fixtures and constants for skeleton-testkit integration tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL