コード例 #1
0
def test_check_keypair(aggregator, instance):
    instance['private_key_file'] = PRIVATE_KEY_FILE
    instance['password'] = '******'
    check = CheckSSH('ssh_check', {}, [instance])
    check.check(instance)
    common._test_check(aggregator, instance)
    common.wait_for_threads()
コード例 #2
0
ファイル: test_ssh.py プロジェクト: zorgz/integrations-core
    def test_ssh(self, aggregator):
        c = CheckSSH('ssh_check', {}, {}, list(self.INSTANCES.values()))

        nb_threads = threading.active_count()

        c.check(self.INSTANCES['main'])

        for sc in aggregator.service_checks(CheckSSH.SSH_SERVICE_CHECK_NAME):
            assert sc.status == CheckSSH.OK
            for tag in sc.tags:
                assert tag in ('instance:io.netgarage.org-22', 'optional:tag1')

        # Check that we've closed all connections, if not we're leaking threads
        assert nb_threads == threading.active_count()
コード例 #3
0
ファイル: test_ssh.py プロジェクト: y14a/integrations-core
def test_ssh(aggregator):
    check = CheckSSH('ssh_check', {}, [common.INSTANCES['main']])

    nb_threads = threading.active_count()

    check.check(common.INSTANCES['main'])

    for sc in aggregator.service_checks(CheckSSH.SSH_SERVICE_CHECK_NAME):
        assert sc.status == CheckSSH.OK
        for tag in sc.tags:
            assert tag in ('instance:io.netgarage.org-22', 'optional:tag1')

    # Check that we've closed all connections, if not we're leaking threads
    common.wait_for_threads()
    assert nb_threads == threading.active_count()
コード例 #4
0
ファイル: test_ssh.py プロジェクト: zorgz/integrations-core
    def test_ssh_bad_config(self, aggregator):
        c = CheckSSH('ssh_check', {}, {}, list(self.INSTANCES.values()))

        nb_threads = threading.active_count()

        with pytest.raises(Exception):
            c.check(self.INSTANCES['bad_auth'])

        with pytest.raises(Exception):
            c.check(self.INSTANCES['bad_hostname'])

        for sc in aggregator.service_checks(CheckSSH.SSH_SERVICE_CHECK_NAME):
            assert sc.status == CheckSSH.CRITICAL

        # Check that we've closed all connections, if not we're leaking threads
        assert nb_threads == threading.active_count()
コード例 #5
0
ファイル: test_ssh.py プロジェクト: y14a/integrations-core
def test_ssh_bad_config(aggregator):

    nb_threads = threading.active_count()

    with pytest.raises(Exception):
        check = CheckSSH('ssh_check', {}, [common.INSTANCES['bad_auth']])
        check.check(common.INSTANCES['bad_auth'])

    with pytest.raises(Exception):
        check = CheckSSH('ssh_check', {}, [common.INSTANCES['bad_hostname']])
        check.check(common.INSTANCES['bad_hostname'])

    for sc in aggregator.service_checks(CheckSSH.SSH_SERVICE_CHECK_NAME):
        assert sc.status == CheckSSH.CRITICAL

    # Check that we've closed all connections, if not we're leaking threads
    common.wait_for_threads()
    assert nb_threads == threading.active_count()
コード例 #6
0
def test_metadata(aggregator, instance, datadog_agent):
    check = CheckSSH('ssh_check', {}, [instance])
    check.check_id = 'test:123'
    check.check(instance)

    _, _, flavor, raw_version = re.split(r'[-_]', common.SSH_SERVER_VERSION)
    major, minor = raw_version.split(".")

    version_metadata = {
        'version.scheme': 'ssh_check',
        'version.major': major,
        'version.minor': minor,
        'version.raw': common.SSH_SERVER_VERSION,
        'flavor': flavor,
    }

    datadog_agent.assert_metadata('test:123', version_metadata)

    common.wait_for_threads(
    )  # needed, otherwise the next won't count correctly threads
コード例 #7
0
def test_check(aggregator, instance):
    check = CheckSSH('ssh_check', {}, [instance])
    check.check(instance)
    common._test_check(aggregator, instance)
    common.wait_for_threads()