-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test environment for activemq (#5204)
* Add test env for activemq * Minor refactor; update setup steps * Fix hostname reference * Update file headers Co-Authored-By: Ofek Lev <ofekmeister@gmail.com> * Increase CI to 3GB Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
- Loading branch information
Showing
11 changed files
with
143 additions
and
10 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
.azure-pipelines/scripts/activemq/linux/50_increase_docker_memory.sh
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,10 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
# Allocate 3GB for activemq | ||
# The default number of memory addresses is 65536, i.e. 512MB (Linux 64-bit). | ||
# => To get 3GB, we multiply that amount by 6. | ||
sudo sysctl -w vm.max_map_count=$(expr 6 \* 65536) | ||
|
||
set +ex |
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 @@ | ||
-e ../datadog_checks_dev |
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,3 @@ | ||
# (C) Datadog, Inc. 2019 | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) |
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,37 @@ | ||
# (C) Datadog, Inc. 2019 | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
from datadog_checks.dev import get_docker_hostname, get_here | ||
|
||
CHECK_NAME = 'activemq' | ||
|
||
HERE = get_here() | ||
HOST = get_docker_hostname() | ||
|
||
TEST_QUEUES = ('FOO_QUEUE', 'TEST_QUEUE') | ||
TEST_TOPICS = ('FOO_TOPIC', 'TEST_TOPIC') | ||
TEST_MESSAGE = {'body': 'test_message'} | ||
TEST_AUTH = ('admin', 'admin') | ||
|
||
TEST_PORT = 8161 | ||
BASE_URL = 'http://{}:{}/api/message'.format(HOST, TEST_PORT) | ||
|
||
# not all metrics will be available in our E2E environment, specifically: | ||
# "activemq.queue.dequeue_count", | ||
# "activemq.queue.dispatch_count", | ||
# "activemq.queue.enqueue_count", | ||
# "activemq.queue.expired_count", | ||
# "activemq.queue.in_flight_count", | ||
|
||
ACTIVEMQ_E2E_METRICS = [ | ||
"activemq.queue.avg_enqueue_time", | ||
"activemq.queue.consumer_count", | ||
"activemq.queue.producer_count", | ||
"activemq.queue.max_enqueue_time", | ||
"activemq.queue.min_enqueue_time", | ||
"activemq.queue.memory_pct", | ||
"activemq.queue.size", | ||
"activemq.broker.store_pct", | ||
"activemq.broker.temp_pct", | ||
"activemq.broker.memory_pct", | ||
] |
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,12 @@ | ||
version: "3" | ||
|
||
services: | ||
namenode: | ||
image: rmohr/activemq:${ACTIVEMQ_VERSION} | ||
container_name: dd-test-activemq-server | ||
environment: | ||
ACTIVEMQ_SUNJMX_START: "-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false" | ||
ports: | ||
- "61616:61616" | ||
- "8161:8161" | ||
- "1616:1616" |
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,38 @@ | ||
# (C) Datadog, Inc. 2019 | ||
# 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} |
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,16 @@ | ||
# (C) Datadog, Inc. 2019 | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
import pytest | ||
|
||
from .common import ACTIVEMQ_E2E_METRICS | ||
|
||
|
||
@pytest.mark.e2e | ||
def test(dd_agent_check): | ||
instance = {} | ||
aggregator = dd_agent_check(instance) | ||
|
||
for metric in ACTIVEMQ_E2E_METRICS: | ||
aggregator.assert_metric(metric) |
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,22 @@ | ||
[tox] | ||
minversion = 2.0 | ||
skip_missing_interpreters = true | ||
basepython = py37 | ||
envlist = | ||
py37 | ||
|
||
[testenv] | ||
description = | ||
py37: e2e ready | ||
usedevelop = true | ||
dd_check_style = true | ||
platform = linux|darwin|win32 | ||
deps = | ||
-e../datadog_checks_base[deps] | ||
-rrequirements-dev.txt | ||
passenv = | ||
DOCKER* | ||
COMPOSE* | ||
setenv = ACTIVEMQ_VERSION=5.15.9 | ||
commands = | ||
pytest -v {posargs} |