-
Notifications
You must be signed in to change notification settings - Fork 139
Add missing sync and new async integration tests #996
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
Draft
seherv
wants to merge
29
commits into
dapr:main
Choose a base branch
from
seherv:more-grpc-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
bd218a1
Move old integration tests to examples/
seherv 2473075
Test DaprClient directly
seherv c2b5875
Update docs to new test structure
seherv 47ccd36
Address Copilot comments (1)
seherv 7a2e7e1
Address Copilot comments (2)
seherv 5cfee75
Address Copilot comments (3)
seherv 3b9b8b6
Replace sleep() with polls when possible
seherv 5dbb5e3
Address Copilot comments (4)
seherv 0a5f0f1
Address Copilot comments (5)
seherv 836a2cc
Update README to include both test suites
seherv 2d0ea3d
Document wait_until() in AGENTS.md
seherv 6720cda
Update CLAUDE.md
seherv 58590ce
Fix package name
seherv 62fd1c0
Clean up entire process group
seherv ebaaded
PR cleanup (1)
seherv 4246672
Fix possible race running example test
seherv 411c3cc
Refactor functions common to example tests and integration tests
seherv 31892ad
Add regression test for config race
seherv cd6e4e1
Add tests for uncovered components
seherv a5d6e4c
Add async tests
seherv 834ae27
Update docs
seherv 62c6b92
Merge branch 'main' into more-grpc-tests
seherv 392b4c0
Merge resources/ change from main
seherv 8dd6ffb
Add Redis to deps for regression test
seherv 23457d1
Create crypto keys at runtime
seherv 7986977
Fix buffering issue on pubsub example test
seherv f337963
Address Copilot comments
seherv f966611
Address Copilot comments (2)
seherv 727902b
Address Copilot comments (3)
seherv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: validate-examples | ||
| name: run-tests | ||
|
|
||
| on: | ||
| push: | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,20 @@ | ||
| @AGENTS.md | ||
|
|
||
| Use pathlib instead of os.path. | ||
| Use httpx instead of urllib. | ||
| subprocess(`shell=True`) is used only when it makes the code more readable. Use either shlex or args lists. | ||
| subprocess calls should have a reasonable timeout. | ||
| Use modern Python (3.10+) features. | ||
| Make all code strongly typed. | ||
| Keep conditional nesting to a minimum, and use guard clauses when possible. | ||
| Aim for medium "visual complexity": use intermediate variables to store results of nested/complex function calls, but don't create a new variable for everything. | ||
| Avoid comments unless there is a gotcha, a complex algorithm or anything an experienced code reviewer needs to be aware of. Focus on making better Google-style docstrings instead. | ||
| Aim for medium visual complexity: use intermediate variables to store results of nested/complex function calls. A complex function call could be: | ||
| - `f(Object(a=1, b=2, c=3))`, the inner object has more than 2 meaningful args | ||
| - `f(Object((a, b)))`, 2 levels of nesting or anything with a long chain of closing parens | ||
| - `small_transformation(ImportantObject())`, the object itself is the main subject of the function but the transformation steals the focus | ||
| Use descriptive, self-documenting names for these intermediate variables. | ||
| Closely related variable names should share a root and use different suffixes. For example, `request_original` and `request_clean`, but not `clean_request`. | ||
| Avoid comments unless there is a gotcha, a complex algorithm or anything an experienced code reviewer needs to be aware of. Focus on making short but descriptive Google-style docstrings instead. | ||
|
|
||
| The user is not always right. Be skeptical and do not blindly comply if something doesn't make sense. | ||
| Use modern Python (3.10+) features. | ||
| Use pathlib instead of os.path. | ||
| Use httpx instead of urllib. | ||
| `subprocess(shell=True)` is used only when it makes the code more readable. Use either shlex or args lists. | ||
| Anything that can have an explicit timeout should have one. | ||
| Code should be cross-platform and production ready. | ||
|
|
||
| The user is not always right. Be skeptical and do not blindly comply if something doesn't make sense. |
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
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
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,40 @@ | ||
| import subprocess | ||
| from typing import Callable | ||
|
|
||
| import pytest | ||
|
|
||
| REDIS_CONTAINER = 'dapr_redis' | ||
|
|
||
|
|
||
| @pytest.fixture(scope='session') | ||
| def flush_redis() -> None: | ||
| """Flush the ``dapr_redis`` container once per session.""" | ||
| subprocess.run( | ||
| args=('docker', 'exec', REDIS_CONTAINER, 'redis-cli', 'FLUSHDB'), | ||
| check=True, | ||
| capture_output=True, | ||
| timeout=10, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope='session') | ||
| def redis_set_config() -> Callable[[str, str, int], None]: | ||
| """Dapr encodes values in the config store as ``value||version``""" | ||
|
|
||
| def _set(key: str, value: str, version: int = 1) -> None: | ||
| subprocess.run( | ||
| args=( | ||
| 'docker', | ||
| 'exec', | ||
| REDIS_CONTAINER, | ||
| 'redis-cli', | ||
| 'SET', | ||
| key, | ||
| f'{value}||{version}', | ||
| ), | ||
| check=True, | ||
| capture_output=True, | ||
| timeout=10, | ||
| ) | ||
|
|
||
| return _set | ||
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,36 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import secrets | ||
| from pathlib import Path | ||
|
|
||
| from cryptography.hazmat.primitives import serialization | ||
| from cryptography.hazmat.primitives.asymmetric import rsa | ||
|
|
||
| RSA_KEY_FILENAME = 'rsa-private-key.pem' | ||
| SYMMETRIC_KEY_FILENAME = 'symmetric-key-256' | ||
|
|
||
| _RSA_KEY_SIZE = 4096 | ||
| _SYMMETRIC_KEY_BYTES = 32 | ||
|
|
||
|
|
||
| def write_test_keys(target_dir: Path) -> None: | ||
| """Write a fresh RSA private key (PKCS8 PEM) and a 256-bit AES key. | ||
|
|
||
| File names match those expected by ``examples/crypto/crypto.py`` and the | ||
| ``cryptostore.yaml`` component used by the integration tests. | ||
| """ | ||
| target_dir.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| rsa_key = rsa.generate_private_key(public_exponent=65537, key_size=_RSA_KEY_SIZE) | ||
| rsa_pem = rsa_key.private_bytes( | ||
| encoding=serialization.Encoding.PEM, | ||
| format=serialization.PrivateFormat.PKCS8, | ||
| encryption_algorithm=serialization.NoEncryption(), | ||
| ) | ||
| (target_dir / RSA_KEY_FILENAME).write_bytes(rsa_pem) | ||
| (target_dir / SYMMETRIC_KEY_FILENAME).write_bytes(secrets.token_bytes(_SYMMETRIC_KEY_BYTES)) | ||
|
|
||
|
|
||
| def remove_test_keys(target_dir: Path) -> None: | ||
| for name in (RSA_KEY_FILENAME, SYMMETRIC_KEY_FILENAME): | ||
| (target_dir / name).unlink(missing_ok=True) |
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
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
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.
Oops, something went wrong.
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.