mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 08:51:13 +00:00
[AZ-289] [AZ-290] Batch 3 tests: integration ZIP cap, perf, security, queue
AZ-289 — RL-01 50MB ZIP cap added to RunRouteWithTilesZipTest;
existing integration tests already cover BT-08/BT-09 + AC-1/AC-2.
AZ-290:
- scripts/run-performance-tests.sh extended with PT-01/03/04/05
- SatelliteProvider.IntegrationTests/SecurityTests.cs (SEC-01..SEC-04),
wired into Program.cs
- SatelliteProvider.Tests/RegionRequestQueueTests.cs covering RS-04 /
RL-02 queue capacity behavior
Notes:
- RS-04 spec wording ("rejects overflow") drifts from the channel's
BoundedChannelFullMode.Wait back-pressure semantics. Tests assert
the actual behavior; spec to be reconciled in Step 12 (Test-Spec
Sync). Tracked as Low/Spec-Gap in batch_03_review.md.
- Unit tests: 35/35 passed (Docker .NET 8 SDK).
- Integration test project builds clean (0 warnings, 0 errors).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -204,6 +204,13 @@ public static class ExtendedRouteTests
|
|||||||
throw new Exception($"ZIP file seems too small: {zipInfo.Length} bytes");
|
throw new Exception($"ZIP file seems too small: {zipInfo.Length} bytes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const long maxZipBytes = 50L * 1024 * 1024;
|
||||||
|
if (zipInfo.Length > maxZipBytes)
|
||||||
|
{
|
||||||
|
throw new Exception($"ZIP file exceeds 50MB cap: {zipInfo.Length} bytes (max {maxZipBytes})");
|
||||||
|
}
|
||||||
|
Console.WriteLine($" ZIP size within 50MB cap: {zipInfo.Length / 1024.0 / 1024.0:F2} MB");
|
||||||
|
|
||||||
Console.WriteLine("✓ Route with Tiles ZIP File Test: PASSED");
|
Console.WriteLine("✓ Route with Tiles ZIP File Test: PASSED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ class Program
|
|||||||
await ComplexRouteTests.RunComplexRouteWithStitchingAndGeofences(httpClient);
|
await ComplexRouteTests.RunComplexRouteWithStitchingAndGeofences(httpClient);
|
||||||
await ExtendedRouteTests.RunExtendedRouteEast(httpClient);
|
await ExtendedRouteTests.RunExtendedRouteEast(httpClient);
|
||||||
|
|
||||||
|
await SecurityTests.RunAll(httpClient);
|
||||||
|
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
Console.WriteLine("=========================");
|
Console.WriteLine("=========================");
|
||||||
Console.WriteLine("All tests completed successfully!");
|
Console.WriteLine("All tests completed successfully!");
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SatelliteProvider.IntegrationTests;
|
||||||
|
|
||||||
|
public static class SecurityTests
|
||||||
|
{
|
||||||
|
public static async Task RunAll(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
RouteTestHelpers.PrintTestHeader("Test: Security (SEC-01..SEC-04)");
|
||||||
|
|
||||||
|
await Sec01_SqlInjectionViaCoordinates(httpClient);
|
||||||
|
await Sec02_PathTraversalInTileServing(httpClient);
|
||||||
|
await Sec03_OversizedRegionRequest(httpClient);
|
||||||
|
await Sec04_MalformedJson(httpClient);
|
||||||
|
|
||||||
|
Console.WriteLine("✓ Security Tests: PASSED");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Sec01_SqlInjectionViaCoordinates(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("SEC-01: SQL injection attempt in coordinate query string");
|
||||||
|
|
||||||
|
var injection = "' OR 1=1 --";
|
||||||
|
var url = $"/api/satellite/tiles/latlon?Latitude={Uri.EscapeDataString(injection)}&Longitude=37.647063&ZoomLevel=18";
|
||||||
|
var response = await httpClient.GetAsync(url);
|
||||||
|
|
||||||
|
if (response.StatusCode != HttpStatusCode.BadRequest && response.StatusCode != HttpStatusCode.UnprocessableEntity)
|
||||||
|
{
|
||||||
|
throw new Exception($"SEC-01 expected 400/422 for non-numeric coordinate, got {(int)response.StatusCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($" ✓ Non-numeric coordinate rejected with HTTP {(int)response.StatusCode}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Sec02_PathTraversalInTileServing(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("SEC-02: Path traversal attempt against tile serving endpoint");
|
||||||
|
|
||||||
|
var traversalPaths = new[]
|
||||||
|
{
|
||||||
|
"/tiles/../../etc/passwd",
|
||||||
|
"/tiles/18/..%2F..%2Fetc%2Fpasswd/0",
|
||||||
|
"/tiles/18/0/..%2F..%2Fetc%2Fpasswd"
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (var path in traversalPaths)
|
||||||
|
{
|
||||||
|
var response = await httpClient.GetAsync(path);
|
||||||
|
var status = (int)response.StatusCode;
|
||||||
|
|
||||||
|
if (status == 200)
|
||||||
|
{
|
||||||
|
throw new Exception($"SEC-02 expected non-200 for traversal '{path}', got 200");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($" ✓ Traversal '{path}' rejected with HTTP {status}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Sec03_OversizedRegionRequest(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("SEC-03: Oversized region request (sizeMeters beyond allowed cap)");
|
||||||
|
|
||||||
|
var regionId = Guid.NewGuid();
|
||||||
|
var body = $"{{\"id\":\"{regionId}\",\"latitude\":47.461747,\"longitude\":37.647063,\"sizeMeters\":1000000,\"zoomLevel\":18,\"stitchTiles\":false}}";
|
||||||
|
var content = new StringContent(body, Encoding.UTF8, "application/json");
|
||||||
|
var response = await httpClient.PostAsync("/api/satellite/request", content);
|
||||||
|
var status = (int)response.StatusCode;
|
||||||
|
|
||||||
|
if (status != 400 && status != 422)
|
||||||
|
{
|
||||||
|
throw new Exception($"SEC-03 expected 400/422 for oversized region (1,000,000m), got {status}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($" ✓ Oversized region rejected with HTTP {status}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Sec04_MalformedJson(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("SEC-04: Malformed JSON body");
|
||||||
|
|
||||||
|
var malformed = "{ this is not json ::";
|
||||||
|
var content = new StringContent(malformed, Encoding.UTF8, "application/json");
|
||||||
|
var response = await httpClient.PostAsync("/api/satellite/request", content);
|
||||||
|
var status = (int)response.StatusCode;
|
||||||
|
|
||||||
|
if (status != 400 && status != 415 && status != 422)
|
||||||
|
{
|
||||||
|
throw new Exception($"SEC-04 expected 400/415/422 for malformed JSON, got {status}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($" ✓ Malformed JSON rejected with HTTP {status}");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
using FluentAssertions;
|
||||||
|
using Microsoft.Extensions.Logging.Abstractions;
|
||||||
|
using SatelliteProvider.Common.DTO;
|
||||||
|
using SatelliteProvider.Services;
|
||||||
|
|
||||||
|
namespace SatelliteProvider.Tests;
|
||||||
|
|
||||||
|
public class RegionRequestQueueTests
|
||||||
|
{
|
||||||
|
private static RegionRequest BuildRequest() => new()
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Latitude = 47.461747,
|
||||||
|
Longitude = 37.647063,
|
||||||
|
SizeMeters = 200,
|
||||||
|
ZoomLevel = 18,
|
||||||
|
StitchTiles = false
|
||||||
|
};
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnqueueAsync_RespectsCapacity_WritesUpToCapacityWithoutBlocking_RS04()
|
||||||
|
{
|
||||||
|
const int capacity = 10;
|
||||||
|
var queue = new RegionRequestQueue(capacity, NullLogger<RegionRequestQueue>.Instance);
|
||||||
|
|
||||||
|
for (var i = 0; i < capacity; i++)
|
||||||
|
{
|
||||||
|
await queue.EnqueueAsync(BuildRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.Count.Should().Be(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnqueueAsync_BlocksWhenAtCapacity_UntilDequeue_RL02()
|
||||||
|
{
|
||||||
|
const int capacity = 2;
|
||||||
|
var queue = new RegionRequestQueue(capacity, NullLogger<RegionRequestQueue>.Instance);
|
||||||
|
|
||||||
|
await queue.EnqueueAsync(BuildRequest());
|
||||||
|
await queue.EnqueueAsync(BuildRequest());
|
||||||
|
|
||||||
|
var overflow = queue.EnqueueAsync(BuildRequest()).AsTask();
|
||||||
|
var completedFirst = await Task.WhenAny(overflow, Task.Delay(150));
|
||||||
|
|
||||||
|
completedFirst.Should().NotBeSameAs(overflow, "overflow enqueue must wait while queue is full");
|
||||||
|
|
||||||
|
var dequeued = await queue.DequeueAsync();
|
||||||
|
dequeued.Should().NotBeNull();
|
||||||
|
|
||||||
|
await overflow.WaitAsync(TimeSpan.FromSeconds(1));
|
||||||
|
queue.Count.Should().Be(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task EnqueueAsync_HonorsCancellation_WhenFull()
|
||||||
|
{
|
||||||
|
var queue = new RegionRequestQueue(1, NullLogger<RegionRequestQueue>.Instance);
|
||||||
|
await queue.EnqueueAsync(BuildRequest());
|
||||||
|
|
||||||
|
using var cts = new CancellationTokenSource(TimeSpan.FromMilliseconds(150));
|
||||||
|
|
||||||
|
Func<Task> act = async () => await queue.EnqueueAsync(BuildRequest(), cts.Token);
|
||||||
|
|
||||||
|
await act.Should().ThrowAsync<OperationCanceledException>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task DequeueAsync_ReturnsItemsInFifoOrder()
|
||||||
|
{
|
||||||
|
var queue = new RegionRequestQueue(8, NullLogger<RegionRequestQueue>.Instance);
|
||||||
|
var first = BuildRequest();
|
||||||
|
var second = BuildRequest();
|
||||||
|
|
||||||
|
await queue.EnqueueAsync(first);
|
||||||
|
await queue.EnqueueAsync(second);
|
||||||
|
|
||||||
|
var dequeued1 = await queue.DequeueAsync();
|
||||||
|
var dequeued2 = await queue.DequeueAsync();
|
||||||
|
|
||||||
|
dequeued1!.Id.Should().Be(first.Id);
|
||||||
|
dequeued2!.Id.Should().Be(second.Id);
|
||||||
|
queue.Count.Should().Be(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
# Batch 3 Implementation Report
|
||||||
|
|
||||||
|
**Batch**: 3 of 3 (Implement Tests / Step 6)
|
||||||
|
**Date**: 2026-05-10
|
||||||
|
**Tasks**: AZ-289 (Integration tests: route map processing + ZIP), AZ-290 (Non-functional tests: perf, resilience, security, limits)
|
||||||
|
|
||||||
|
## Tasks
|
||||||
|
|
||||||
|
### AZ-289 — Integration tests: route map processing + ZIP
|
||||||
|
|
||||||
|
- **Spec**: `_docs/02_tasks/done/AZ-289_integration_route_maps.md`
|
||||||
|
- **Outcome**: Acceptance criteria met by existing integration tests; one assertion added.
|
||||||
|
- **Existing coverage**:
|
||||||
|
- BT-08 (RequestMaps=true → mapsReady, stitchedImagePath, csvFilePath) — `BasicRouteTests.RunRouteWithRegionProcessingAndStitching`, `ExtendedRouteTests.RunExtendedRouteEast`, `ExtendedRouteTests.RunRouteWithTilesZipTest`.
|
||||||
|
- BT-09 (ZIP entries == CSV count, directory structure preserved with `tiles/` prefix) — `ExtendedRouteTests.RunRouteWithTilesZipTest`.
|
||||||
|
- AC-1 (180s timeout) — `WaitForRouteReady(routeId, 180, 3000)` in the same test.
|
||||||
|
- AC-2 (ZIP structure) — entry-count + path-prefix assertions + directory depth check.
|
||||||
|
- **New addition**: 50 MB ZIP cap assertion in `ExtendedRouteTests.RunRouteWithTilesZipTest` (also satisfies AZ-290 / RL-01).
|
||||||
|
|
||||||
|
### AZ-290 — Non-functional tests
|
||||||
|
|
||||||
|
- **Spec**: `_docs/02_tasks/done/AZ-290_nonfunctional_tests.md`
|
||||||
|
- **Outcome**: All three ACs covered by a mix of new unit tests, new integration tests, an extended performance script, and existing tests cross-referenced below.
|
||||||
|
|
||||||
|
#### Performance (AC-1)
|
||||||
|
|
||||||
|
`scripts/run-performance-tests.sh` extended:
|
||||||
|
|
||||||
|
| Scenario | Threshold | Implementation |
|
||||||
|
|----------|-----------|----------------|
|
||||||
|
| PT-01 — Tile download (cold) | 30 000 ms | New: GET `/api/satellite/tiles/latlon` with offset coords |
|
||||||
|
| PT-02 — Cached tile retrieval | 500 ms | Existing |
|
||||||
|
| PT-03 — Region 200 m / z18 | 60 000 ms | New: POST `/api/satellite/request` + status poll |
|
||||||
|
| PT-04 — Region 500 m / z18 + stitch | 120 000 ms | New: POST `/api/satellite/request` (stitchTiles=true) + status poll |
|
||||||
|
| PT-05 — 5 concurrent regions | 300 000 ms | New: 5 parallel enqueues + wait-all loop |
|
||||||
|
| PT-06 — Route interpolation | 5 000 ms | Existing |
|
||||||
|
|
||||||
|
#### Resilience (AC-2)
|
||||||
|
|
||||||
|
| Scenario | Coverage |
|
||||||
|
|----------|----------|
|
||||||
|
| RS-01 — API starts with DB ready | Structural (Docker Compose `depends_on`, healthcheck) |
|
||||||
|
| RS-02 — Migrations run on fresh DB | Structural (DbUp on startup, `Program.cs`) |
|
||||||
|
| RS-03 — Region processing handles tile failures | Unit: `RegionServiceTests.ProcessRegionAsync_DownloaderFailure_TransitionsToFailedAndWritesErrorSummary` (Batch 2) |
|
||||||
|
| RS-04 — Queue capacity bounded behavior | Unit: `RegionRequestQueueTests.EnqueueAsync_BlocksWhenAtCapacity_UntilDequeue_RL02` and `EnqueueAsync_HonorsCancellation_WhenFull` (new). **Spec drift noted**: spec says "rejects overflow" but channel uses `BoundedChannelFullMode.Wait` → producer back-pressure. Tests assert actual behavior. To be reconciled in Step 12 (Test-Spec Sync). |
|
||||||
|
| RS-05 — Max 4 concurrent downloads | Configuration: `appsettings.json` `ProcessingConfig.MaxConcurrentDownloads = 4`; semaphore enforced inside `GoogleMapsDownloaderV2` |
|
||||||
|
| RS-06 — Route processing completes all regions | Existing: `ComplexRouteTests.RunComplexRouteWithStitching*`, `ExtendedRouteTests.RunExtendedRouteEast` |
|
||||||
|
|
||||||
|
#### Security (AC-3)
|
||||||
|
|
||||||
|
`SatelliteProvider.IntegrationTests/SecurityTests.cs` (new) wired into `Program.cs`:
|
||||||
|
|
||||||
|
| Scenario | Test |
|
||||||
|
|----------|------|
|
||||||
|
| SEC-01 — SQL injection via coordinates | `Sec01_SqlInjectionViaCoordinates` — non-numeric `Latitude` rejected (400/422) |
|
||||||
|
| SEC-02 — Path traversal in tile serving | `Sec02_PathTraversalInTileServing` — three traversal patterns all return non-200 |
|
||||||
|
| SEC-03 — Oversized region request | `Sec03_OversizedRegionRequest` — `sizeMeters=1_000_000` rejected (400/422) |
|
||||||
|
| SEC-04 — Malformed JSON | `Sec04_MalformedJson` — non-JSON body rejected (400/415/422) |
|
||||||
|
|
||||||
|
#### Resource Limits
|
||||||
|
|
||||||
|
| Scenario | Coverage |
|
||||||
|
|----------|----------|
|
||||||
|
| RL-01 — ZIP ≤ 50 MB | `ExtendedRouteTests.RunRouteWithTilesZipTest` new cap assertion |
|
||||||
|
| RL-02 — Queue capacity 1000 | `appsettings.json` `QueueCapacity: 1000`; bounded behavior verified by `RegionRequestQueueTests` |
|
||||||
|
| RL-03 — Concurrent download semaphore (4) | `appsettings.json` `MaxConcurrentDownloads: 4` |
|
||||||
|
| RL-04 — Concurrent region processing (20) | `appsettings.json` `MaxConcurrentRegions: 20` |
|
||||||
|
|
||||||
|
## Files Changed
|
||||||
|
|
||||||
|
```
|
||||||
|
SatelliteProvider.IntegrationTests/ExtendedRouteTests.cs
|
||||||
|
SatelliteProvider.IntegrationTests/SecurityTests.cs [new]
|
||||||
|
SatelliteProvider.IntegrationTests/Program.cs
|
||||||
|
SatelliteProvider.Tests/RegionRequestQueueTests.cs [new]
|
||||||
|
scripts/run-performance-tests.sh
|
||||||
|
_docs/02_tasks/todo/AZ-289_integration_route_maps.md → _docs/02_tasks/done/...
|
||||||
|
_docs/02_tasks/todo/AZ-290_nonfunctional_tests.md → _docs/02_tasks/done/...
|
||||||
|
_docs/03_implementation/reviews/batch_03_review.md [new]
|
||||||
|
_docs/03_implementation/batch_03_report.md [new]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Test Results
|
||||||
|
|
||||||
|
- Unit tests (Docker): **35 / 35 passed** (1.21 s).
|
||||||
|
- Integration test project build: **0 errors, 0 warnings**.
|
||||||
|
- Integration tests (full Compose runtime): deferred to Step 7 (Run Tests).
|
||||||
|
- Performance script (live API): deferred to Step 15 (Performance) per autodev flow.
|
||||||
|
|
||||||
|
## Code Review
|
||||||
|
|
||||||
|
`_docs/03_implementation/reviews/batch_03_review.md` — verdict: **PASS_WITH_WARNINGS**.
|
||||||
|
|
||||||
|
- Findings: 2 Low (RS-04 spec wording drift, time-based test heuristic). No Critical or High.
|
||||||
|
- Baseline delta: no new architecture findings; pre-existing High findings (F1, F2) remain resolved.
|
||||||
|
|
||||||
|
## Tracker Updates
|
||||||
|
|
||||||
|
- AZ-289 → In Testing
|
||||||
|
- AZ-290 → In Testing
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# Code Review Report
|
||||||
|
|
||||||
|
**Batch**: 3 — AZ-289 (Integration tests: route map processing + ZIP), AZ-290 (Non-functional tests: perf, resilience, security, limits)
|
||||||
|
**Date**: 2026-05-10
|
||||||
|
**Verdict**: PASS_WITH_WARNINGS
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
Changed files in this batch:
|
||||||
|
|
||||||
|
- `SatelliteProvider.IntegrationTests/ExtendedRouteTests.cs` — added 50 MB ZIP cap assertion (RL-01).
|
||||||
|
- `SatelliteProvider.IntegrationTests/SecurityTests.cs` — new file; SEC-01..SEC-04 integration tests.
|
||||||
|
- `SatelliteProvider.IntegrationTests/Program.cs` — wires `SecurityTests.RunAll` into the integration runner.
|
||||||
|
- `SatelliteProvider.Tests/RegionRequestQueueTests.cs` — new file; covers queue capacity behavior (RS-04 / RL-02 at unit level).
|
||||||
|
- `scripts/run-performance-tests.sh` — extended with PT-01, PT-03, PT-04, PT-05.
|
||||||
|
|
||||||
|
Existing integration tests (`BasicRouteTests.RunRouteWithRegionProcessingAndStitching`, `ExtendedRouteTests.RunRouteWithTilesZipTest`, `ComplexRouteTests.RunComplexRouteWithStitching*`) already covered BT-08 / BT-09 / RS-06 / RL-01 (capped now); no duplicates added.
|
||||||
|
|
||||||
|
## Findings
|
||||||
|
|
||||||
|
| # | Severity | Category | File:Line | Title |
|
||||||
|
|---|----------|----------|-----------|-------|
|
||||||
|
| 1 | Low | Spec-Gap | `_docs/02_tasks/todo/AZ-290_nonfunctional_tests.md:24` | RS-04 spec says "rejects overflow"; implementation `BoundedChannelFullMode.Wait` blocks instead |
|
||||||
|
| 2 | Low | Maintainability | `SatelliteProvider.Tests/RegionRequestQueueTests.cs:35` | Time-based blocking assertion uses a 150ms `Task.Delay` heuristic |
|
||||||
|
|
||||||
|
### Finding Details
|
||||||
|
|
||||||
|
**F1: RS-04 spec wording vs. implementation behavior** (Low / Spec-Gap)
|
||||||
|
- Location: `_docs/02_tasks/todo/AZ-290_nonfunctional_tests.md:24`
|
||||||
|
- Description: RS-04 reads "Queue rejects overflow (capacity 1000)". The actual queue uses `Channel.CreateBounded<>(BoundedChannelFullMode.Wait)` (`SatelliteProvider.Services/RegionRequestQueue.cs:17-20`), which blocks the producer rather than rejecting the request. The unit tests assert the actually-implemented behavior (block + cancellable wait). Spec needs to be updated to "Queue back-pressures producer when full" in Step 12 (Test-Spec Sync).
|
||||||
|
- Suggestion: Fix in Step 12; do not change runtime behavior — back-pressure is the correct choice for an in-process producer/consumer.
|
||||||
|
- Task: AZ-290
|
||||||
|
|
||||||
|
**F2: Time-based assertion in capacity-block test** (Low / Maintainability)
|
||||||
|
- Location: `SatelliteProvider.Tests/RegionRequestQueueTests.cs:35-46` (`EnqueueAsync_BlocksWhenAtCapacity_UntilDequeue_RL02`)
|
||||||
|
- Description: The test relies on a 150 ms `Task.Delay` race to confirm that the third `EnqueueAsync` does not complete while the queue is full. This is a small heuristic risk on heavily loaded CI agents. Risk is low because the operation only completes after a real `DequeueAsync`, and the subsequent `WaitAsync(1s)` covers slow paths.
|
||||||
|
- Suggestion: Acceptable as-is; revisit if the test ever flakes on CI.
|
||||||
|
- Task: AZ-290
|
||||||
|
|
||||||
|
## Acceptance Criteria Coverage
|
||||||
|
|
||||||
|
### AZ-289
|
||||||
|
|
||||||
|
| AC | Coverage | Evidence |
|
||||||
|
|----|----------|----------|
|
||||||
|
| AC-1 — Route map processing completes within 180s | Existing | `WaitForRouteReady(routeId, 180, 3000)` in `RunRouteWithTilesZipTest` |
|
||||||
|
| AC-2 — ZIP structure validated (entry count = CSV, path prefix `tiles/`) | Existing + reinforced | Entry count check, `firstEntry.FullName.StartsWith("tiles/")`, plus new 50 MB cap |
|
||||||
|
|
||||||
|
### AZ-290
|
||||||
|
|
||||||
|
| AC | Coverage | Evidence |
|
||||||
|
|----|----------|----------|
|
||||||
|
| AC-1 — Performance script passes thresholds | New | `scripts/run-performance-tests.sh` covers PT-01..PT-06 with `check_threshold` per scenario |
|
||||||
|
| AC-2 — Resilience tests verify state transitions and resource limits | Mixed (unit + integration + structural) | RS-03 in `RegionServiceTests.ProcessRegionAsync_DownloaderFailure_TransitionsToFailedAndWritesErrorSummary` (Batch 2); RS-04 / RL-02 in new `RegionRequestQueueTests`; RS-01 / RS-02 covered by Docker startup + `DbUp` migrations; RS-05 (semaphore) and RL-03 / RL-04 (concurrency caps) verified structurally via `appsettings.json` (`MaxConcurrentDownloads: 4`, `MaxConcurrentRegions: 20`, `QueueCapacity: 1000`); RS-06 covered by existing `ComplexRouteTests` |
|
||||||
|
| AC-3 — Security tests confirm no injection or traversal vulnerabilities | New | `SecurityTests.cs` runs SEC-01 (non-numeric coord rejected), SEC-02 (multiple traversal attempts rejected), SEC-03 (oversized region rejected), SEC-04 (malformed JSON rejected) |
|
||||||
|
|
||||||
|
## Test Run
|
||||||
|
|
||||||
|
- Unit tests: 35 passed / 0 failed (Docker `mcr.microsoft.com/dotnet/sdk:8.0`).
|
||||||
|
- Integration test project: builds clean (0 warnings, 0 errors); runtime execution deferred to Step 7 (Run Tests) since it requires the full Docker Compose stack and a Google Maps API key.
|
||||||
|
|
||||||
|
## Baseline Delta
|
||||||
|
|
||||||
|
No new architecture findings. The two High findings from `architecture_compliance_baseline.md` (F1: TileService concrete dependency, F2: ISatelliteDownloader dead code) were both resolved by the earlier testability refactor that landed in the autodev baseline commit and remain resolved at the end of this batch.
|
||||||
|
|
||||||
|
## Verdict Rationale
|
||||||
|
|
||||||
|
No Critical or High findings. Two Low findings (spec wording drift, time-based test heuristic) are non-blocking and tracked for follow-up. Verdict: **PASS_WITH_WARNINGS** — proceed to commit.
|
||||||
@@ -8,7 +8,7 @@ status: in_progress
|
|||||||
sub_step:
|
sub_step:
|
||||||
phase: 14
|
phase: 14
|
||||||
name: batch-loop
|
name: batch-loop
|
||||||
detail: "batch 3 of 3 — AZ-289 + AZ-290 integration & non-functional"
|
detail: "batch 3/3 — implementing"
|
||||||
retry_count: 0
|
retry_count: 0
|
||||||
cycle: 1
|
cycle: 1
|
||||||
tracker: jira
|
tracker: jira
|
||||||
|
|||||||
@@ -31,6 +31,40 @@ check_threshold() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait_region_completed() {
|
||||||
|
local region_id="$1"
|
||||||
|
local timeout_s="${2:-180}"
|
||||||
|
local elapsed=0
|
||||||
|
while (( elapsed < timeout_s )); do
|
||||||
|
local status
|
||||||
|
status=$(curl -s "$API_URL/api/satellite/region/$region_id" | grep -o '"status":"[^"]*"' | head -1 || true)
|
||||||
|
case "$status" in
|
||||||
|
*completed*) return 0 ;;
|
||||||
|
*failed*) echo " region $region_id failed during wait" >&2; return 2 ;;
|
||||||
|
esac
|
||||||
|
sleep 2
|
||||||
|
elapsed=$((elapsed + 2))
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# PT-01: Tile download latency for a fresh tile (cold path).
|
||||||
|
# Uses lat/lon offset so the cache miss is likely; threshold 30s.
|
||||||
|
echo "PT-01: Tile Download Latency (cold) (threshold: 30000ms)"
|
||||||
|
PT01_LAT="47.461347"
|
||||||
|
PT01_LON="37.646663"
|
||||||
|
START=$(date +%s%N)
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/api/satellite/tiles/latlon?Latitude=$PT01_LAT&Longitude=$PT01_LON&ZoomLevel=18")
|
||||||
|
END=$(date +%s%N)
|
||||||
|
ELAPSED_MS=$(( (END - START) / 1000000 ))
|
||||||
|
if [[ "$HTTP_CODE" == "200" ]]; then
|
||||||
|
check_threshold "Tile download (cold)" "$ELAPSED_MS" 30000
|
||||||
|
else
|
||||||
|
echo " ✗ PT-01: HTTP $HTTP_CODE (expected 200)"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
echo "PT-02: Cached Tile Retrieval Latency (threshold: 500ms)"
|
echo "PT-02: Cached Tile Retrieval Latency (threshold: 500ms)"
|
||||||
START=$(date +%s%N)
|
START=$(date +%s%N)
|
||||||
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/api/satellite/tiles/latlon?Latitude=47.461747&Longitude=37.647063&ZoomLevel=18")
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/api/satellite/tiles/latlon?Latitude=47.461747&Longitude=37.647063&ZoomLevel=18")
|
||||||
@@ -44,6 +78,83 @@ else
|
|||||||
FAIL=$((FAIL + 1))
|
FAIL=$((FAIL + 1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# PT-03: Region 200m at zoom 18, no stitching, threshold 60s end-to-end.
|
||||||
|
echo ""
|
||||||
|
echo "PT-03: Region Processing 200m / zoom 18 (threshold: 60000ms)"
|
||||||
|
PT03_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
|
||||||
|
PT03_BODY="{\"id\":\"$PT03_ID\",\"latitude\":47.461747,\"longitude\":37.647063,\"sizeMeters\":200,\"zoomLevel\":18,\"stitchTiles\":false}"
|
||||||
|
START=$(date +%s%N)
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$PT03_BODY" "$API_URL/api/satellite/request")
|
||||||
|
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "202" ]]; then
|
||||||
|
if wait_region_completed "$PT03_ID" 60; then
|
||||||
|
END=$(date +%s%N)
|
||||||
|
ELAPSED_MS=$(( (END - START) / 1000000 ))
|
||||||
|
check_threshold "Region 200m/z18" "$ELAPSED_MS" 60000
|
||||||
|
else
|
||||||
|
echo " ✗ PT-03: region did not complete within 60s"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ✗ PT-03: enqueue HTTP $HTTP_CODE (expected 200/202)"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# PT-04: Region 500m at zoom 18 with stitching, threshold 120s end-to-end.
|
||||||
|
echo ""
|
||||||
|
echo "PT-04: Region Processing 500m / zoom 18 + stitch (threshold: 120000ms)"
|
||||||
|
PT04_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
|
||||||
|
PT04_BODY="{\"id\":\"$PT04_ID\",\"latitude\":47.461747,\"longitude\":37.647063,\"sizeMeters\":500,\"zoomLevel\":18,\"stitchTiles\":true}"
|
||||||
|
START=$(date +%s%N)
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$PT04_BODY" "$API_URL/api/satellite/request")
|
||||||
|
if [[ "$HTTP_CODE" == "200" || "$HTTP_CODE" == "202" ]]; then
|
||||||
|
if wait_region_completed "$PT04_ID" 120; then
|
||||||
|
END=$(date +%s%N)
|
||||||
|
ELAPSED_MS=$(( (END - START) / 1000000 ))
|
||||||
|
check_threshold "Region 500m/z18 stitched" "$ELAPSED_MS" 120000
|
||||||
|
else
|
||||||
|
echo " ✗ PT-04: region did not complete within 120s"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo " ✗ PT-04: enqueue HTTP $HTTP_CODE (expected 200/202)"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
# PT-05: 5 concurrent regions all complete within 5min (300s) end-to-end.
|
||||||
|
echo ""
|
||||||
|
echo "PT-05: Concurrent Region Processing (5 in 300000ms)"
|
||||||
|
PT05_IDS=()
|
||||||
|
PT05_START=$(date +%s%N)
|
||||||
|
for i in 1 2 3 4 5; do
|
||||||
|
rid=$(uuidgen | tr '[:upper:]' '[:lower:]')
|
||||||
|
PT05_IDS+=("$rid")
|
||||||
|
LAT=$(awk "BEGIN { printf \"%.6f\", 47.461747 + 0.001 * $i }")
|
||||||
|
LON=$(awk "BEGIN { printf \"%.6f\", 37.647063 + 0.001 * $i }")
|
||||||
|
BODY="{\"id\":\"$rid\",\"latitude\":$LAT,\"longitude\":$LON,\"sizeMeters\":200,\"zoomLevel\":18,\"stitchTiles\":false}"
|
||||||
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST -H "Content-Type: application/json" -d "$BODY" "$API_URL/api/satellite/request")
|
||||||
|
if [[ "$HTTP_CODE" != "200" && "$HTTP_CODE" != "202" ]]; then
|
||||||
|
echo " ✗ PT-05: enqueue $i HTTP $HTTP_CODE (expected 200/202)"
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
PT05_OK=1
|
||||||
|
for rid in "${PT05_IDS[@]}"; do
|
||||||
|
if ! wait_region_completed "$rid" 300; then
|
||||||
|
PT05_OK=0
|
||||||
|
echo " ✗ PT-05: region $rid did not complete within 300s"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if (( PT05_OK == 1 )); then
|
||||||
|
PT05_END=$(date +%s%N)
|
||||||
|
ELAPSED_MS=$(( (PT05_END - PT05_START) / 1000000 ))
|
||||||
|
check_threshold "5 concurrent regions" "$ELAPSED_MS" 300000
|
||||||
|
else
|
||||||
|
FAIL=$((FAIL + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "PT-06: Route Point Interpolation Speed (threshold: 5000ms)"
|
echo "PT-06: Route Point Interpolation Speed (threshold: 5000ms)"
|
||||||
ROUTE_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
|
ROUTE_ID=$(uuidgen | tr '[:upper:]' '[:lower:]')
|
||||||
|
|||||||
Reference in New Issue
Block a user