Skip to content

Add Linux workflow for testing with Cosmos DB emulator docker container (current and vnext) - #197

Merged
Mark Brown (markjbrown) merged 15 commits into
mainfrom
copilot/fix-196
Oct 13, 2026
Merged

Mark Brown (markjbrown) merged 15 commits into
mainfrom
copilot/fix-196

Conversation

Copilot AI commented Jul 23, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Add Linux CI coverage for the current and vNext Cosmos DB emulators, with reliable integration-test execution checks. This branch includes current main (f22439ff9a8e3ae150a9dce2f2cdb4774c1baa34) through a non-history-rewriting merge; no production application code is changed relative to main.

Changes

  • Test mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest and :vnext-latest over HTTPS. The .NET SDK does not support vNext HTTP mode. Configure PROTOCOL=https, use Gateway mode, and explicitly disable bulk execution for these JSON round-trip tests. See Microsoft's vNext emulator documentation.
  • Wait up to ten minutes for the current emulator's certificate endpoint or vNext's documented http://localhost:8080/ready probe. Import the certificate into the runner trust store and verify HTTPS without disabling certificate validation for the SDK.
  • Preserve the intentional policy: the current emulator and failure-guard job fail the workflow on errors; the vNext preview job remains advisory through continue-on-error. Inspect the actual preview job and test outcomes, not just the overall workflow conclusion.
  • Replace the test fixture's swallowed initialization errors with asynchronous class initialization. No emulator configuration still permits local skips; partial configuration or connection/database initialization failures fail the tests. Use class-level database cleanup and a bounded two-minute deletion allowance.
  • Require exactly one passing result for each of Test_Json_RoundTrip_WithLongValues and Test_FromJson_WithLongValues in both Linux and Windows emulator workflows. Missing, duplicate, skipped, or failed results fail the verification step.
  • Add an emulator-free regression job covering absent/partial configuration, unreachable endpoints, and missing/duplicate/failed/skipped TRX results. Preserve TRX artifacts, per-test job summaries, and Linux container diagnostics.
  • Document test configuration and emulator limitations in the Cosmos extension README.

Verified results

Final pushed commit: 06a3b2e51cb81d3b7c45ea313063782eb14ee01e. Counts below were checked against the downloaded TRX test records, not inferred from workflow status.

Validation Result Evidence
Linux current emulator 109 passed, 0 failed, 0 skipped; both required integration tests passed Manual exact-SHA run
Linux vNext emulator 109 passed, 0 failed, 0 skipped; both required integration tests passed Manual exact-SHA run
Repeated Linux PR matrix Both emulators again passed all 109 tests, including both integrations; guard job passed PR run
Windows emulator 109 passed, 0 failed, 0 skipped; both required integration tests passed Windows run
Failure-guard regression No configuration: 2 intentional skips rejected by the gate. Missing endpoint, missing key, and unreachable endpoint: each produced 2 failures and a nonzero test exit. Missing/duplicate/empty results and missing TRX were rejected; a synthetic passing fixture was accepted. Guard job
Build and test all .NET projects Passed PR build/test
Validate all .NET projects 377 passed, 4 existing optional integration skips, 0 failed across 381 tests Validation run
Self-contained packages All six Windows/macOS/Linux x64/arm64 builds passed Package matrix

Local focused Cosmos tests also passed (107 unit tests, 2 expected no-emulator skips), negative cases passed, and both changed workflows passed actionlint.

An earlier repair run surfaced a stable-emulator database cleanup timeout at 30 seconds. The final commit increases that bounded allowance to two minutes without swallowing failures; both subsequent Linux matrix runs passed. The preview still has documented SDK/feature limitations: this validates JSON round trips, not bulk execution or authentication enforcement. Existing compiler/package warnings remain unchanged.

The PR remains draft. No approval, readiness, merge, release, deployment, or publication action was taken.

Copilot AI and others added 2 commits July 23, 2025 04:08
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
…nectivity checks

Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Copilot AI changed the title [WIP] Run tests on Linux using Cosmos DB emulator docker container Add Linux workflow for testing with Cosmos DB emulator docker container Jul 23, 2025

@philnach Phil Nachreiner (philnach) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot , where do the tests target the emulator?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good and verified works by running the action.

@philnach
Phil Nachreiner (philnach) marked this pull request as ready for review July 27, 2025 12:59
@philnach

Copy link
Copy Markdown
Collaborator

Copilot, the vnext Cosmos DB emulator is in preview see: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux. Can you update the PR to also run against the vnet emulator, but don't fail if the tests don't past?

Copilot AI commented Jul 30, 2025 •

Copy link
Copy Markdown
Contributor Author

Copilot , where do the tests target the emulator?

The tests target the emulator through environment variables:

  1. Environment Variables: The workflow sets Cosmos_Endpoint=https://127.0.0.1:8081/ and Cosmos_Key to the default emulator key
  2. Test Logic: In CosmosDataSourceExtensionTests.cs, the static constructor checks for these environment variables:
    • If missing → skips tests with "Connection details for Cosmos DB not found. Ignoring tests..."
    • If present → creates a CosmosClient using those connection details to connect to the emulator
  3. Service Configuration: The workflow runs the emulator container with ports 8081, 10251-10254 exposed and waits for it to be ready before running tests

This follows the same pattern as the existing Windows workflow (cosmos_db_emulator.yml) which sets identical environment variables.

Copilot, the vnext Cosmos DB emulator is in preview see: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux. Can you update the PR to also run against the vnet emulator, but don't fail...

Updated the workflow to test against both emulator versions using a matrix strategy:

  • Current: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest (must pass)
  • Vnext: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview (allowed to fail)

The vnext tests use continue-on-error: true and fail-fast: false so they won't break the workflow if they fail. Each job shows which emulator version it's running against in the job name.

Commit: 1718e27

Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Copilot AI changed the title Add Linux workflow for testing with Cosmos DB emulator docker container Add Linux workflow for testing with Cosmos DB emulator docker container (current and vnext) Jul 30, 2025
@philnach
Phil Nachreiner (philnach) marked this pull request as draft December 5, 2025 13:38
@philnach

Copy link
Copy Markdown
Collaborator

Copilot, the test is failing because there isn't enough wait time for the container. Can you take a look at the failure and fix it?

…B emulator

Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>

Copilot AI commented Dec 23, 2025

Copy link
Copy Markdown
Contributor Author

Copilot, the test is failing because there isn't enough wait time for the container. Can you take a look at the failure and fix it?

I've identified and fixed the container initialization timeout issue. The vnext emulator container was taking longer than 5 minutes to start, causing the health checks to fail.

Changes made in commit 77045dc:

  • Added --health-start-period=120s to give the container 2 minutes before health checks start counting as failures
  • Increased health check retries from 10 to 20
  • Decreased health check interval from 30s to 20s (checks more frequently)
  • Increased the "Wait for Cosmos Emulator" timeout from 300s to 600s (10 minutes total wait time)

This gives the container up to ~8.7 minutes to become healthy (120s start period + 20 retries × 20s intervals), which should be sufficient for the vnext emulator to fully initialize.

@philnach

Copy link
Copy Markdown
Collaborator

Copilot, the vnext emulator doesn't easily support HTTPS with .net. Can you use http:// protocol when connecting to the vnext emulator. You also cannot download the pem file. This means don't attempt to try and pull down the pem url for the vnext emulator. Also, the vnext emulator has two port configurations the endpoint which is on port 8081 and the explorer port which is on 1234. Can you update the test to target the vnext emulator in this fashion? See this page for more information on the vnext emulator: https://learn.microsoft.com/en-us/azure/cosmos-db/emulator-linux

Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>

Copilot AI commented Dec 24, 2025

Copy link
Copy Markdown
Contributor Author

Copilot, the vnext emulator doesn't easily support HTTPS with .net. Can you use http:// protocol when connecting to the vnext emulator. You also cannot download the pem file. This means don't attem...

Updated the workflow to support vnext emulator's HTTP-only configuration in commit 2314467:

Key changes:

  • Vnext emulator now uses http://127.0.0.1:8081/ instead of HTTPS
  • Added explorer port 1234 to service ports
  • Certificate import step now skips for vnext (only runs for current/HTTPS emulator)
  • Health check changed to simple HTTP endpoint check (works for both versions)
  • Wait step conditionally checks HTTPS PEM endpoint for current or HTTP root for vnext
  • Connectivity test uses appropriate protocol based on emulator version
  • Matrix configuration differentiates protocol, ports, and HTTPS usage between versions

Copilot AI and others added 2 commits December 24, 2025 21:30
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: philnach <19275540+philnach@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4e24c294-5f06-491a-9097-3183ee8b3eff
Merge current main separately, use documented vNext HTTPS readiness and trusted certificates, and retain preview advisory policy. Make configured initialization failures visible and verify both integration results in Linux and Windows CI with negative regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4e24c294-5f06-491a-9097-3183ee8b3eff
The stable Linux emulator exceeded the 30-second cleanup deadline after the round-trip assertions passed. Allow two minutes for database deletion while retaining failure propagation and the workflow test timeout.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 4e24c294-5f06-491a-9097-3183ee8b3eff
@markjbrown
Mark Brown (markjbrown) marked this pull request as ready for review October 13, 2026 13:33
@markjbrown
Mark Brown (markjbrown) merged commit 9474fec into main Oct 13, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants