|
| 1 | +# Docker Compose Test Setup |
| 2 | + |
| 3 | +This docker-compose file provides a local testing environment for the TCDI Admin application with all required dependencies. |
| 4 | + |
| 5 | +## Services |
| 6 | + |
| 7 | +| Service | Port | Description | |
| 8 | +|---------|------|-------------| |
| 9 | +| postgres | 5432 | PostgreSQL database for the admin application | |
| 10 | +| postgres-interference | 5433 | PostgreSQL database for the interference service | |
| 11 | +| eureka | 8761 | Netflix Eureka service registry | |
| 12 | +| mock-interference-service | 8090 | MockServer simulating the interference service API | |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- Docker and Docker Compose installed |
| 17 | +- The admin application built (`mvn install -Dcheckstyle.skip=true -DskipTests`) |
| 18 | + |
| 19 | +## Quick Start |
| 20 | + |
| 21 | +1. **Start the infrastructure:** |
| 22 | + ```bash |
| 23 | + docker-compose -f docker-compose-test.yml up -d |
| 24 | + ``` |
| 25 | + |
| 26 | +2. **Wait for services to be healthy:** |
| 27 | + ```bash |
| 28 | + docker-compose -f docker-compose-test.yml ps |
| 29 | + ``` |
| 30 | + |
| 31 | +3. **Run the admin application:** |
| 32 | + ```bash |
| 33 | + mvn spring-boot:run -pl forms -Dcheckstyle.skip=true \ |
| 34 | + -Dspring-boot.run.profiles=dev \ |
| 35 | + -Dspring-boot.run.arguments="--eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/" |
| 36 | + ``` |
| 37 | + |
| 38 | +4. **Access the application:** |
| 39 | + - Admin UI: http://localhost:8080 |
| 40 | + - Eureka Dashboard: http://localhost:8761 |
| 41 | + |
| 42 | +## Testing CSV Dataset Upload |
| 43 | + |
| 44 | +### Scenario: Test normal upload flow |
| 45 | + |
| 46 | +1. Navigate to the CSV Datasets section in the admin UI |
| 47 | +2. Create a new dataset for the "INTERFERENCE" service |
| 48 | +3. Upload the test CSV file: `forms/src/test/resources/world_industry_interference_2025.csv` |
| 49 | +4. Click "Save and Publish" |
| 50 | +5. The mock service will return a successful response |
| 51 | + |
| 52 | +### Scenario: Test stuck publishing detection |
| 53 | + |
| 54 | +1. Create and publish a dataset |
| 55 | +2. The job checker runs every minute (`@Scheduled(cron = "0 * * * * *")`) |
| 56 | +3. If a job is in PUBLISHING state for longer than `dataset.publishing.timeout.minutes` (default: 30), it will be marked as ERROR_IN_PUBLISHING |
| 57 | + |
| 58 | +### Scenario: Test Cancel Publishing button |
| 59 | + |
| 60 | +1. Create a dataset and start publishing |
| 61 | +2. While in PUBLISHING state, a "Cancel Publishing" button should appear |
| 62 | +3. Click the button to cancel and mark as ERROR_IN_PUBLISHING |
| 63 | +4. This allows retrying the upload after fixing issues |
| 64 | + |
| 65 | +## Configuration |
| 66 | + |
| 67 | +### Publishing Timeout |
| 68 | + |
| 69 | +Configure the timeout for stuck jobs in `application.properties` or via environment variable: |
| 70 | + |
| 71 | +```properties |
| 72 | +dataset.publishing.timeout.minutes=30 |
| 73 | +``` |
| 74 | + |
| 75 | +### Mock Service Responses |
| 76 | + |
| 77 | +The mock interference service (MockServer) is configured via `mockserver-init.json`. It simulates: |
| 78 | + |
| 79 | +- `GET /health` - Health check endpoint |
| 80 | +- `POST /datasets` - Dataset upload (returns PROCESSING status) |
| 81 | +- `GET /jobs/code/tcdi-*` - Job status check (returns COMPLETED) |
| 82 | +- `DELETE /datasets/tcdi-*` - Dataset deletion |
| 83 | +- `GET /template/download` - CSV template download |
| 84 | +- `GET /dimensions` - Get available dimensions |
| 85 | +- `GET /measures` - Get available measures |
| 86 | + |
| 87 | +## Cleanup |
| 88 | + |
| 89 | +Stop and remove all containers and volumes: |
| 90 | + |
| 91 | +```bash |
| 92 | +docker-compose -f docker-compose-test.yml down -v |
| 93 | +``` |
| 94 | + |
| 95 | +## Troubleshooting |
| 96 | + |
| 97 | +### Database connection issues |
| 98 | + |
| 99 | +Check if PostgreSQL is healthy: |
| 100 | +```bash |
| 101 | +docker-compose -f docker-compose-test.yml logs postgres |
| 102 | +``` |
| 103 | + |
| 104 | +### Eureka connection issues |
| 105 | + |
| 106 | +Ensure Eureka is running and accessible: |
| 107 | +```bash |
| 108 | +curl http://localhost:8761/actuator/health |
| 109 | +``` |
| 110 | + |
| 111 | +### Mock service not responding |
| 112 | + |
| 113 | +Check MockServer logs: |
| 114 | +```bash |
| 115 | +docker-compose -f docker-compose-test.yml logs mock-interference-service |
| 116 | +``` |
| 117 | + |
| 118 | +## Running Unit Tests |
| 119 | + |
| 120 | +The `DatasetClientServiceTest` class contains unit tests for the new functionality: |
| 121 | + |
| 122 | +```bash |
| 123 | +mvn test -pl forms -Dtest=DatasetClientServiceTest -Dcheckstyle.skip=true |
| 124 | +``` |
| 125 | + |
| 126 | +Tests cover: |
| 127 | +- Cancel publishing functionality |
| 128 | +- Status transitions (PUBLISHING → PUBLISHED, UNPUBLISHING → DRAFT) |
| 129 | +- Error status transitions (PUBLISHING → ERROR_IN_PUBLISHING, UNPUBLISHING → ERROR_IN_UNPUBLISHING) |
| 130 | +- Timeout detection for stuck jobs |
| 131 | +- Dataset saving based on type (CSV vs Tetsim) |
0 commit comments