Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 23, 2025

This PR implements a new GitHub Actions workflow to run Cosmos DB unit tests on Linux using the official Cosmos DB emulator docker containers, enabling Linux developers to perform local testing and development with both current and preview emulator versions.

Changes Made

New Workflow: .github/workflows/linux-cosmos-emulator-test.yml

Key Features:

  • Platform: Runs on ubuntu-latest
  • Matrix Strategy: Tests against both current stable and vnext preview emulator versions
  • Container Images:
    • Current: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest
    • Vnext: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview
  • Networking: Configures all required ports (8081, 10251-10254) for Cosmos DB emulator
  • Health Checks: Comprehensive monitoring to ensure emulator readiness before running tests
  • SSL Certificates: Automatic import of emulator certificates for secure HTTPS connections
  • Environment Setup: Properly configured Cosmos_Endpoint and Cosmos_Key environment variables
  • Failure Tolerance: Vnext emulator tests are allowed to fail without breaking the workflow

Workflow Triggers:

  • Manual execution via workflow_dispatch
  • Automatic on PRs affecting Cosmos extension code (Extensions/Cosmos/**)
  • Self-triggering when workflow file changes

Test Execution:

  • Targets specifically the Cosmos extension unit tests: ./Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/
  • Tests detect emulator availability through environment variables and skip gracefully if not present
  • Includes connectivity validation and detailed logging
  • Uses the same environment variable pattern as existing Windows emulator workflow

Benefits

  1. Cross-Platform Development: Enables Linux developers to run full Cosmos DB integration tests locally
  2. CI/CD Coverage: Verifies DMT functionality works correctly with Cosmos DB emulator on Linux
  3. Preview Testing: Tests against vnext emulator in preview without breaking builds if unstable
  4. Consistency: Uses same test patterns and environment setup as existing Windows workflow
  5. Minimal Impact: Focused only on Cosmos extension tests, doesn't affect other workflows

Testing

  • ✅ Verified environment variable detection works correctly
  • ✅ Confirmed tests behave appropriately (skip when no emulator, run when available)
  • ✅ Validated YAML syntax and GitHub Actions compatibility
  • ✅ Tested against existing repository patterns and conventions
  • ✅ Added matrix strategy for testing both current and vnext emulator versions

The workflow complements the existing cosmos_db_emulator.yml (Windows) workflow and provides the same testing capabilities for Linux environments with additional coverage for preview emulator versions.

Fixes #196.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

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
Copilot AI requested a review from philnach July 23, 2025 04:11
Copilot finished work on behalf of philnach July 23, 2025 04:11
Copy link
Collaborator

@philnach philnach left a comment

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
Collaborator

@philnach philnach left a comment

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 philnach marked this pull request as ready for review July 27, 2025 12:59
@philnach
Copy link
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?

Copy link
Contributor Author

Copilot AI commented Jul 30, 2025

@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
Copilot finished work on behalf of philnach July 30, 2025 03:28
Copilot AI requested a review from philnach July 30, 2025 03:28
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.

Run tests on Linux using Cosmos DB emulator docker container

2 participants