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

How to properly test #494

Open
qustavo opened this issue Jan 11, 2024 · 5 comments
Open

How to properly test #494

qustavo opened this issue Jan 11, 2024 · 5 comments

Comments

@qustavo
Copy link
Contributor

qustavo commented Jan 11, 2024

I'm opening this issue to ask how should I test components that are using dapr.
In my case, I needed to make sure that my code was using pubsub correctly.
I ended up exec.Command("dapr", "run", ... more args ...) and creating a Client and a Service that conneted to the dapr daemon. While this worked, I wonder if there is a programmatic way to do this. I skim through this repo and dapr/dapr and I could find anything.
Is this the right way to test? is there a better one?

Thanks!

@etiennetremel
Copy link

Depends what test you are looking for. For my case, I used testcontainers to spin-up containers and test Dapr functionalities during the integration testing phase. It's particularly useful when a service provider doesn't offer a way to test their proprietary service locally. With Dapr it's just a matter of swapping a container with an open-source alternative.

You can find an example in the following repository: https://github.com/etiennetremel/testcontainers-dapr-example

@qustavo
Copy link
Contributor Author

qustavo commented Jan 22, 2024

I'm following a similar approach but without docker, just by running the binnary (os.Exec). Using docker sounds interesting, portable and contained, specially when it comes to finding unused ports. Although it would be nice to have some package implementing a testing server.
Have you experimented creating a grpc server for test?

@etiennetremel
Copy link

I haven't played with GRPC for tests, but I wouldn't expect much difference from a standard HTTP server

@qustavo
Copy link
Contributor Author

qustavo commented Jan 29, 2024

have you started a HTTP server for tests?

@mikeee
Copy link
Member

mikeee commented Jan 29, 2024

The examples in this repo are validated using mechanical markdown - https://github.com/dapr/mechanical-markdown
Have a look at the validation github workflow along with the README files which validates the output against expected.

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

No branches or pull requests

3 participants