forked from elastic/apm-integration-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
55 lines (48 loc) · 1.89 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
import os
import pytest
import json
import subprocess
import sys
from tests.fixtures.transactions import minimal
from tests.fixtures.apm_server import apm_server
from tests.fixtures.es import es
from tests.fixtures.kibana import kibana
from tests.fixtures.agents import flask
from tests.fixtures.agents import django
from tests.fixtures.agents import dotnet
from tests.fixtures.agents import express
from tests.fixtures.agents import rails
from tests.fixtures.agents import go_nethttp
from tests.fixtures.agents import java_spring
from tests.fixtures.agents import rum
from tests.fixtures import default
def pytest_addoption(parser):
parser.addoption(
"--run-upgrade", action="store_true", default=False, help="run upgrade tests"
)
def pytest_collection_modifyitems(config, items):
if config.getoption("--run-upgrade"):
return
skip_upgrade = pytest.mark.skip(reason="need --run-upgrade option to run")
for item in items:
if item.get_marker("upgradetest"):
item.add_marker(skip_upgrade)
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_logreport(report):
yield
if report.when == "call" and report.failed:
name = report.nodeid.split(":", 2)[-1]
try:
es_url = default.from_env("ES_URL")
isDumpEnable = os.getenv("ENABLE_ES_DUMP")
if isDumpEnable is not None:
subprocess.call(['elasticdump',
'--input={}/apm-*'.format(es_url),
'--output=/app/tests/results/data-{}.json'.format(name)])
subprocess.call(['elasticdump',
'--input={}/packetbeat-*'.format(es_url),
'--output=/app/tests/results/packetbeat-{}.json'.format(name)])
except IOError:
sys.stderr.write("Error launching elasticdump")
pass