Skip to content

Commit c337965

Browse files
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent a21e267 commit c337965

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

.agents/skills/cosmos-provider/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Non-relational provider with its own parallel query pipeline. Uses JSON for docu
2323

2424
## Azure Cosmos DB Emulator in Docker
2525

26-
Cosmos tests run on Helix via Docker sidecar containers:
26+
Cosmos tests on Helix start the emulator from the work item via `PreCommands` that run a Docker container using:
2727
- `eng/testing/run-cosmos-container.ps1`
2828
- `eng/testing/run-cosmos-container.sh`
2929

eng/testing/run-cosmos-container.ps1

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ Write-Host "Pulling image: $image"
1414
docker pull $image
1515
if ($LASTEXITCODE -ne 0) { throw "docker pull failed with exit code $LASTEXITCODE" }
1616

17+
Write-Host "Checking for existing container named $containerName..."
18+
$existingContainerId = docker ps -a --filter "name=^${containerName}$" --format '{{.ID}}'
19+
if ($LASTEXITCODE -ne 0) { throw "docker ps failed with exit code $LASTEXITCODE" }
20+
if ($existingContainerId) {
21+
Write-Host "Existing container '$containerName' found. Stopping and removing it..."
22+
docker stop $containerName 2>$null
23+
docker rm -f $containerName
24+
if ($LASTEXITCODE -ne 0) { throw "docker rm failed with exit code $LASTEXITCODE" }
25+
}
26+
1727
# -t is required because Start.ps1 sets [Console]::BufferWidth which needs a TTY handle.
1828
Write-Host "Starting Cosmos DB Emulator container on port $port..."
1929
docker run -d -t `
@@ -27,14 +37,11 @@ Write-Host "Waiting for emulator to be ready (up to $($maxRetries * $retryDelayS
2737
$ready = $false
2838
for ($i = 0; $i -lt $maxRetries; $i++) {
2939
Start-Sleep -Seconds $retryDelaySec
30-
try {
31-
# Any HTTP response (even 401) means the emulator is up and accepting connections.
32-
$null = Invoke-WebRequest -Uri "https://localhost:${port}/" -UseBasicParsing -TimeoutSec 5
33-
$ready = $true
34-
} catch [Microsoft.PowerShell.Commands.HttpResponseException] {
35-
# Got an HTTP error response (401, 404, etc.) — emulator is reachable.
40+
# Any HTTP response (even 401) means the emulator is up and accepting connections.
41+
$null = & curl.exe -k "https://localhost:${port}/" --silent --output NUL --max-time 5
42+
if ($LASTEXITCODE -eq 0) {
3643
$ready = $true
37-
} catch {
44+
} else {
3845
Write-Host " Attempt $($i+1)/$maxRetries - not ready yet..."
3946
}
4047
if ($ready) {

0 commit comments

Comments
 (0)