Skip to content

Commit

Permalink
Remove gRPC parametric interface #1930
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeauchesne committed Nov 5, 2024
1 parent 278f73a commit c56c6e0
Show file tree
Hide file tree
Showing 17 changed files with 15 additions and 2,302 deletions.
44 changes: 3 additions & 41 deletions docs/scenarios/parametric.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,54 +198,16 @@ See the steps below in the HTTP section to run the Python server and view the sp

### Shared Interface

#### HTTP

We have transitioned to using an HTTP interface, replacing the legacy GRPC interface. To view the available HTTP endpoints , follow these steps:
To view the available HTTP endpoints , follow these steps:

1. `./utils/scripts/parametric/run_reference_http.sh`

2. Navigate to http://localhost:8000/docs in your web browser to access the documentation.

3. You can download the OpenAPI schema from http://localhost:8000/openapi.json. This schema can be imported into tools like [Postman](https://learning.postman.com/docs/integrations/available-integrations/working-with-openAPI/) or other API clients to facilitate development and testing.

#### Legacy GRPC
**Important:** The legacy GRPC interface will be **deprecated** and no longer in use. All tests will be migrated to use the HTTP interface.

Previously, we used a shared GRPC interface to enable shared testing across different tracers. Each tracer would implement the GRPC interface server, allowing shared tests to be run against the libraries. The GRPC service definition included methods like StartSpan, FinishSpan, SpanSetMeta, and others, which facilitated span and trace operations.

#### Updating protos for GRPC (will be deprecated)

In order to update the `parametric/protos`, these steps must be followed.

1. Create a virtual environment and activate it:
```bash
python3.12 -m venv .venv && source .venv/bin/activate
```

2. Install the required dependencies:
```bash
pip install -r requirements.txt
```

3. Install `grpcio-tools` (make sure grpcaio is the same version):
```bash
pip install grpcio-tools==1.60.1
```

4. Change directory to `utils/parametric`:
```console
cd utils/parametric
```

5. Run the script to generate the proto files:
```bash
./generate_protos.sh
```

Then you should have updated proto files. This script will generate weird files, you can ignore/delete these.

### Architecture: How System-tests work

Below is an overview of how the testing architecture is structured:

- Shared Tests in Python: We write shared test cases using Python's pytest framework. These tests are designed to be generic and interact with the tracers through an HTTP interface.
- HTTP Servers in Docker: For each language tracer, we build and run an HTTP server within a Docker container. These servers expose the required endpoints defined in the OpenAPI schema and handle the tracer-specific logic.
- [Test Agent](https://github.com/DataDog/dd-apm-test-agent/) in Docker: We start a test agent in a separate Docker container. This agent collects data (such as spans and traces) submitted by the HTTP servers. It serves as a centralized point for aggregating and accessing test data.
Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages = ["tests", "utils", "manifests"]

[tool.black]
line-length = 120
exclude = "(venv/|utils/grpc/weblog_pb2_grpc.py|utils/grpc/weblog_pb2.py|parametric/apps|parametric/protos/)"
exclude = "(venv/|utils/grpc/weblog_pb2_grpc.py|utils/grpc/weblog_pb2.py|parametric/apps)"

[tool.pytest.ini_options]
addopts = "--json-report --json-report-indent=2 --color=yes --no-header --junitxml=reportJunit.xml -r Xf"
Expand Down Expand Up @@ -134,12 +134,7 @@ disable = [
"import-error", # full of bug
]
ignore-paths = [
"utils/parametric/protos/.*" # generated by grpc
]
generated-members = [
"pb\\.(DistributedHTTPHeaders|FlushSpansArgs|FlushTraceStatsArgs|HeaderTuple|InjectHeadersArgs)",
"pb\\.(StartSpanArgs|StopTracerArgs|SpanSetMetaArgs|SpanSetMetricArgs|SpanSetErrorArgs|FinishSpanArgs)",
"pb\\.(Otel.*|ListVal|AttrVal|Attributes)",
"(ok_summary|err_summary)\\.mapping",
"Span\\.__annotations__"
]
18 changes: 5 additions & 13 deletions tests/parametric/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
from utils.parametric.spec.trace import V06StatsPayload
from utils.parametric.spec.trace import Trace
from utils.parametric.spec.trace import decode_v06_stats
from utils.parametric._library_client import APMLibraryClientGRPC
from utils.parametric._library_client import APMLibraryClientHTTP
from utils.parametric._library_client import APMLibrary
from utils.parametric._library_client import APMLibrary, APMLibraryClient

from utils import context, scenarios
from utils.tools import logger
Expand Down Expand Up @@ -570,15 +568,9 @@ def test_library(
if apm_test_server.host_port is None:
raise RuntimeError("Internal error, no port has been assigned", 1)

if apm_test_server.protocol == "grpc":
client = APMLibraryClientGRPC(
f"localhost:{apm_test_server.host_port}", test_server_timeout, apm_test_server.container
)
elif apm_test_server.protocol == "http":
client = APMLibraryClientHTTP(
f"http://localhost:{apm_test_server.host_port}", test_server_timeout, apm_test_server.container
)
else:
raise ValueError(f"Interface {apm_test_server.protocol} not supported")
client = APMLibraryClient(
f"http://localhost:{apm_test_server.host_port}", test_server_timeout, apm_test_server.container
)

tracer = APMLibrary(client, apm_test_server.lang)
yield tracer
10 changes: 0 additions & 10 deletions utils/_context/_scenarios/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def _get_client() -> docker.DockerClient:
class APMLibraryTestServer:
# The library of the interface.
lang: str
# The interface that this test server implements.
protocol: Union[Literal["grpc"], Literal["http"]]
container_name: str
container_tag: str
container_img: str
Expand Down Expand Up @@ -348,7 +346,6 @@ def python_library_factory() -> APMLibraryTestServer:
python_absolute_appdir = os.path.join(_get_base_directory(), python_appdir)
return APMLibraryTestServer(
lang="python",
protocol="http",
container_name="python-test-library",
container_tag="python-test-library",
container_img="""
Expand Down Expand Up @@ -385,7 +382,6 @@ def node_library_factory() -> APMLibraryTestServer:

return APMLibraryTestServer(
lang="nodejs",
protocol="http",
container_name="node-test-client",
container_tag="node-test-client",
container_img=f"""
Expand Down Expand Up @@ -421,7 +417,6 @@ def golang_library_factory():
golang_reldir = golang_appdir.replace("\\", "/")
return APMLibraryTestServer(
lang="golang",
protocol="http",
container_name="go-test-library",
container_tag="go122-test-library",
container_img=f"""
Expand Down Expand Up @@ -454,7 +449,6 @@ def dotnet_library_factory():
dotnet_reldir = dotnet_appdir.replace("\\", "/")
server = APMLibraryTestServer(
lang="dotnet",
protocol="http",
container_name="dotnet-test-api",
container_tag="dotnet8_0-test-api",
container_img=f"""
Expand Down Expand Up @@ -522,7 +516,6 @@ def java_library_factory():
# TODO : use official install_ddtrace.sh
return APMLibraryTestServer(
lang="java",
protocol="http",
container_name="java-test-client",
container_tag="java-test-client",
container_img=f"""
Expand All @@ -549,7 +542,6 @@ def php_library_factory() -> APMLibraryTestServer:
php_reldir = php_appdir.replace("\\", "/")
return APMLibraryTestServer(
lang="php",
protocol="http",
container_name="php-test-library",
container_tag="php-test-library",
container_img=f"""
Expand Down Expand Up @@ -584,7 +576,6 @@ def ruby_library_factory() -> APMLibraryTestServer:
ruby_reldir = ruby_appdir.replace("\\", "/")
return APMLibraryTestServer(
lang="ruby",
protocol="http",
container_name="ruby-test-client",
container_tag="ruby-test-client",
container_img=f"""
Expand Down Expand Up @@ -629,7 +620,6 @@ def cpp_library_factory() -> APMLibraryTestServer:

return APMLibraryTestServer(
lang="cpp",
protocol="http",
container_name="cpp-test-client",
container_tag="cpp-test-client",
container_img=dockerfile_content,
Expand Down
5 changes: 0 additions & 5 deletions utils/build/docker/golang/parametric/generate_protos.ps1

This file was deleted.

7 changes: 0 additions & 7 deletions utils/build/docker/golang/parametric/generate_protos.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ class OtelStartSpanArgs(BaseModel):
name: str
parent_id: int
span_kind: int
service: str = "" # Not used but defined in protos/apm-test-client.protos
resource: str = "" # Not used but defined in protos/apm-test-client.protos
type: str = "" # Not used but defined in protos/apm-test-client.protos
links: List[Dict] = [] # Not used but defined in protos/apm-test-client.protos
service: str = ""
resource: str = ""
type: str = ""
links: List[Dict] = []
timestamp: int
http_headers: List[Tuple[str, str]]
attributes: dict
Expand Down
Loading

0 comments on commit c56c6e0

Please sign in to comment.