Skip to content
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

Dapr example and tests #394

Merged
merged 24 commits into from
Jan 22, 2025
Merged

Dapr example and tests #394

merged 24 commits into from
Jan 22, 2025

Conversation

aaronpowell
Copy link
Member

This pull request introduces Dapr integration into the project by adding necessary configurations and setup steps. The changes span multiple files to ensure Dapr is properly initialized and used across various services.

Dapr Integration:

Project Configuration:

Example Projects:

Service Projects:

@aaronpowell aaronpowell requested a review from Copilot January 15, 2025 06:06

Choose a reason for hiding this comment

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

Copilot reviewed 15 out of 30 changed files in this pull request and generated no comments.

Files not reviewed (15)
  • .devcontainer/devcontainer.json: Language not supported
  • .devcontainer/post-create.sh: Language not supported
  • CommunityToolkit.Aspire.sln: Language not supported
  • Directory.Packages.props: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.AppHost/CommunityToolkit.Aspire.Hosting.Dapr.AppHost.csproj: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.AppHost/Properties/launchSettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.AppHost/appsettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceA/CommunityToolkit.Aspire.Hosting.Dapr.ServiceA.csproj: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceA/Properties/launchSettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceA/appsettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceB/CommunityToolkit.Aspire.Hosting.Dapr.ServiceB.csproj: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceB/Properties/launchSettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceB/appsettings.json: Language not supported
  • examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceC/CommunityToolkit.Aspire.Hosting.Dapr.ServiceC.csproj: Language not supported
  • .github/workflows/dotnet-ci.yml: Evaluated as low risk
Comments suppressed due to low confidence (1)

examples/dapr/CommunityToolkit.Aspire.Hosting.Dapr.ServiceB/Program.cs:22

  • The new behavior for handling weather forecasts and pub/sub events should be covered by tests.
app.MapGet("/weatherforecast", async (DaprClient client) =>
@aaronpowell
Copy link
Member Author

CI is failing because the install location of Dapr isn't into the paths that are hard-coded to be used for lookup in the DaprDistributedApplicationLifecycleHook. Gonna have to hack it somewhere

@paule96
Copy link

paule96 commented Jan 20, 2025

@aaronpowell maybe add this to the DaprDistributedApplicationLifecycleHook.GetDefaultDaprPath.GetAvailablePaths method.

// Add all the paths that are reachable via the `PATH` environment variable:
var possibleDaprPaths = Environment.GetEnvironmentVariable("PATH")?
   .Split(Path.PathSeparator)
   .Select(path => Path.Combine(path, "dapr"))
   .Where(path => File.Exists(path)) ?? [];            
foreach(var path in possibleDaprPaths){
   yield return path;
}

It should search truth the PATH environment variable to find the dapr executable.

@aaronpowell
Copy link
Member Author

@aaronpowell maybe add this to the DaprDistributedApplicationLifecycleHook.GetDefaultDaprPath.GetAvailablePaths method.

// Add all the paths that are reachable via the `PATH` environment variable:
var possibleDaprPaths = Environment.GetEnvironmentVariable("PATH")?
   .Split(Path.PathSeparator)
   .Select(path => Path.Combine(path, "dapr"))
   .Where(path => File.Exists(path)) ?? [];            
foreach(var path in possibleDaprPaths){
   yield return path;
}

It should search truth the PATH environment variable to find the dapr executable.

This seems fine on Linux runners but it's not working on Windows and I can't seem to get Aspire to do any sort of logging on what paths it is trying to look at during the tests.

* Adding the ability to do a maven build in the app host

This uses an event to run the mvnw build (or it can be customised via options), so it is only used when the app host is running the resource

Fixes #339

* Adding a 'build with maven' command

Allows you to rebuild the java app without having to restart the whole app host.

* Expanding test coverage

* Some more tests
@davidfowl
Copy link

That logic is not complete windows needs to look for .exe and .cmd

@aaronpowell
Copy link
Member Author

That logic is not complete windows needs to look for .exe and .cmd

Yep, can't believe it took me half a day to notice that 🤣

Tests are still failing, I've asked on the Dapr discord

@paule96
Copy link

paule96 commented Jan 21, 2025

@aaronpowell hm it looks like it's a CI issue. Because lokal on my Windows machine the tests are working:

image

@paule96
Copy link

paule96 commented Jan 21, 2025

The problem is actually that the dapr init silently failed.

image

Note: What is very interesting is, that docker seems to run in a Windows Container mode. Because docker tries to pulls images for Windows. Not for linux what should be normal (thanks to WSL) So Maybe the build agent we got was broken

@paule96
Copy link

paule96 commented Jan 21, 2025

@aaronpowell can you push an emtpy commit to trigger CI again. I guess this will solve the issue.

Sadly I can't push to your branch

@aaronpowell
Copy link
Member Author

Ah, so it will require those container images? Windows runners don't have WSL to they need Windows container images.

Probably going to have to disable that test on Windows CI

@paule96
Copy link

paule96 commented Jan 21, 2025

@aaronpowell oh okay I was not aware of that. Yeah so I guess we need to deactive the test.

Are there any windows runners with wsl support?

@paule96
Copy link

paule96 commented Jan 21, 2025

@aaronpowell maybe we can try todo this befor the docker install:
https://github.com/marketplace/actions/setup-wsl

Note: According to this issue it should be possible todo that: actions/runner-images#5920

@aaronpowell
Copy link
Member Author

@aaronpowell maybe we can try todo this befor the docker install: https://github.com/marketplace/actions/setup-wsl

Note: According to this issue it should be possible todo that: actions/runner-images#5920

It might be worth exploring but I'm going to disable the test for now as that kind of a refactor is beyond the scope of what should be in this workstream.

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
Aspire.Hosting.Dapr 3% 0% 277
Aspire.Hosting.RabbitMQ 49% 30% 109
Aspire.Hosting.Redis 0% 0% 120
CommunityToolkit.Aspire.EventStore 100% 100% 46
CommunityToolkit.Aspire.Hosting.ActiveMQ 70% 27% 144
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Azure.StaticWebApps 100% 100% 28
CommunityToolkit.Aspire.Hosting.Bun 81% 71% 54
CommunityToolkit.Aspire.Hosting.Dapr 60% 51% 560
CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis 93% 71% 54
CommunityToolkit.Aspire.Hosting.Deno 84% 75% 72
CommunityToolkit.Aspire.Hosting.EventStore 90% 71% 62
CommunityToolkit.Aspire.Hosting.Golang 94% 50% 16
CommunityToolkit.Aspire.Hosting.Java 69% 72% 120
CommunityToolkit.Aspire.Hosting.Meilisearch 61% 27% 94
CommunityToolkit.Aspire.Hosting.Ngrok 59% 50% 58
CommunityToolkit.Aspire.Hosting.NodeJS.Extensions 90% 68% 92
CommunityToolkit.Aspire.Hosting.Ollama 65% 64% 198
CommunityToolkit.Aspire.Hosting.Python.Extensions 69% 50% 86
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 74% 61% 96
CommunityToolkit.Aspire.Hosting.Sqlite 96% 96% 38
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 50% 50% 88
CommunityToolkit.Aspire.OllamaSharp 87% 82% 68
Summary 63% (3967 / 6257) 48% (1139 / 2362) 2682

Minimum allowed line rate is 60%

@aaronpowell aaronpowell merged commit 94f8d7f into dapr-migration Jan 22, 2025
11 of 12 checks passed
@aaronpowell aaronpowell deleted the dapr-migration-tests branch January 22, 2025 00:20
aaronpowell added a commit that referenced this pull request Jan 31, 2025
* Dapr migration initial import (#378)

* Dropping files from Aspire repo

* Moving to the right namespace/folder naming

* Adding to solution and getting it to compile

* Adding in the Dapr tests from the Aspire repo

Had to remove the DaprSchemaTests file as we can't do schema tests (missing a lot of infrastructure from the Aspire repo).

Had to edit the DaprTests to not use EnvironmentVariableEvaluator, which we can't leverage as it uses some internal types from Aspire.Hosting. This means that our testing of the environment variables is slightly different, and the values we assert against are not the docker internal host endpoints, but the public endpoints

* Dapr azure hosting ext (#371)

* Create Dap Azure extensions project
Create Dapr Azure Redis project
Create Example AppHost + ApiService

* Work in progress
Create Dapr resource for provisioning

* Remove specific resource as not generating properly
Use AddAzureInfrastructure

* Updated to use secret refs

* Fix - Remove code used for testing
Add AzureDaprComponentResource
Start of unit tests

* Unit tests +
Fixes based on unit tests

* remove bicep file

* Tests for AzureRedis

* Add Readme and perform small cleanup tasks

* Update src/CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions/ApplicationModel/AzureDaprComponentResource.cs

Co-authored-by: Aaron Powell <[email protected]>

* Apply suggestions from code review

Co-authored-by: Aaron Powell <[email protected]>

* Revert unintentional change to Java.AppHost

* Update tests/CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.Tests/ResourceCreationTests.cs

Co-authored-by: Aaron Powell <[email protected]>

* Updated azure redis documentation also added missing xmldocs for api

* correct unit test approach

* remove unnecessary comment

* null checking

* More null checking

* Update Azure redis readme

* Update AzureExtension readme

* move extensions to shared files
remove Dapr Azure extensions project
make dapr azure extensions internal
include extensions in dapr redis package
include extensions in dapr extensions tests
make dapr redis internals visible to dapr redis tests

* change redisCache to infra rename source to redisBuilder

---------

Co-authored-by: Aaron Powell <[email protected]>

* Fixing broken sln

* Dapr example and tests (#394)

* Migrating sample from dotnet/aspire repo

* Adding dapr tests

* Adding dapr setup to CI workflow

* Following the setup-dapr instructions

* Debugging CI

* Falling back to looking at PATH

* Fixing line endings replacement

* Added PATH lookup to Windows

* Adding some diagnostic info

* Changing log level

* init was only running on linux, which I think is wrong

* Turning up logging

* Bypass logging

* Interpolated strings

* Adding resource logger service

* Java app build extension (#348)

* Adding the ability to do a maven build in the app host

This uses an event to run the mvnw build (or it can be customised via options), so it is only used when the app host is running the resource

Fixes #339

* Adding a 'build with maven' command

Allows you to rebuild the java app without having to restart the whole app host.

* Expanding test coverage

* Some more tests

* Windows exe needs a file extension

* Rolling back some changes

* Renaming step

* Tidying up the tests

* Requiring docker for dapr tests

* Adding codeowners

* Moving dapr extensions to use our dapr package

* Forgot to update the tests project

* Adding some assembly filters

* Adding readme updates

* Slight break in the markdown

---------

Co-authored-by: Brett Smith <[email protected]>
@Alirexaa Alirexaa added this to the 9.2 milestone Feb 6, 2025
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.

4 participants