-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Set up contract tests #40
Conversation
fc7e93a
to
796d034
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I did not understand much of the protobuf stuff in the mock collector but I guess if it is working fine then all that must be correct. 😄
Other than that did a sanity check on the code and posted comments/questions wherever I needed clarification. Overall LGTM!
12cbf1a
to
2cdcf29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
In this commit, we are setting up contract tests similar to those in the aws-otel-java-instrumentation repo. Initially, we are just commiting the logic to run the mock collector and a single application that uses the requests library, but the tests are extensible to other frameworks. There are a number of small differences between these tests and the Java contract tests, most of which are language dependent. One callout is that the building and running of these tests is currently possible, but not rigourously so. In coming commits, we will make github workflows to do this, and several build-related configurations/etc. are likely to change.
* Make contract tests runnable from project root * Use public ecr version of python * Fix py3.8 issues (dict/list/set not subscriptable, need to use Dict/List/Set) * Remove `--no-isolation` from set up script (initially added as it solves a local problem with my set up, but causes general problems)
* Remove requests/pyproject.toml * Improve naming of _WAIT_INTERVAL * Fix type hint * Improve comment
When docker build fails, it does so silently. We have to detect the failure with the bash variable $?, then exit the script. This avoids silent docker failures.
a08562a
to
7e56820
Compare
Not blocking: you mentioned an example application need a pyproject.toml, but your request application don’t contain this. It may be because of this application is too simple, so not blocking anything |
@XinRanZhAWS thanks for the reminder, I had it initially, then removed it because I forgot why I had it in the first place. Good thing I wrote it down, and good thing you reviewed haha. Will add back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks
In this commit, we are setting up contract tests similar to those in the aws-otel-java-instrumentation repo. Initially, we are just commiting the logic to run the mock collector and a single application that uses the requests library, but the tests are extensible to other frameworks.
There are a number of small differences between these tests and the Java contract tests, most of which are language dependent.
Callouts:
mock_collector_service_pb2_grpc.py
,mock_collector_service_pb2.py
, andmock_collector_service_pb2.pyi
. These are generated GRPC files and no edits to these files are recommended after generating from proto files. I have made no edits to these files after generating with commands described in the mock collector README.requests_server.py
is based on thenative-http-client/App.java
mock_collector_client.py
is based on theMockCollectorClient.java
andResourceScopeSignal.kt
. Note that a lot of the serialization/deserialization logic is simplified in Python/gRPC.mock-collector
classes (e.g.mock_collector_server
,mock_collector_metrics_service
, etc are based on themockcollector
java classes. Callout that java uses an HTTP server wrapping gRPC servicers, while I'm just using a gRPC server and servicers as it was simpler to do so in Python.app_signals_constants.py
note that metric names are all lowercase, which is intentional (java will be fixed in future).contract_test_base.py
is based onContractTestBase.java
. One substantial difference is that we are not passing information in about the agent, since both testcontainers and OTEL instrumentation mechanisms are quite different in Java vs Python.requests_test.py
is based onBaseHttpClientTest.java
andNativeHttpClientTest.java
PEER_SERVICE
does not appear to be supported by Pythonrequests
. This is acceptable from a contract perspective, but does result inAWS_LOCAL_OPERATION
beingInternalOperation
andAWS_SPAN_KIND
beingLOCAL_ROOT
on spans/metrics (in metricsAWS_SPAN_KIND
isCLIENT
, this is expected)NET_PEER_NAME
andNET_PEER_PORT
are not populated byrequests
instrumentation, which appears to be an upstream bug. This results inAWS_REMOTE_SERVICE
beingUnknownRemoteService
pylint: disable
summary:invalid-name
- only used where I do not have control over the method name (e.g. overrides)broad-exception-caught
- Used where we really do want to just catch everything and keep goingno-self-use
- only used when defining methods that are designed to be overridden by subclasses.no-member
- Used forSpan.SPAN_KIND_CLIENT
- for some reason, pylint cannot detect this constant, likely related to gRPC/proto magicBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.