예제 #1
0
def test_storeonce_argument_parsing(params, expected_args):
    """Tests if all required arguments are present."""
    agent = SpecialAgent("agent_storeonce")
    arguments = agent.argument_func(params, "host", "address")
    assert arguments == expected_args
예제 #2
0
def test_ddn_s2a(params, result):
    agent = SpecialAgent("agent_ddn_s2a")
    arguments = agent.argument_func(params, "host", "address")
    assert arguments == result
예제 #3
0
def test_cisco_prime_argument_parsing(params, hostname, ipaddress, args):
    agent = SpecialAgent("agent_cisco_prime")
    arguments = agent.argument_func(params, hostname, ipaddress)
    assert arguments == args
예제 #4
0
def test_parse_arguments(params, expected_args):
    """Tests if all required arguments are present."""
    agent = SpecialAgent("agent_kube")
    arguments = agent.argument_func(params, "host", "127.0.0.1")
    assert arguments == expected_args
예제 #5
0
def test_host_labels_annotation_selection():
    """Test the import-annotations option"""
    agent = SpecialAgent("agent_kube")

    # Option not set -> no annotations imported. This special case is covered
    # by test_parse_arguments. If test_parse_arguments is migrated, this
    # special case needs to be reconsidered.

    # Explicit no filtering
    arguments = agent.argument_func(
        {
            "cluster-name": "cluster",
            "token": ("password", "token"),
            "kubernetes-api-server": {
                "endpoint": "https://11.211.3.32",
                "verify-cert": False,
                "proxy": ("no_proxy", "no_proxy"),
            },
            "import-annotations": "include-annotations-as-host-labels",
            "monitored-objects": ["pods"],
        },
        "host",
        "11.211.3.32",
    )
    assert arguments == [
        "--cluster",
        "cluster",
        "--token",
        "token",
        "--monitored-objects",
        "pods",
        "--cluster-aggregation-exclude-node-roles",
        "control-plane",
        "infra",
        "--include-annotations-as-host-labels",
        "--api-server-endpoint",
        "https://11.211.3.32",
        "--api-server-proxy",
        "NO_PROXY",
    ]

    # Explicit filtering
    arguments = agent.argument_func(
        {
            "cluster-name":
            "cluster",
            "token": ("password", "token"),
            "kubernetes-api-server": {
                "endpoint": "https://11.211.3.32",
                "verify-cert": False,
                "proxy": ("no_proxy", "no_proxy"),
            },
            "import-annotations": (
                "include-matching-annotations-as-host-labels",
                "checkmk-monitoring$",
            ),
            "monitored-objects": ["pods"],
        },
        "host",
        "11.211.3.32",
    )
    assert arguments == [
        "--cluster",
        "cluster",
        "--token",
        "token",
        "--monitored-objects",
        "pods",
        "--cluster-aggregation-exclude-node-roles",
        "control-plane",
        "infra",
        "--include-matching-annotations-as-host-labels",
        "checkmk-monitoring$",
        "--api-server-endpoint",
        "https://11.211.3.32",
        "--api-server-proxy",
        "NO_PROXY",
    ]
예제 #6
0
def test_cluster_resource_aggregation():
    """Test the cluster-resource-aggregation option"""
    agent = SpecialAgent("agent_kube")
    arguments = agent.argument_func(
        {
            "cluster-name":
            "cluster",
            "token": ("password", "token"),
            "kubernetes-api-server": {
                "endpoint": "https://11.211.3.32",
                "verify-cert": False,
                "proxy": ("no_proxy", "no_proxy"),
            },
            "monitored-objects": ["pods"],
            "cluster-resource-aggregation": (
                "cluster-aggregation-exclude-node-roles",
                ["control*", "worker"],
            ),
        },
        "host",
        "11.211.3.32",
    )
    assert arguments == [
        "--cluster",
        "cluster",
        "--token",
        "token",
        "--monitored-objects",
        "pods",
        "--cluster-aggregation-exclude-node-roles",
        "control*",
        "worker",
        "--api-server-endpoint",
        "https://11.211.3.32",
        "--api-server-proxy",
        "NO_PROXY",
    ]
    arguments = agent.argument_func(
        {
            "cluster-name":
            "cluster",
            "token": ("password", "token"),
            "kubernetes-api-server": {
                "endpoint": "https://11.211.3.32",
                "verify-cert": False,
                "proxy": ("no_proxy", "no_proxy"),
            },
            "monitored-objects": ["pods"],
            "cluster-resource-aggregation":
            "cluster-aggregation-include-all-nodes",
        },
        "host",
        "11.211.3.32",
    )
    assert arguments == [
        "--cluster",
        "cluster",
        "--token",
        "token",
        "--monitored-objects",
        "pods",
        "--cluster-aggregation-include-all-nodes",
        "--api-server-endpoint",
        "https://11.211.3.32",
        "--api-server-proxy",
        "NO_PROXY",
    ]
    arguments = agent.argument_func(
        {
            "cluster-name": "cluster",
            "token": ("password", "token"),
            "kubernetes-api-server": {
                "endpoint": "https://11.211.3.32",
                "verify-cert": False,
                "proxy": ("no_proxy", "no_proxy"),
            },
            "monitored-objects": ["pods"],
        },
        "host",
        "11.211.3.32",
    )
    assert arguments == [
        "--cluster",
        "cluster",
        "--token",
        "token",
        "--monitored-objects",
        "pods",
        "--cluster-aggregation-exclude-node-roles",
        "control-plane",
        "infra",
        "--api-server-endpoint",
        "https://11.211.3.32",
        "--api-server-proxy",
        "NO_PROXY",
    ]