Exemplo n.º 1
0
def test_get_hostname():
    hn = Hostname(context_wrap(HOSTNAME))
    expected = (HOSTNAME, HOSTNAME_SHORT, 'example.com')
    result = hostname(hn, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]

    hn = Hostname(context_wrap(HOSTNAME_SHORT))
    expected = (HOSTNAME_SHORT, HOSTNAME_SHORT, '')
    result = hostname(hn, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemplo n.º 2
0
def test_hostname():
    data = Hostname(context_wrap(HOSTNAME))
    assert data.fqdn == "rhel7.example.com"
    assert data.hostname == "rhel7"
    assert data.domain == "example.com"
    assert "{0}".format(data) == "<hostname: rhel7, domain: example.com>"

    data = Hostname(context_wrap(HOSTNAME_SHORT))
    assert data.fqdn == "rhel7"
    assert data.hostname == "rhel7"
    assert data.domain == ""

    data = Hostname(context_wrap(""))
    assert data.fqdn is None
    assert data.hostname is None
    assert data.domain is None
Exemplo n.º 3
0
def test_lssap_ascs():
    lssap = Lssap(context_wrap(Lssap_ascs_TEST))
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    sap = Sap(hn, None, lssap)
    assert sap['ASCS16'].sid == 'HA2'
    assert sap.is_netweaver is False
    assert sap.is_hana is False
    assert sap.is_ascs is True
Exemplo n.º 4
0
def test_doc_examples():
    env = {
        'saps':
        Sap(hostname(Hostname(context_wrap(HOSTNAME)), None, None), None,
            Lssap(context_wrap(Lssap_doc_TEST)))
    }
    failed, total = doctest.testmod(sap, globs=env)
    assert failed == 0
Exemplo n.º 5
0
def test_full_multiline_hostname():
    data = Hostname(context_wrap(HOSTNAME_FULL_MULTILINE, strip=False))
    assert data.fqdn == "rhel7.example.com"
    assert data.hostname == "rhel7"
    assert data.domain == "example.com"
    assert "{0}".format(
        data
    ) == "<raw: rhel7.example.com, hostname: rhel7, domain: example.com>"
Exemplo n.º 6
0
def test_lssap_hana():
    lssap = Lssap(context_wrap(Lssap_hana_TEST))
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    sap = Sap(hn, None, lssap)
    assert 'D50' not in sap
    assert sap.is_netweaver is False
    assert sap.is_hana is True
    assert sap.is_ascs is False
Exemplo n.º 7
0
def test_hostname_doc():
    env = {
        'hostname': Hostname(context_wrap(HOSTNAME_FULL)),
        'hostname_def': HostnameDefault(context_wrap(HOSTNAME_SHORT)),
        'hostname_s': HostnameShort(context_wrap(HOSTNAME_SHORT)),
    }
    failed, total = doctest.testmod(hostname, globs=env)
    assert failed == 0
Exemplo n.º 8
0
def test_all():
    lssap = Lssap(context_wrap(Lssap_all_TEST))
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    sap = Sap(hn, None, lssap)
    assert sap['D16'].version == '749, patch 10, changelist 1698137'
    assert sap['ASCS16'].hostname == 'lu0417'
    assert sap.is_netweaver is True
    assert sap.is_hana is True
    assert sap.is_ascs is True
Exemplo n.º 9
0
def test_get_all_hostname():
    hn = Hostname(context_wrap(HOSTNAME))
    fhn = Facter(context_wrap(FACTS_FQDN))
    shn = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME, HOSTNAME_SHORT, 'example.com')
    result = hostname(hn, fhn, shn)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemplo n.º 10
0
def test_full_hostname():
    data = Hostname(context_wrap(HOSTNAME_FULL))
    assert data.fqdn == "rhel7.example.com"
    assert data.raw == "rhel7.example.com"
    assert data.hostname == "rhel7"
    assert data.domain == "example.com"
    assert "{0}".format(
        data
    ) == "<raw: rhel7.example.com, hostname: rhel7, domain: example.com>"
Exemplo n.º 11
0
def test_lssap_netweaver():
    lssap = Lssap(context_wrap(Lssap_nw_TEST))
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    sap = Sap(hn, None, lssap)
    assert sap['D50'].number == '50'
    assert 'D16' in sap.local_instances
    assert 'D51' in sap.all_instances
    assert 'D51' not in sap.local_instances
    assert sap.is_netweaver is True
    assert sap.is_hana is False
    assert sap.is_ascs is False
Exemplo n.º 12
0
def test_hostname_uh():
    hostname = Hostname(context_wrap(HOSTNAME))
    uname = Uname(context_wrap(UNAME))

    hostname_uh = HostnameUH(hostname, None)
    assert hostname_uh.hostname == HOSTNAME

    hostname_uh = HostnameUH(None, uname)
    assert hostname_uh.hostname == "hostone_u.example.com"

    hostname_uh = HostnameUH(hostname, uname)
    assert hostname_uh.hostname == HOSTNAME
Exemplo n.º 13
0
def test_saphostcrtl_hana():
    lssap = Lssap(context_wrap(Lssap_nw_TEST))
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES))
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    sap = Sap(hn, inst, lssap)
    assert 'D50' not in sap
    assert sap.local_instances == ['HDB88']
    assert 'HDB90' in sap.all_instances
    assert sap['HDB88'].number == '88'
    assert sap['HDB90'].hostname == 'lu0418'
    assert sap['HDB90'].version == '749, patch 211, changelist 1754007'
    assert sap.number('HDB90') == '90'
    assert sap.sid('HDB88') == 'D89'
    assert sap.is_netweaver is False
    assert sap.is_hana is True
    assert sap.is_ascs is False
Exemplo n.º 14
0
def test_saphostcrtl_hana_2():
    lssap = Lssap(context_wrap(Lssap_all_TEST))
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_GOOD))
    hn = hostname(Hostname(context_wrap(HOSTNAME1)), None, None)
    sap = Sap(hn, inst, lssap)
    assert 'D50' not in sap
    assert sorted(sap.local_instances) == sorted(['HDB88', 'HDB90', 'SMDA91'])
    assert sorted(sap.business_instances) == sorted(['HDB88', 'HDB90'])
    assert sorted(sap.function_instances) == sorted(['SMDA91'])
    assert 'ASCS52' in sap.all_instances
    assert sap['HDB88'].number == '88'
    assert sap['HDB90'].hostname == 'li-ld-1810'
    assert sap['DVEBMGS09'].version == '749, patch 301, changelist 1779613'
    assert sap.version('HDB90') == '749, patch 211, changelist 1754007'
    assert sap.hostname('HDB62') == 'd62dbsrv'
    assert sap.type('SCS10') == 'SCS'
    assert sap.is_netweaver is False
    assert sap.is_hana is True
    assert sap.is_ascs is False
Exemplo n.º 15
0
from insights.core.plugins import make_fail
from insights.plugins import insights_heartbeat
from insights.parsers.hostname import Hostname
from insights.specs import Specs
from insights.tests import context_wrap, InputData, run_test

NON_MATCHING_HOSTNAME = "some-other-hostname-that-doesnt-match"

good = Hostname(context_wrap(insights_heartbeat.HOST))
bad = Hostname(context_wrap(NON_MATCHING_HOSTNAME))


def test_heartbeat():
    expected_result = make_fail(insights_heartbeat.ERROR_KEY)
    assert expected_result == insights_heartbeat.is_insights_heartbeat(good)
    assert insights_heartbeat.is_insights_heartbeat(bad) is None


def test_integration_tests():
    comp = insights_heartbeat.is_insights_heartbeat

    input_data = InputData(name="Match: no kernel")
    input_data.add(Specs.hostname, insights_heartbeat.HOST)
    expected = make_fail(insights_heartbeat.ERROR_KEY)
    run_test(comp, input_data, expected)

    input_data = InputData(name="No Match: bad hostname")
    input_data.add(Specs.hostname, NON_MATCHING_HOSTNAME)
    run_test(comp, input_data, None)
Exemplo n.º 16
0
def test_short_multiline_hostname():
    data = Hostname(context_wrap(HOSTNAME_SHORT_MULTILINE, strip=False))
    assert data.fqdn == "rhel7"
    assert data.hostname == "rhel7"
    assert data.domain == ""
Exemplo n.º 17
0
def test_empty_hostname():
    with pytest.raises(Exception):
        Hostname(context_wrap(""))
Exemplo n.º 18
0
def test_ab():
    hn = hostname(Hostname(context_wrap(HOSTNAME)), None, None)
    with pytest.raises(SkipException) as se:
        Sap(hn, None, None)
    assert 'No SAP instance.' in str(se)
Exemplo n.º 19
0
def test_hostname_raise():
    hn = Hostname(context_wrap(""))
    with pytest.raises(Exception):
        hostname(hn, None, None)
Exemplo n.º 20
0
def test_short_hostname():
    data = Hostname(context_wrap(HOSTNAME_SHORT))
    assert data.fqdn == "rhel7"
    assert data.hostname == "rhel7"
    assert data.domain == ""