Skip to content

Commit

Permalink
try to fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed Dec 21, 2021
1 parent d19c615 commit be09296
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 57 deletions.
30 changes: 15 additions & 15 deletions .azure-pipelines/changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ variables:
DDEV_COLOR: 1
DD_TRACE_AGENT_PORT: 8127

resources:
containers:
- ${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
- container: dd_agent
image: gcr.io/datadoghq/agent:latest
ports:
- 8127:8126
env:
DD_API_KEY: $(DD_CI_API_KEY)
DD_HOSTNAME: "none"
DD_INSIDE_CI: "true"
# resources:
# containers:
# - ${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
# - container: dd_agent
# image: gcr.io/datadoghq/agent:latest
# ports:
# - 8127:8126
# env:
# DD_API_KEY: $(DD_CI_API_KEY)
# DD_HOSTNAME: "none"
# DD_INSIDE_CI: "true"

jobs:
- template: './templates/test-single-linux.yml'
parameters:
job_name: Changed
display: Linux
${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
ddtrace_flag: '--ddtrace'
# ${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
# ddtrace_flag: '--ddtrace'
validate: false
validate_codeowners: false
validate_changed: changed
Expand All @@ -47,8 +47,8 @@ jobs:
parameters:
job_name: Changed
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'
# ${{ if eq(variables['System.PullRequest.IsFork'], 'False') }}:
# ddtrace_flag: '--ddtrace'
validate_changed: changed
display: Windows
pip_cache_config:
Expand Down
67 changes: 67 additions & 0 deletions .azure-pipelines/scripts/ibm_mq/windows/55_install_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import os
import subprocess
from tempfile import TemporaryDirectory
from zipfile import ZipFile

import requests

SERVER_VERSION = '924'
SERVER_ARCHIVE_NAME = f'mqadv_dev{SERVER_VERSION}_windows.zip'
SERVER_URL = f'https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/messaging/mqadv/{SERVER_ARCHIVE_NAME}'

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)

print('Downloading server')
server_target_dir = os.path.join(temp_dir, 'server')
server_archive_path = os.path.join(temp_dir, SERVER_ARCHIVE_NAME)
download_file(SERVER_URL, server_archive_path)

print('Extracting server')
with ZipFile(server_archive_path) as zip_file:
zip_file.extractall(server_target_dir)

print('Installing server')
msi_path = os.path.join(server_target_dir, 'MQServer', 'MSI', 'IBM MQ.msi')
subprocess.check_call(
[
'msiexec',
'/quiet',
'/passive',
'/qn',
'/i',
msi_path,
'TRANSFORMS=1033.mst',
'AGREETOLICENSE=YES',
'ADDLOCAL=Server',
],
shell=True,
)


if __name__ == '__main__':
main()
12 changes: 0 additions & 12 deletions .azure-pipelines/scripts/ibm_mq/windows/install_ibm_mq.bat

This file was deleted.

6 changes: 1 addition & 5 deletions ibm_mq/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,7 @@
E2E_METADATA = {
'docker_volumes': ['{}/agent_scripts/start_commands.sh:/tmp/start_commands.sh'.format(HERE)],
'start_commands': ['bash /tmp/start_commands.sh'],
'env_vars': {
'LD_LIBRARY_PATH': '/opt/mqm/lib64:/opt/mqm/lib',
'C_INCLUDE_PATH': '/opt/mqm/inc',
'MQ_FILE_PATH': 'c:\\ibm_mq',
},
'env_vars': {'LD_LIBRARY_PATH': '/opt/mqm/lib64:/opt/mqm/lib', 'C_INCLUDE_PATH': '/opt/mqm/inc'},
}

QUEUE_METRICS = [
Expand Down
60 changes: 38 additions & 22 deletions ibm_mq/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import logging
import os
import re
import subprocess

import pytest
from six.moves import range

from datadog_checks.dev import docker_run
from datadog_checks.dev import docker_run, environment_run
from datadog_checks.dev.ci import running_on_ci
from datadog_checks.dev.conditions import CheckDockerLogs, WaitFor
from datadog_checks.dev.utils import ON_WINDOWS

Expand Down Expand Up @@ -138,11 +140,22 @@ def consume():
def prepare_queue_manager():
import pymqi

conn_info = '{0}({1})'.format(common.HOST, common.PORT)
qm_name = common.QUEUE_MANAGER.lower()
if ON_WINDOWS:
# https://developer.ibm.com/tutorials/mq-connect-app-queue-manager-windows/
exe_dir = os.path.join('C:', 'Program Files', 'IBM', 'MQ', 'bin')
subprocess.check_call([os.path.join(exe_dir, 'setmqenv'), '-s'], shell=True)
subprocess.check_call([os.path.join(exe_dir, 'crtmqm'), 'QM1'], shell=True)
subprocess.check_call([os.path.join(exe_dir, 'strmqm'), 'QM1'], shell=True)
qmgr = pymqi.connect(common.QUEUE_MANAGER)
else:
conn_info = '{0}({1})'.format(common.HOST, common.PORT)
qm_name = common.QUEUE_MANAGER.lower()

qmgr = pymqi.QueueManager(None)
qmgr.connectTCPClient(
common.QUEUE_MANAGER, pymqi.CD(), common.CHANNEL, conn_info, common.USERNAME, common.PASSWORD
)

qmgr = pymqi.QueueManager(None)
qmgr.connectTCPClient(common.QUEUE_MANAGER, pymqi.CD(), common.CHANNEL, conn_info, common.USERNAME, common.PASSWORD)
pcf = pymqi.PCFExecute(qmgr, response_wait_interval=5000)

attrs = [
Expand Down Expand Up @@ -196,21 +209,24 @@ def prepare_queue_manager():

@pytest.fixture(scope='session')
def dd_environment():

if common.MQ_VERSION == 9:
log_pattern = "AMQ5026I: The listener 'DEV.LISTENER.TCP' has started. ProcessId"
elif common.MQ_VERSION == 8:
log_pattern = r".*QMNAME\({}\)\s*STATUS\(Running\).*".format(common.QUEUE_MANAGER)
if ON_WINDOWS and running_on_ci():
with environment_run(up=lambda: None, down=lambda: None, conditions=[prepare_queue_manager]):
yield common.INSTANCE
else:
raise RuntimeError('Invalid version: {}'.format(common.MQ_VERSION))

e2e_meta = copy.deepcopy(common.E2E_METADATA)
e2e_meta.setdefault('docker_volumes', [])
e2e_meta['docker_volumes'].append("{}:/opt/pki/keys".format(os.path.join(common.HERE, 'keys')))

conditions = [CheckDockerLogs('ibm_mq1', log_pattern)]
if not ON_WINDOWS:
conditions.append(WaitFor(prepare_queue_manager))

with docker_run(compose_file=common.COMPOSE_FILE_PATH, build=True, conditions=conditions, sleep=10, attempts=2):
yield common.INSTANCE, e2e_meta
if common.MQ_VERSION == 9:
log_pattern = "AMQ5026I: The listener 'DEV.LISTENER.TCP' has started. ProcessId"
elif common.MQ_VERSION == 8:
log_pattern = r".*QMNAME\({}\)\s*STATUS\(Running\).*".format(common.QUEUE_MANAGER)
else:
raise RuntimeError('Invalid version: {}'.format(common.MQ_VERSION))

e2e_meta = copy.deepcopy(common.E2E_METADATA)
e2e_meta.setdefault('docker_volumes', [])
e2e_meta['docker_volumes'].append("{}:/opt/pki/keys".format(os.path.join(common.HERE, 'keys')))

conditions = [CheckDockerLogs('ibm_mq1', log_pattern)]
if not ON_WINDOWS:
conditions.append(WaitFor(prepare_queue_manager))

with docker_run(compose_file=common.COMPOSE_FILE_PATH, build=True, conditions=conditions, sleep=10, attempts=2):
yield common.INSTANCE, e2e_meta
8 changes: 5 additions & 3 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,8 +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}
MQ_FILE_PATH=c:\ibm_mq
LD_LIBRARY_PATH=/opt/mqm/lib64{:}/opt/mqm/lib{:}C:\ibm_mq{:}{env:LD_LIBRARY_PATH:none}
MQ_FILE_PATH=C:\ProgramData\IBM\MQ
8: IBM_MQ_VERSION = 8
8: IBM_MQ_COMPOSE_VERSION = 8
8: IBM_MQ_VERSION_RAW = 8.0.0.4
Expand Down

0 comments on commit be09296

Please sign in to comment.