コード例 #1
0
import mock

import os
import shutil
import tempfile
import utils

from common import constants

utils.add_sys_plugin_path("rabbitmq")
from plugins.rabbitmq.parts import (  # noqa E402
    services, )


class TestRabbitmqPluginPartServices(utils.BaseTestCase):
    def setUp(self):
        super().setUp()
        self.tmpdir = tempfile.mkdtemp()

    def tearDown(self):
        if os.path.isdir(self.tmpdir):
            shutil.rmtree(self.tmpdir)

        super().tearDown()

    @mock.patch.object(services, "RABBITMQ_INFO", {})
    def test_get_service_info_bionic(self):
        expected = {
            'services': ['beam.smp (1)'],
            'resources': {
                'vhosts': [
コード例 #2
0
ファイル: test_storage.py プロジェクト: ivoks/hotsos
import mock

import utils

utils.add_sys_plugin_path("storage")

from plugins.storage import (  # noqa E402
    _01ceph, _02bcache, _03ceph_daemon_logs,
)


class TestStoragePlugin01ceph(utils.BaseTestCase):
    def setUp(self):
        super().setUp()
        _01ceph.issues_utils.PLUGIN_TMP_DIR = self.plugin_tmp_dir

    def tearDown(self):
        super().tearDown()
        _01ceph.issues_utils.PLUGIN_TMP_DIR = ""

    @mock.patch.object(_01ceph.helpers, "get_date")
    def test_get_date_secs(self, mock_get_date):
        mock_get_date.return_value = "1234\n"
        c = _01ceph.get_ceph_checker()
        self.assertEquals(c.get_date_secs(), 1234)

    @mock.patch.object(_01ceph.helpers, "get_date")
    def test_get_date_secs_from_timestamp(self, mock_get_date):
        mock_get_date.return_value = "1234\n"
        date_string = "Thu Mar 25 10:55:05 MDT 2021"
        c = _01ceph.get_ceph_checker()
コード例 #3
0
ファイル: test_openstack.py プロジェクト: freyes/hotsos
import os

import datetime
import mock
import tempfile

import utils

from common import searchtools

# Need this for plugin imports
utils.add_sys_plugin_path("openstack")
from plugins.openstack.parts import (  # noqa E402
    openstack_services,
    vm_info,
    nova_external_events,
    package_info,
    network,
    service_features,
    cpu_pinning_check,
    agent_checks,
    agent_exceptions,
    neutron_l3ha,
)


APT_UCA = """
# Ubuntu Cloud Archive
deb http://ubuntu-cloud.archive.canonical.com/ubuntu bionic-updates/{} main
"""
コード例 #4
0
ファイル: test_juju.py プロジェクト: dosaboy/hotsos
import os

import mock
import shutil
import tempfile

import utils

from common import known_bugs_utils

# Need this for plugin imports
utils.add_sys_plugin_path("juju")
from plugins.juju.parts import (  # noqa E402
    services, charms, units, known_bugs,
)


class TestJujuPluginPartServices(utils.BaseTestCase):
    def setUp(self):
        super().setUp()

    def tearDown(self):
        super().tearDown()

    @mock.patch.object(services, 'JUJU_MACHINE_INFO', {"machines": {}})
    def test_get_machine_info(self):
        expected = {
            'machines': {
                'running': ['33 (version=unknown)', '0 (version=unknown)']
            }
        }
コード例 #5
0
import os

import mock
import shutil
import tempfile

import utils

# Need this for plugin imports
utils.add_sys_plugin_path("kernel")
from plugins.kernel.parts import (  # noqa E402
    kernel_info, kernel_memory, kernel_network,
)


class TestKernelPluginPartKernelInfo(utils.BaseTestCase):
    def setUp(self):
        super().setUp()

    def tearDown(self):
        super().tearDown()

    @mock.patch.object(kernel_info, "KERNEL_INFO", {})
    def test_get_cmdline_info(self):
        kernel_info.KernelGeneralChecks().get_cmdline_info()
        expected = {
            'boot':
            'ro '
            'console=tty0 console=ttyS0,115200 console=ttyS1,115200 '
            'panic=30 raid=noautodetect'
        }
コード例 #6
0
ファイル: test_kubernetes.py プロジェクト: nicolasbock/hotsos
import os

import mock

import utils

from common import cli_helpers

# Need this for plugin imports
utils.add_sys_plugin_path("kubernetes")
from plugins.kubernetes.parts import (  # noqa E402
    general, network,
)


class TestKubernetesPluginPartGeneral(utils.BaseTestCase):
    def setUp(self):
        self.snaps_list = cli_helpers.get_snap_list_all()
        super().setUp()

    def tearDown(self):
        super().tearDown()

    @mock.patch.object(general, "KUBERNETES_INFO", {})
    def test_get_service_info(self):
        expected = [
            'calico-node (3)', 'containerd (17)', 'containerd-shim (16)',
            'flanneld (1)', 'kube-proxy (1)', 'kubelet (2)'
        ]
        general.get_kubernetes_service_checker()()
        self.assertEqual(general.KUBERNETES_INFO['services'], expected)
コード例 #7
0
ファイル: test_openvswitch.py プロジェクト: dosaboy/hotsos
import os
import shutil
import tempfile

import mock

import utils

# Need this for plugin imports
utils.add_sys_plugin_path("openvswitch")
from plugins.openvswitch.parts import (  # noqa E402
    ovs_checks, ovs_resources,
)


class TestOpenvswitchPluginPartOpenvswitchServices(utils.BaseTestCase):
    def setUp(self):
        super().setUp()

    def tearDown(self):
        super().tearDown()

    @mock.patch.object(ovs_resources, "OVS_INFO", {})
    def test_get_package_checks(self):
        expected = {
            'dpkg': [
                'libc-bin 2.23-0ubuntu11.2',
                'openvswitch-switch 2.9.5-0ubuntu0.18.04.1~cloud0'
            ]
        }
コード例 #8
0
import mock

import utils

utils.add_sys_plugin_path("system")
from plugins.system.parts import (  # noqa E402
    system,
)


class TestSystemPluginPartSystem(utils.BaseTestCase):

    def setUp(self):
        super().setUp()

    def tearDown(self):
        super().tearDown()

    @mock.patch.object(system, "SYSTEM_INFO", {})
    def test_get_service_info(self):
        expected = {'hostname': 'hothost',
                    'num-cpus': 72,
                    'os': 'ubuntu bionic',
                    'unattended-upgrades': 'ENABLED'}
        system.get_system_checks()()
        self.assertEqual(system.SYSTEM_INFO, expected)