Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support to IBM MQ #10737

Merged
merged 49 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6517d7b
[Release] Bumped ibm_mq version to 3.16.2
hithwen Nov 26, 2021
6806f24
[Release] Update metadata
hithwen Nov 26, 2021
3ed20a7
Include dependency on windows
hithwen Nov 26, 2021
7610258
[Release] Bumped ibm_mq version to 3.16.2-beta
hithwen Nov 26, 2021
137b3a4
[Release] Update metadata
hithwen Nov 26, 2021
3aac77d
[Release] Bumped ibm_mq version to 3.16.2-beta.2
hithwen Nov 26, 2021
54a4cd4
[Release] Update metadata
hithwen Nov 26, 2021
dcbcdfe
Merge remote-tracking branch 'origin/master' into js/FRAGENT-1564-ibm…
hithwen Dec 13, 2021
bd742fe
Merge remote-tracking branch 'origin/master' into js/FRAGENT-1564-ibm…
hithwen Dec 16, 2021
6e2223e
Test in windows
hithwen Dec 16, 2021
77c7f2c
Add install instructions for windows
hithwen Dec 17, 2021
e2fe1f0
Add MQ_FILE_PATH env var to tests
hithwen Dec 17, 2021
9e7cd42
Add artificial change to make it test
hithwen Dec 17, 2021
9cec72c
Add ibm mq to list of changes to check
hithwen Dec 17, 2021
c67ae1f
Add python-dev dependency
hithwen Dec 17, 2021
0f7750f
Add python-dev in requirements-dev
hithwen Dec 17, 2021
57c2e73
Pin python-dev dependency
hithwen Dec 17, 2021
b97c7fd
fix package name
hithwen Dec 17, 2021
7615d5f
Do not run unit & integration tests on windows
hithwen Dec 17, 2021
93aedd7
Remove python-dev dependency
hithwen Dec 17, 2021
4f29b1b
Run e2e even if integration fails
hithwen Dec 17, 2021
5f041d8
Add install script
hithwen Dec 17, 2021
34e57b0
Fix bat script
hithwen Dec 17, 2021
d6eda84
Do not skip tests on windows
hithwen Dec 17, 2021
fa10050
Dir the directory
hithwen Dec 17, 2021
7603702
Provide right path to ps1 script
hithwen Dec 17, 2021
941f23c
Change dir command
hithwen Dec 17, 2021
b10175b
Use just one script
hithwen Dec 20, 2021
0c9e1c1
Add more messages to script
hithwen Dec 20, 2021
38e6cc6
Simpler download and extract script
hithwen Dec 20, 2021
65ce864
Fix variable definition
hithwen Dec 20, 2021
9d805ec
Fix variables
hithwen Dec 20, 2021
4737676
Fix string?
hithwen Dec 20, 2021
0c38008
Create directory
hithwen Dec 20, 2021
27d3d05
Fix variable
hithwen Dec 20, 2021
a2ed0db
Use drive download
hithwen Dec 20, 2021
d19c615
fix url?
hithwen Dec 20, 2021
7918306
try to fix build
ofek Dec 20, 2021
4b9a70f
migrate script to python
hithwen Dec 21, 2021
885cedf
t merge origin/master
hithwen Dec 21, 2021
9d19c25
Fix os separator in conftest
hithwen Dec 21, 2021
e1f2462
Do not install server, skip int tests on windows
hithwen Dec 21, 2021
00a4b1a
Undo pipeline changes
hithwen Dec 21, 2021
c9c174d
Run tests on py2 too
hithwen Dec 21, 2021
2826ca7
Do not run py2 on windows
hithwen Dec 21, 2021
26e7911
add back support for non-CI Windows
ofek Dec 22, 2021
b6dc116
No need to force import on common
hithwen Dec 22, 2021
eb1af7a
Merge remote-tracking branch 'origin/master' into js/FRAGENT-1564-ibm…
hithwen Dec 23, 2021
e5bb452
Merge remote-tracking branch 'origin/master' into js/FRAGENT-1564-ibm…
hithwen Dec 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure-pipelines/changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- template: './templates/test-single-windows.yml'
parameters:
job_name: Changed
check: '--changed datadog_checks_base datadog_checks_dev active_directory aspdotnet disk dns_check dotnetclr exchange_server iis network pdh_check sqlserver tcp_check win32_event_log windows_performance_counters windows_service wmi_check'
check: '--changed datadog_checks_base datadog_checks_dev active_directory aspdotnet disk dns_check dotnetclr exchange_server ibm_mq iis network pdh_check sqlserver tcp_check win32_event_log windows_performance_counters windows_service wmi_check'
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
ddtrace_flag: '--ddtrace'
validate_changed: changed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
from tempfile import TemporaryDirectory
from zipfile import ZipFile

import requests


CLIENT_VERSION = '9.2.2.0'
CLIENT_ARCHIVE_NAME = f'{CLIENT_VERSION}-IBM-MQC-Redist-Win64.zip'
CLIENT_URL = f'https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqdev/redist/{CLIENT_ARCHIVE_NAME}'
CLIENT_TARGET_DIR = 'C:\\ibm_mq'


def download_file(url, file_name):
response = requests.get(url, stream=True)
response.raise_for_status()

with open(file_name, 'wb') as f:
for chunk in response.iter_content(16384):
f.write(chunk)


def main():
with TemporaryDirectory() as d:
temp_dir = os.path.realpath(d)

print('Downloading client')
client_archive_path = os.path.join(temp_dir, CLIENT_ARCHIVE_NAME)
download_file(CLIENT_URL, client_archive_path)

print('Extracting client')
with ZipFile(client_archive_path) as zip_file:
zip_file.extractall(CLIENT_TARGET_DIR)


if __name__ == '__main__':
main()
5 changes: 4 additions & 1 deletion .azure-pipelines/templates/test-all-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ jobs:
displayName: IBM i
os: linux
- checkName: ibm_mq
displayName: IBM MQ
displayName: IBM MQ (Linux)
os: linux
- checkName: ibm_mq
displayName: IBM MQ (Windows)
os: windows
- checkName: ibm_was
displayName: IBM WAS
os: linux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pyhdb==0.3.4
pyjwt==1.7.1; python_version < "3.0"
pyjwt==2.0.1; python_version > "3.0"
pymongo==3.11.4
pymqi==1.12.0; sys_platform != "win32"
pymqi==1.12.0
pymysql==0.9.3
pyodbc==4.0.26
pyro4==4.73; sys_platform == "win32"
Expand Down
15 changes: 11 additions & 4 deletions ibm_mq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ This check monitors [IBM MQ][1] versions 8 to 9.0.

The IBM MQ check is included in the [Datadog Agent][2] package.

To use the IBM MQ check, you need to:
To use the IBM MQ check, you need to make sure the [IBM MQ Client][3] 9.1+ is installed (unless a compatible version of IBM MQ server is installed on the Agent host).

#### On Linux

1. Make sure the [IBM MQ Client][3] 9.1+ is installed (unless a compatible version of IBM MQ server is installed on the Agent host).
2. Update your `LD_LIBRARY_PATH` and `C_INCLUDE_PATH` to include the location of the libraries. (Create these two environment variables if they don’t exist yet.) For example:
Update your `LD_LIBRARY_PATH` and `C_INCLUDE_PATH` to include the location of the libraries. (Create these two environment variables if they don’t exist yet.)
For example, if you installed it in `/opt`:

```text
export LD_LIBRARY_PATH=/opt/mqm/lib64:/opt/mqm/lib:$LD_LIBRARY_PATH
Expand Down Expand Up @@ -129,7 +131,12 @@ Update the bindings:
sudo ldconfig
```

#### Permissions and authentication
#### On Windows

There is a file called `mqclient.ini` in the IBM MQ data directory. It is normally `C:\ProgramData\IBM\MQ`.
Configure the environment variable `MQ_FILE_PATH`, to point at the data directory.

### Permissions and authentication

There are many ways to set up permissions in IBM MQ. Depending on how your setup works, create a `datadog` user within MQ with read only permissions.

Expand Down
3 changes: 2 additions & 1 deletion ibm_mq/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"support": "core",
"supported_os": [
"linux",
"mac_os"
"mac_os",
"windows"
],
"public_title": "Datadog-IBM MQ Integration",
"categories": [
Expand Down
2 changes: 1 addition & 1 deletion ibm_mq/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pymqi==1.12.0; sys_platform != 'win32'
pymqi==1.12.0
8 changes: 8 additions & 0 deletions ibm_mq/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

import os

import pytest

from datadog_checks.dev import get_docker_hostname
from datadog_checks.dev.ci import running_on_ci
from datadog_checks.dev.utils import ON_WINDOWS

# Ignore missing library to not require it for e2e
try:
from datadog_checks.ibm_mq.metrics import COUNT, GAUGE
except ImportError:
COUNT = GAUGE = ''

RUNNING_ON_WINDOWS_CI = ON_WINDOWS and running_on_ci()
skip_windows_ci = pytest.mark.skipif(RUNNING_ON_WINDOWS_CI, reason='MQ server cannot be setup on Windows VMs in CI')


HERE = os.path.dirname(os.path.abspath(__file__))
COMPOSE_DIR = os.path.join(HERE, 'compose')

Expand Down
6 changes: 3 additions & 3 deletions ibm_mq/tests/test_ibm_mq_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

from datadog_checks.dev.utils import get_metadata_metrics

from .common import MQ_VERSION, assert_all_metrics
from .common import MQ_VERSION, assert_all_metrics, skip_windows_ci

pytestmark = [skip_windows_ci, pytest.mark.e2e]


@pytest.mark.e2e
def test_e2e_check_all(dd_agent_check, instance_collect_all):
aggregator = dd_agent_check(instance_collect_all, rate=True)

assert_all_metrics(aggregator)
aggregator.assert_metrics_using_metadata(get_metadata_metrics())


@pytest.mark.e2e
@pytest.mark.skipif(
MQ_VERSION < 9, reason='Only test for for version >=9, for v8 use a custom image with custom setup.'
)
Expand Down
4 changes: 2 additions & 2 deletions ibm_mq/tests/test_ibm_mq_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
from datadog_checks.dev.utils import get_metadata_metrics

from . import common
from .common import QUEUE_METRICS, assert_all_metrics
from .common import QUEUE_METRICS, assert_all_metrics, skip_windows_ci

pytestmark = [pytest.mark.usefixtures("dd_environment"), pytest.mark.integration]
pytestmark = [skip_windows_ci, pytest.mark.usefixtures("dd_environment"), pytest.mark.integration]


def test_no_msg_errors_are_caught(get_check, instance, caplog):
Expand Down
3 changes: 3 additions & 0 deletions ibm_mq/tests/test_ibm_mq_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from datadog_checks.base import AgentCheck, ConfigurationError

from .common import skip_windows_ci

pytestmark = pytest.mark.unit


Expand Down Expand Up @@ -182,6 +184,7 @@ def test_channel_queue_config_error(instance_config):
assert 'channel, queue_manager are required configurations' in str(excinfo.value)


@skip_windows_ci
def test_ssl_connection_creation(get_check, instance):
"""
Test that we are not getting unicode/bytes type error.
Expand Down
3 changes: 2 additions & 1 deletion ibm_mq/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# Licensed under a 3-clause BSD style license (see LICENSE)
import pytest

from .common import MQ_VERSION_RAW
from .common import MQ_VERSION_RAW, skip_windows_ci


@skip_windows_ci
@pytest.mark.integration
def test_metadata(get_check, instance, datadog_agent):
check = get_check(instance)
Expand Down
7 changes: 5 additions & 2 deletions ibm_mq/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ dd_mypy_args =
'.*/config_models/.*\.py$'
dd_mypy_deps =
types-mock==0.1.5
platform = linux|darwin|win32
platform =
linux|darwin
py38-9: linux|darwin|win32
deps =
-e../datadog_checks_base[deps]
-rrequirements-dev.txt
Expand All @@ -33,7 +35,8 @@ commands =
pip install -r requirements.in
pytest -v {posargs}
setenv =
LD_LIBRARY_PATH=/opt/mqm/lib64:/opt/mqm/lib:{env:LD_LIBRARY_PATH:none}
LD_LIBRARY_PATH=/opt/mqm/lib64{:}/opt/mqm/lib{:}C:\ibm_mq{:}{env:LD_LIBRARY_PATH:none}
MQ_FILE_PATH=C:\ibm_mq
8: IBM_MQ_VERSION = 8
8: IBM_MQ_COMPOSE_VERSION = 8
8: IBM_MQ_VERSION_RAW = 8.0.0.4
Expand Down