-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathconftest.py
38 lines (28 loc) · 1.16 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
# (C) Datadog, Inc. 2019-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
import os
import time
import pytest
import requests
from datadog_checks.dev import docker_run
from datadog_checks.dev.conditions import WaitForPortListening
from datadog_checks.dev.utils import load_jmx_config
from .common import BASE_URL, HERE, HOST, TEST_AUTH, TEST_MESSAGE, TEST_PORT, TEST_QUEUES, TEST_TOPICS
def populate_server():
"""Add some queues and topics to ensure more metrics are available."""
time.sleep(3)
for queue in TEST_QUEUES:
url = '{}/{}?type=queue'.format(BASE_URL, queue)
requests.post(url, data=TEST_MESSAGE, auth=TEST_AUTH)
for topic in TEST_TOPICS:
url = '{}/{}?type=topic'.format(BASE_URL, topic)
requests.post(url, data=TEST_MESSAGE, auth=TEST_AUTH)
@pytest.fixture(scope="session")
def dd_environment():
with docker_run(
os.path.join(HERE, 'compose', 'docker-compose.yaml'),
log_patterns=['ActiveMQ Jolokia REST API available'],
conditions=[WaitForPortListening(HOST, TEST_PORT), populate_server],
):
yield load_jmx_config(), {'use_jmx': True}