Skip to content
Permalink
Browse files

jolokia: conversion from string to list

CMK-1244

Change-Id: I95fe835cdfc6418d459f7fb8b2d8f5932d41041a
  • Loading branch information
anthonyh209 authored and mo-ki committed Jun 21, 2019
1 parent d82c7cc commit c2999dcb610ecbf45c87f5630928b00fcb424511
Showing with 32 additions and 7 deletions.
  1. +5 −7 checks/agent_jolokia
  2. +27 −0 tests/unit/checks/test_agent_jolokia.py
@@ -26,18 +26,16 @@


def agent_jolokia_arguments(params, hostname, ipaddress):
arglist = ['--server %s' % quote_shell_string(ipaddress)]
arglist = ['--server', ipaddress]

for param in ['port', 'suburi', 'instance', 'protocol']:
if param in params:
arglist.append('--%s %s' % (param, params[param]))
arglist += ['--%s' % param, '%s' % params[param]]

if 'login' in params:
arglist.append('--user %s' % params['login'][0])
arglist.append('--password %s' % params['login'][1])
arglist.append('--mode %s' % params['login'][2])
for pair in zip(('--user', '--password', '--mode'), params.get('login', ())):
arglist.extend(pair)

return " ".join(arglist)
return arglist


special_agent_info['jolokia'] = agent_jolokia_arguments
@@ -0,0 +1,27 @@
import pytest

pytestmark = pytest.mark.checks


@pytest.mark.parametrize('params,expected_args', [
({}, ["--server", "address"]),
({
'port': 8080
}, ["--server", "address", "--port", "8080"]),
({
'instance': u'monitor',
'port': 8080
}, ["--server", "address", "--port", "8080", "--instance", "monitor"]),
({
'login': ('userID', 'password', 'basic'),
'port': 8080
}, [
"--server", "address", "--port", "8080", "--user", "userID", "--password", "password",
"--mode", "basic"
]),
])
def test_jolokia_argument_parsing(check_manager, params, expected_args):
"""Tests if all required arguments are present."""
agent = check_manager.get_special_agent('agent_jolokia')
arguments = agent.argument_func(params, "host", "address")
assert arguments == expected_args

0 comments on commit c2999dc

Please sign in to comment.
You can’t perform that action at this time.