Skip to content

Remove Mechanical Markdown from examples/ validation#977

Merged
sicoyle merged 25 commits intodapr:mainfrom
seherv:remove-mechanical-markdown
Apr 22, 2026
Merged

Remove Mechanical Markdown from examples/ validation#977
sicoyle merged 25 commits intodapr:mainfrom
seherv:remove-mechanical-markdown

Conversation

@seherv
Copy link
Copy Markdown
Contributor

@seherv seherv commented Apr 10, 2026

Description

Removes all references to Mechanical Markdown and replaces them with pytest files that validate the output generated by the examples.


The existing Mechanical Markdown tests can be loosely categorized as:

  1. run a single process and check its output
  2. start a consumer process, run another producer process, read the producer output, and then read the consumer output

We made a DaprRunner helper class to have new pytest files that look as close to the original MM tests as possible. For both types of MM tests:

  1. DaprRunner.run() spawns a "short-lived" process. We only care about its output, so we can read all of it and close the process immediately after. Reading its output blocks the test code.
  2. DaprRunner.start()/stop() spawns a "long-lived" process, usually a consumer like Kafka. We then execute a separate producer process in any way we want, optionally read its output, and close the producer. The consumer will now have the desired output. The stop() is there to let us read the consumer output and close it after the producer is done.

We use these methods to run the examples pretty much as-is.


These examples are not meant to be proper integration tests. They help to loosely test a few integrations, but the main goal of this PR is to keep the examples/ directory consistent. It's fine to have a relatively simple and readable reimplementation of MM for this purpose.

For more reliable integration tests, check #981.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #972 (first iteration)

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
@seherv seherv force-pushed the remove-mechanical-markdown branch from b92a68e to 65fc9ae Compare April 10, 2026 13:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates example validation away from Mechanical Markdown to pytest-based integration tests, so the examples/ directory is validated via native Python tests that run the examples and assert on their output.

Changes:

  • Replaces the tox -e examples Mechanical Markdown workflow with a new tox -e integration pytest environment.
  • Adds tests/integration/ with a DaprRunner helper + one pytest file per example to validate expected output.
  • Updates project docs (README.md, AGENTS.md, examples/AGENTS.md) and removes examples/validate.sh.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tox.ini Removes Mechanical Markdown example envs and adds integration env running pytest.
pyproject.toml Registers the custom example_dir pytest marker.
README.md Updates developer instructions to run tox -e integration.
AGENTS.md Updates repo contributor guidance to refer to pytest integration tests instead of Mechanical Markdown.
examples/AGENTS.md Rewrites examples validation docs to describe pytest/DaprRunner approach.
examples/validate.sh Removes the Mechanical Markdown validation entrypoint script.
CLAUDE.md Adds repository development guidelines.
tests/integration/conftest.py Introduces DaprRunner, output assertion helper, and dapr fixture/marker handling.
tests/integration/test_workflow.py Adds integration coverage for the workflow examples (task chaining, fan-out/fan-in, simple).
tests/integration/test_w3c_tracing.py Adds integration coverage for w3c tracing example with background receiver.
tests/integration/test_state_store.py Adds integration coverage for state store example output.
tests/integration/test_state_store_query.py Adds integration coverage for state store query example with MongoDB setup.
tests/integration/test_secret_store.py Adds integration coverage for secret store example (with/without ACL config).
tests/integration/test_pubsub_streaming.py Adds integration coverage for streaming pubsub example (subscriber/publisher).
tests/integration/test_pubsub_streaming_async.py Adds integration coverage for async streaming pubsub example (subscriber/publisher).
tests/integration/test_pubsub_simple.py Adds integration coverage for basic pubsub example (subscriber/publisher).
tests/integration/test_metadata.py Adds integration coverage for metadata example output.
tests/integration/test_langgraph_checkpointer.py Adds integration coverage for langgraph checkpointer example (skips if deps missing).
tests/integration/test_jobs.py Adds integration coverage for jobs example (management + processing).
tests/integration/test_invoke_simple.py Adds integration coverage for invoke-simple using direct sidecar HTTP call to avoid infinite loop.
tests/integration/test_invoke_custom_data.py Adds integration coverage for invoke-custom-data (receiver + caller).
tests/integration/test_invoke_binding.py Adds integration coverage for invoke-binding with Kafka docker-compose setup.
tests/integration/test_grpc_proxying.py Adds integration coverage for gRPC proxying example (receiver + caller).
tests/integration/test_error_handling.py Adds integration coverage for error handling example output.
tests/integration/test_distributed_lock.py Adds integration coverage for distributed lock example output.
tests/integration/test_demo_actor.py Adds integration coverage for demo actor example (service + client).
tests/integration/test_crypto.py Adds integration coverage for crypto examples with key generation/cleanup fixture.
tests/integration/test_conversation.py Adds integration coverage for conversation examples output.
tests/integration/test_configuration.py Adds integration coverage for configuration example with Redis seeding + update trigger.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tox.ini
Comment thread tests/integration/test_state_store.py Outdated
Comment thread tests/integration/conftest.py Outdated
Comment thread tests/integration/conftest.py Outdated
Comment thread tests/integration/test_invoke_binding.py Outdated
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/test_state_store_query.py
Comment thread tests/integration/test_langgraph_checkpointer.py
Comment thread tests/integration/test_invoke_binding.py Outdated
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/test_state_store_query.py
Comment thread tests/integration/test_invoke_simple.py Outdated
Comment thread tox.ini
Comment thread tests/integration/conftest.py Outdated
Comment thread tests/integration/conftest.py Outdated
Comment thread tests/integration/conftest.py
Comment thread tests/integration/test_invoke_binding.py Outdated
@sicoyle
Copy link
Copy Markdown
Contributor

sicoyle commented Apr 14, 2026

@seherv pls see latest copilot feedback and build failures :)

seherv and others added 5 commits April 14, 2026 16:10
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.46%. Comparing base (bffb749) to head (53ddae8).
⚠️ Report is 108 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #977      +/-   ##
==========================================
- Coverage   86.63%   81.46%   -5.17%     
==========================================
  Files          84      139      +55     
  Lines        4473    13525    +9052     
==========================================
+ Hits         3875    11018    +7143     
- Misses        598     2507    +1909     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
@seherv seherv marked this pull request as ready for review April 15, 2026 12:23
@seherv seherv requested review from a team as code owners April 15, 2026 12:23
@acroca acroca requested a review from Copilot April 15, 2026 12:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/test_langgraph_checkpointer.py Outdated
Comment thread tests/integration/test_langgraph_checkpointer.py
Comment thread tests/integration/test_langgraph_checkpointer.py Outdated
Comment thread tox.ini
seherv added 2 commits April 15, 2026 16:06
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tox.ini Outdated
Comment thread CLAUDE.md Outdated
Comment thread tests/integration/test_invoke_binding.py Outdated
Comment thread tests/integration/test_langgraph_checkpointer.py Outdated
Comment thread tests/integration/test_pubsub_simple.py Outdated
Comment thread tests/integration/test_distributed_lock.py Outdated
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 32 out of 32 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/integration/test_langgraph_checkpointer.py
Comment thread tests/integration/test_langgraph_checkpointer.py
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
@sicoyle
Copy link
Copy Markdown
Contributor

sicoyle commented Apr 20, 2026

Hiiii! This is the one we said we'd review/fix first right? Just want to double check I'm not mixing the two :)

Copy link
Copy Markdown
Contributor

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

thank you! This is looking great 🙌 👏 👏 here's my initial feedback :)

Comment thread tests/integration/conftest.py Outdated

Use this for servers/subscribers that must stay alive while a second
process runs via ``run()``. Call ``stop()`` to terminate and collect
output. Stdout is written to a temp file to avoid pipe-buffer deadlocks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

did you experience this running the tests locally? Just too much output?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did experience deadlocks with some of the "heavier" tests (Kafka and Langgraph IIRC) that got solved after force flushing the output streams.

One way of solving that was using a thread to constantly flush them into the void, but the code was getting unnecessarily complicated for these output-based tests. I opted for tempfiles because it was easier and more helpful to me while debugging, considering pytest is (understandably) very shy about printing stuff to the screen.

Comment thread tests/integration/conftest.py Outdated
)
self._bg_process = proc
self._bg_output_file = output_file
time.sleep(wait)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we need the wait sleep?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's there for examples that needs two processes, like the pubsub ones where one waits and the other acts. The sleep is just there for the consumer process to finish booting up before the producer does anything. In a way, the user already does this wait implicitly when they execute the commands manually.

That two process pattern is also what motivated me to make start()/stop()andrun()`, more on that in the next comment.

Comment thread tests/integration/conftest.py Outdated
Comment thread tests/integration/test_pubsub_streaming.py Outdated
Comment thread tests/integration/test_pubsub_streaming_async.py Outdated
Comment thread tests/integration/test_pubsub_streaming_async.py Outdated
Comment thread tests/integration/test_state_store_query.py Outdated
Comment thread tox.ini Outdated
@sicoyle
Copy link
Copy Markdown
Contributor

sicoyle commented Apr 21, 2026

Please prioritize closing out this PR so it’s easier to review your other one once it’s rebased onto main. The branch is updated and the build is approved for you 😁

@seherv
Copy link
Copy Markdown
Contributor Author

seherv commented Apr 21, 2026

Please prioritize closing out this PR so it’s easier to review your other one once it’s rebased onto main. The branch is updated and the build is approved for you 😁

Yup, I'm on it! Your feedback on this PR has been very useful for me to clean up unused/wrong code in this branch, but it ended up being even more useful in the DaprClient SDK tests branch and there is some shared code I need to bring here first.

I'll push the relevant changes to this branch, respond to your comments and ask you for a second review on both PRs once they are in the intended state.

seherv added 2 commits April 21, 2026 17:25
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
@seherv seherv marked this pull request as draft April 21, 2026 18:15
seherv added 6 commits April 21, 2026 21:33
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Signed-off-by: seherv <627709+seherv@users.noreply.github.com>
@seherv seherv marked this pull request as ready for review April 21, 2026 22:33
Copy link
Copy Markdown
Contributor

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

last few comments for ya - thank you!!

Comment thread tests/integration/test_demo_actor.py
Comment thread tests/integration/test_grpc_proxying.py Outdated
Signed-off-by: Sergio Herrera <627709+seherv@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@sicoyle sicoyle left a comment

Choose a reason for hiding this comment

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

lgtm - thank youuu!

@sicoyle sicoyle added this pull request to the merge queue Apr 22, 2026
Merged via the queue into dapr:main with commit 7316b0e Apr 22, 2026
14 of 15 checks passed
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.

(parent) refactor: mv mechanical markdown tests to pytest native

3 participants