1- import os
1+ import os .path
2+ import shutil
23import subprocess
4+ import time
35
46import pytest
57import requests
68from weaver_container import WeaverContainer
79
8- FLASK_PORT = " 5000"
10+ FLASK_PORT = 5000
911
1012
1113@pytest .fixture (scope = "function" )
@@ -18,32 +20,42 @@ def weaver_container_v1_36():
1820
1921
2022@pytest .fixture
21- def flask_fixture (weaver_container_v1_36 ):
22- otlp_endpoint = weaver_container_v1_36 .get_otlp_endpoint ()
23+ def flask_fixture (): # weaver_container_v1_36):
24+ # otlp_endpoint = weaver_container_v1_36.get_otlp_endpoint()
25+ wrapper = shutil .which ("opentelemetry-instrument" )
2326 opentelemetry_instrumentation = [
24- "opentelemetry-instrumentation" ,
27+ wrapper ,
2528 "--metric_export_interval" ,
26- 1 ,
27- "--exporter_otlp_endpoint" ,
28- otlp_endpoint ,
29+ "1000" ,
30+ # "--exporter_otlp_endpoint",
31+ # otlp_endpoint,
2932 ]
33+ application_path = os .path .join (os .path .dirname (__file__ ))
3034 handler = subprocess .Popen (
31- opentelemetry_instrumentation + ["flask" , "run" , "-p" , FLASK_PORT ]
35+ opentelemetry_instrumentation
36+ + ["flask" , "run" , "-p" , f"{ FLASK_PORT } " ],
37+ cwd = application_path ,
3238 )
3339
34- os .sleep (1 )
40+ time .sleep (1 )
3541
3642 yield
3743
44+ time .sleep (1 )
45+
3846 handler .terminate ()
3947 handler .wait (timeout = 5 )
4048
4149
42- def test_flask_request (flask_fixture , weaver_container_v1_36 ):
43- response = requests .get (f"http://127.0.0.1:{ FLASK_PORT } " )
44-
50+ def test_flask_request (flask_fixture ): # , weaver_container_v1_36):
51+ response = requests .get (f"http://127.0.0.1:{ FLASK_PORT } /rolldice" )
4552 assert response .status_code == 200
4653
54+ response = requests .get (f"http://127.0.0.1:{ FLASK_PORT } /" )
55+ assert response .status_code == 404
56+
57+ """
4758 full_report = weaver_container_v1_36.end_live_check()
4859
4960 assert full_report
61+ """
0 commit comments