Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/linux-cosmos-emulator-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Linux .NET test with Cosmos DB Emulator
on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
paths:
- 'Extensions/Cosmos/**'
- '.github/workflows/linux-cosmos-emulator-test.yml'

jobs:
cosmos_tests_linux:
name: Run Cosmos .NET unit tests on Linux (${{ matrix.emulator_version.name }})
runs-on: ubuntu-latest
strategy:
matrix:
emulator_version: [
{
name: "current",
image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest",
allow_failure: false,
protocol: "https",
endpoint_port: 8081,
explorer_port: 8081,
use_https: true
},
{
name: "vnext",
image: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:vnext-preview",
allow_failure: true,
protocol: "http",
endpoint_port: 8081,
explorer_port: 1234,
use_https: false
}
]
fail-fast: false
continue-on-error: ${{ matrix.emulator_version.allow_failure }}
services:
cosmos-emulator:
image: ${{ matrix.emulator_version.image }}
ports:
- 8081:8081
- 1234:1234
- 10251:10251
- 10252:10252
- 10253:10253
- 10254:10254
env:
AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 10
AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: false
AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE: 127.0.0.1
# TCP port check works for both HTTP (vnext) and HTTPS (current) emulators
options: >-
--health-cmd="timeout 5 bash -c 'cat < /dev/null > /dev/tcp/127.0.0.1/8081' || exit 1"
--health-interval=20s
--health-timeout=10s
--health-retries=20
--health-start-period=120s
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore

- name: Wait for Cosmos Emulator
run: |
echo "Waiting for Cosmos DB Emulator (${{ matrix.emulator_version.name }}) to be ready..."
if [ "${{ matrix.emulator_version.use_https }}" == "true" ]; then
timeout 600 bash -c 'until curl -f -k https://127.0.0.1:8081/_explorer/emulator.pem; do sleep 5; done'
else
timeout 600 bash -c 'until curl -f http://127.0.0.1:8081/; do sleep 5; done'
fi
echo "Cosmos DB Emulator is ready!"

- name: Import Cosmos Emulator Certificate
if: matrix.emulator_version.use_https == true
run: |
curl -k https://127.0.0.1:8081/_explorer/emulator.pem > ~/emulatorcert.crt
sudo cp ~/emulatorcert.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates

- name: Run Cosmos Extension Tests
run: |
echo "Running Cosmos extension unit tests with emulator connection (${{ matrix.emulator_version.name }})..."
echo "Cosmos_Endpoint: $Cosmos_Endpoint"
echo "Testing connectivity to emulator..."
if [ "${{ matrix.emulator_version.use_https }}" == "true" ]; then
curl -k -s https://127.0.0.1:8081/_explorer/index.html > /dev/null && echo "Emulator is responding" || echo "Warning: Emulator may not be fully ready"
else
curl -s http://127.0.0.1:8081/ > /dev/null && echo "Emulator is responding" || echo "Warning: Emulator may not be fully ready"
fi
dotnet test ./Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/ --no-build --verbosity normal
env:
Cosmos_Endpoint: ${{ matrix.emulator_version.protocol }}://127.0.0.1:8081/
Cosmos_Key: C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
Loading