-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-serve-5386
- Loading branch information
Showing
12 changed files
with
101 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,25 @@ | ||
import os | ||
import time | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def docker_image_name(): | ||
return 'jina/replica-exec' | ||
|
||
|
||
@pytest.fixture() | ||
def docker_image_built(docker_image_name): | ||
cur_dir = os.path.dirname(os.path.abspath(__file__)) | ||
import docker | ||
|
||
client = docker.from_env() | ||
client.images.build( | ||
path=os.path.join(cur_dir, 'replica-exec'), tag=docker_image_name | ||
) | ||
client.close() | ||
yield | ||
time.sleep(2) | ||
client = docker.from_env() | ||
client.containers.prune() |
This file contains 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 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
50 changes: 50 additions & 0 deletions
50
tests/integration/instrumentation/test_container_instrumentation.py
This file contains 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,50 @@ | ||
import os | ||
import time | ||
|
||
import pytest | ||
|
||
from jina import Flow | ||
from tests.integration.instrumentation import ( | ||
get_exported_jobs, | ||
get_flow_metric_labels, | ||
get_services, | ||
) | ||
|
||
|
||
def test_docker_instrumentation( | ||
jaeger_port, | ||
otlp_collector, | ||
otlp_receiver_port, | ||
docker_image_name, | ||
docker_image_built, | ||
prometheus_client, | ||
expected_flow_metric_labels, | ||
): | ||
f = Flow( | ||
tracing=True, | ||
traces_exporter_host='localhost', | ||
traces_exporter_port=otlp_receiver_port, | ||
metrics=True, | ||
metrics_exporter_host='localhost', | ||
metrics_exporter_port=otlp_receiver_port, | ||
).add(uses=f'docker://{docker_image_name}') | ||
|
||
with f: | ||
from jina import DocumentArray | ||
|
||
f.post(f'/search', DocumentArray.empty(), continue_on_error=True) | ||
# give some time for the tracing and metrics exporters to finish exporting. | ||
# the client is slow to export the data | ||
time.sleep(3) | ||
|
||
services = get_services(jaeger_port) | ||
assert set(services) == {'executor0/rep-0', 'gateway/rep-0'} | ||
|
||
exported_jobs = get_exported_jobs(prometheus_client) | ||
assert exported_jobs == { | ||
'gateway/rep-0', | ||
'executor0/rep-0', | ||
} | ||
|
||
flow_metric_labels = get_flow_metric_labels(prometheus_client) | ||
assert flow_metric_labels.issubset(expected_flow_metric_labels) |
File renamed without changes.
File renamed without changes.
File renamed without changes.