Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.2k
.NET: chore: support retries on Cosmos storage creation#402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
c3f6f5c
support retries
DeagleGross a4922fb
Merge branch 'main' into dmkorolev/cosmos-retries
DeagleGross c4b247f
tests + registration options
DeagleGross 56e469c
Merge branch 'main' into dmkorolev/cosmos-retries
DeagleGross c9de82c
fix ordering ..
DeagleGross 200b699
Merge branch 'dmkorolev/cosmos-retries' of https://github.com/microso…
DeagleGross 68a69e9
HK + update packages
DeagleGross 9bdb789
Merge branch 'main' into dmkorolev/partition-key
DeagleGross 362aa5d
fix paths
DeagleGross 65407d1
Update dotnet/tests/CosmosDB.IntegrationTests/Microsoft.Extensions.AI…
DeagleGross c602bec
Merge branch 'main' into dmkorolev/partition-key
DeagleGross 30b254f
Merge branch 'main' into dmkorolev/partition-key
DeagleGross fb02856
Merge branch 'main' into dmkorolev/partition-key
DeagleGross ba92aa4
re create project and fix some pk usage
DeagleGross c55344b
fix all tests
DeagleGross fefabd4
try workflow?
DeagleGross d5ece1d
wip 1
DeagleGross dbe5230
fix definition
DeagleGross 7166b30
try with cosmos_use_emulator env?
DeagleGross 546181b
Merge branch 'main' into dmkorolev/partition-key
DeagleGross 04e5eaf
try ignore SSL errors?
DeagleGross f9a1ec3
other cert verifications
DeagleGross e51342b
hardcode to 8081?
DeagleGross edd8013
proper valuation of ENV
DeagleGross 6823c96
logging
DeagleGross 7a8338a
ensure db exsists for CI
DeagleGross 4f82ae1
bump
DeagleGross 9740f55
cleanup
DeagleGross 5ca3217
fix usage
DeagleGross b8d03ea
nit comment
DeagleGross f7fff63
try only release for stability?
DeagleGross 5e8eadc
Merge branch 'main' into dmkorolev/partition-key
DeagleGross df9a09e
try skip some flaky tests
DeagleGross 62cffe8
merge main
DeagleGross a97693b
merge fixes + rollback container
DeagleGross 4d91baf
reimplement with iasyncdisposable pattern
DeagleGross 682decc
Merge branch 'main' into dmkorolev/cosmos-retries
DeagleGross a5489d9
Merge branch 'main' into dmkorolev/cosmos-retries
DeagleGross b693e26
remove example doc struct
DeagleGross File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
158 changes: 158 additions & 0 deletions
158 .github/workflows/dotnet-cosmosdb-integration-tests.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| # | ||
| # This workflow runs Cosmos DB integration tests using the Cosmos DB emulator. | ||
| # | ||
| name: dotnet-cosmosdb-integration-tests | ||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| branches: ["main", "feature*"] | ||
| paths: | ||
| - dotnet/tests/CosmosDB.IntegrationTests/** | ||
| - dotnet/src/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB/** | ||
| - '.github/workflows/dotnet-cosmosdb-integration-tests.yml' | ||
| merge_group: | ||
| branches: ["main"] | ||
| push: | ||
| branches: ["main", "feature*"] | ||
| paths: | ||
| - dotnet/tests/CosmosDB.IntegrationTests/** | ||
| - dotnet/src/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB/** | ||
| - '.github/workflows/dotnet-cosmosdb-integration-tests.yml' | ||
| schedule: | ||
| - cron: "0 2 * * *" # Run at 2 AM UTC daily | ||
| env: | ||
| COSMOSDB_TESTS_USE_EMULATOR_CICD: "true" | ||
| jobs: | ||
| build-and-test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - { targetFramework: "net9.0", os: "ubuntu-latest", configuration: Release } | ||
| # - { targetFramework: "net9.0", os: "ubuntu-latest", configuration: Debug } | ||
| services: | ||
| cosmosdb: | ||
| image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest | ||
| ports: | ||
| - 8081:8081 | ||
| env: | ||
| AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: "false" | ||
| AZURE_COSMOS_EMULATOR_PARTITION_COUNT: "20" # the more the better for stable tests | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: | | ||
| . | ||
| .github | ||
| dotnet | ||
| - name: Setup dotnet | ||
| uses: actions/setup-dotnet@v4.3.1 | ||
| with: | ||
| global-json-file: ${{ github.workspace }}/dotnet/global.json | ||
| - name: Build dotnet solutions | ||
| shell: bash | ||
| run: | | ||
| export SOLUTIONS=$(find ./dotnet/ -type f -name "*.slnx" | tr '\n' ' ') | ||
| for solution in $SOLUTIONS; do | ||
| dotnet build $solution -c ${{ matrix.configuration }} --warnaserror | ||
| done | ||
| - name: Package install check | ||
| shell: bash | ||
| # All frameworks are only built for the release configuration, so we only run this step for the release configuration | ||
| # and dotnet new doesn't support net472 | ||
| if: matrix.configuration == 'Release' && matrix.targetFramework != 'net472' | ||
| run: | | ||
| TEMP_DIR=$(mktemp -d) | ||
| export SOLUTIONS=$(find ./dotnet/ -type f -name "*.slnx" | tr '\n' ' ') | ||
| for solution in $SOLUTIONS; do | ||
| dotnet pack $solution /property:TargetFrameworks=${{ matrix.targetFramework }} -c ${{ matrix.configuration }} --no-build --no-restore --output "$TEMP_DIR/artifacts" | ||
| done | ||
| pushd "$TEMP_DIR" | ||
| # Create a new console app to test the package installation | ||
| dotnet new console -f ${{ matrix.targetFramework }} --name packcheck --output consoleapp | ||
| # Create minimal nuget.config and use only dotnet nuget commands | ||
| echo '<?xml version="1.0" encoding="utf-8"?><configuration><packageSources><clear /></packageSources></configuration>' > consoleapp/nuget.config | ||
| # Add sources with local first using dotnet nuget commands | ||
| dotnet nuget add source ../artifacts --name local --configfile consoleapp/nuget.config | ||
| dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org --configfile consoleapp/nuget.config | ||
| # Change to project directory to ensure local nuget.config is used | ||
| pushd consoleapp | ||
| dotnet add packcheck.csproj package Microsoft.Extensions.AI.Agents --prerelease | ||
| dotnet build -f ${{ matrix.targetFramework }} -c ${{ matrix.configuration }} packcheck.csproj | ||
| # Clean up | ||
| popd | ||
| popd | ||
| rm -rf "$TEMP_DIR" | ||
| - name: Wait for Cosmos DB Emulator to be ready | ||
| run: | | ||
| set -e | ||
| for i in $(seq 1 120); do | ||
| if curl -sk https://localhost:8081/_explorer/emulator.pem -o /dev/null; then | ||
| echo "Emulator is up." | ||
| break | ||
| fi | ||
| echo "Waiting for emulator... ($i/120)" | ||
| sleep 2 | ||
| done | ||
| - name: Install emulator TLS certificate into system trust store | ||
| run: | | ||
| set -e | ||
| sudo apt-get update | ||
| sudo apt-get install -y ca-certificates curl openssl | ||
| # Fetch the PEM directly from the emulator's explorer endpoint | ||
| curl -sk https://localhost:8081/_explorer/emulator.pem -o cosmos-emulator.crt | ||
| # Install with the correct .crt extension so update-ca-certificates picks it up | ||
| sudo cp cosmos-emulator.crt /usr/local/share/ca-certificates/cosmos-emulator.crt | ||
| sudo update-ca-certificates | ||
| - name: Verify TLS now trusts the emulator | ||
| run: | | ||
| # Use -servername to avoid SNI warning and check verification | ||
| echo | openssl s_client -connect localhost:8081 -servername localhost 2>/dev/null | grep -E "Verify return code|subject=|issuer=" | ||
| # Expect: "Verify return code: 0 (ok)" | ||
| - name: Run Cosmos DB Integration Tests | ||
| shell: bash | ||
| run: | | ||
| # Run the specific CosmosDB integration tests | ||
| dotnet test ./dotnet/tests/CosmosDB.IntegrationTests/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB.Tests/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB.Tests.csproj \ | ||
| -f ${{ matrix.targetFramework }} \ | ||
| -c ${{ matrix.configuration }} \ | ||
| --no-build \ | ||
| -v Normal \ | ||
| --logger trx \ | ||
| --collect:"XPlat Code Coverage" \ | ||
| --results-directory:"TestResults/Coverage/" \ | ||
| -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByAttribute=GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverageAttribute | ||
| # Generate test reports and check coverage | ||
| - name: Generate test reports | ||
| uses: danielpalme/ReportGenerator-GitHub-Action@5.4.11 | ||
| with: | ||
| reports: "./TestResults/Coverage/**/coverage.cobertura.xml" | ||
| targetdir: "./TestResults/Reports" | ||
| reporttypes: "HtmlInline;JsonSummary" | ||
| - name: Upload coverage report artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: CosmosDB-CoverageReport-${{ matrix.os }}-${{ matrix.targetFramework }}-${{ matrix.configuration }} | ||
| path: ./TestResults/Reports |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2 dotnet/samples/AgentWebChat/AgentWebChat.AppHost/AgentWebChat.AppHost.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 12 additions & 11 deletions
23 dotnet/src/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB/ActorDocuments.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 37 additions & 10 deletions
47 ...et/src/Microsoft.Extensions.AI.Agents.Runtime.Storage.CosmosDB/CosmosActorStateStorage.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.