|
| 1 | +# Hetu Checkpoint Tests |
| 2 | + |
| 3 | +This document provides guidelines for running tests and important test cases for the Hetu Checkpoint project. |
| 4 | + |
| 5 | +## Project Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | +- Go 1.23.4 |
| 9 | +- Docker and Docker Compose |
| 10 | +- Make |
| 11 | +- Git |
| 12 | + |
| 13 | +### Environment Setup |
| 14 | + |
| 15 | +1. Clone the repository: |
| 16 | +```bash |
| 17 | +git clone https://github.com/hetuproject/checkpoint.git |
| 18 | +cd checkpoint |
| 19 | +``` |
| 20 | + |
| 21 | +2. Install dependencies: |
| 22 | +```bash |
| 23 | +make deps |
| 24 | +``` |
| 25 | + |
| 26 | +3. Build the project: |
| 27 | +```bash |
| 28 | +make build |
| 29 | +``` |
| 30 | + |
| 31 | +## Test Categories |
| 32 | + |
| 33 | +### 1. Unit Tests |
| 34 | +Run unit tests: |
| 35 | +```bash |
| 36 | +make test |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Integration Tests |
| 40 | +Run integration tests: |
| 41 | +```bash |
| 42 | +make test-integration |
| 43 | +``` |
| 44 | + |
| 45 | +### 3. Smoke Tests |
| 46 | +Run smoke tests: |
| 47 | +```bash |
| 48 | +make test-smoke |
| 49 | +``` |
| 50 | + |
| 51 | +## Core Test Cases |
| 52 | + |
| 53 | +### Dispatcher Service |
| 54 | + |
| 55 | +1. **Checkpoint Creation** |
| 56 | + - Test successful checkpoint creation with valid data |
| 57 | + - Test checkpoint creation with invalid data |
| 58 | + - Test checkpoint creation with different data sizes |
| 59 | + |
| 60 | +2. **Checkpoint Validation** |
| 61 | + - Test successful validation of valid checkpoints |
| 62 | + - Test validation of corrupted checkpoints |
| 63 | + - Test validation of expired checkpoints |
| 64 | + - Test validation with different validation rules |
| 65 | + |
| 66 | +3. **Storage Integration** |
| 67 | + - Test checkpoint storage in database backends |
| 68 | + - Test checkpoint retrieval |
| 69 | + - Test storage cleanup |
| 70 | + - Test storage capacity limits |
| 71 | + - Test storage failure scenarios |
| 72 | + |
| 73 | +4. **API Endpoints** |
| 74 | + - Test all REST API endpoints |
| 75 | + - Test API rate limiting |
| 76 | + - Test API authentication/whitelist |
| 77 | + |
| 78 | +### Validator Service |
| 79 | + |
| 80 | +1. **Validation Logic** |
| 81 | + - Test signature verification |
| 82 | + - Test timestamp validation |
| 83 | + - Test data integrity checks |
| 84 | + - Test custom validation rules |
| 85 | + - Test validation performance |
| 86 | + |
| 87 | +2. **Integration Tests** |
| 88 | + - Test validator-dispatcher communication |
| 89 | + - Test validator-storage integration |
| 90 | + - Test validator-API integration |
| 91 | + - Test validator scaling |
| 92 | + - Test validator failover |
| 93 | + |
| 94 | +### Performance Tests |
| 95 | + |
| 96 | +1. **Load Testing** |
| 97 | + - Test system under high concurrent requests |
| 98 | + - Test system with large data volumes |
| 99 | + - Test system with different request patterns |
| 100 | + - Test system resource usage |
| 101 | + - Test system recovery after load |
| 102 | + |
| 103 | +2. **Stress Testing** |
| 104 | + - Test system under extreme conditions |
| 105 | + - Test system with network latency |
| 106 | + - Test system with storage delays |
| 107 | + - Test system with partial failures |
| 108 | + - Test system recovery mechanisms |
| 109 | + |
| 110 | +### Security Tests |
| 111 | + |
| 112 | +1. **Authentication & Authorization** |
| 113 | + - Test API key validation |
| 114 | + - Test role-based access control |
| 115 | + - Test permission boundaries |
| 116 | + - Test token expiration |
| 117 | + - Test security headers |
| 118 | + |
| 119 | +2. **Data Protection** |
| 120 | + - Test data encryption |
| 121 | + - Test data integrity |
| 122 | + - Test data privacy |
| 123 | + - Test secure communication |
| 124 | + - Test audit logging |
| 125 | + |
| 126 | +## Test Environment |
| 127 | + |
| 128 | +### Local Development |
| 129 | +```bash |
| 130 | +# Start local development environment |
| 131 | +make dev-up |
| 132 | + |
| 133 | +# Run all tests |
| 134 | +make test-all |
| 135 | + |
| 136 | +# Clean up |
| 137 | +make dev-down |
| 138 | +``` |
| 139 | + |
| 140 | +### CI/CD Pipeline |
| 141 | +Tests are automatically run in the CI/CD pipeline for: |
| 142 | +- Pull requests |
| 143 | +- Main branch commits |
| 144 | +- Release tags |
| 145 | + |
| 146 | +## Test Results |
| 147 | + |
| 148 | +Test results are available in: |
| 149 | +- Console output |
| 150 | +- `test-results/` directory |
| 151 | +- CI/CD pipeline artifacts |
| 152 | + |
| 153 | +## Contributing |
| 154 | + |
| 155 | +When adding new features: |
| 156 | +1. Add corresponding unit tests |
| 157 | +2. Add integration tests if applicable |
| 158 | +3. Update this documentation if needed |
| 159 | +4. Ensure all tests pass before submitting PR |
0 commit comments