Skip to content

Commit c91f281

Browse files
committed
Make it work without dockerweaver
1 parent 9619310 commit c91f281

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

tests/weaver-tests/tests/flask/app.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,3 @@ def roll_dice():
2222

2323
def roll():
2424
return randint(1, 6)
25-
26-
27-
if __name__ == "__main__":
28-
app.run(port=8002, debug=True, use_reloader=False)
Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import os
1+
import os.path
2+
import shutil
23
import subprocess
4+
import time
35

46
import pytest
57
import requests
68
from 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

Comments
 (0)