def test_ld_library_path_of_user():
    # Good
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES))
    hn = Hostname(HostnameParser(context_wrap(HOSTNAME)), None, None, None)
    sap = Sap(hn, inst, None)
    broker = {Sap: sap, HostContext: FakeContext()}
    broker.update({LocalSpecs.sap_instance: LocalSpecs.sap_instance(broker)})
    broker.update({sap_sid: sap_sid(broker)})
    result = ld_library_path_of_user(broker)
    assert result is not None
    assert isinstance(result, DatasourceProvider)
    assert sorted(result.content) == [
        'rh1adm /usr/sap/RH1/SYS/exe/run:/usr/sap/RH1/SYS/exe/uc/linuxx86_64:/sapdb/clients/RH1/lib',
        'rh2adm /usr/sap/RH2/SYS/exe/run:/usr/sap/RH2/SYS/exe/uc/linuxx86_64:/sapdb/clients/RH2/lib',
    ]
    assert result.relative_path == 'insights_commands/echo_user_LD_LIBRARY_PATH'

    # Bad
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_GOOD))
    hn = Hostname(HostnameParser(context_wrap(HOSTNAME1)), None, None, None)
    sap = Sap(hn, inst, None)
    broker = {Sap: sap, HostContext: FakeContext()}
    broker.update({LocalSpecs.sap_instance: LocalSpecs.sap_instance(broker)})
    broker.update({sap_sid: sap_sid(broker)})
    with pytest.raises(SkipComponent):
        result = ld_library_path_of_user(broker)
        assert result is None
def test_saphostcrtl_hana_2():
    lssap = Lssap(context_wrap(Lssap_all_TEST))
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_GOOD))
    hn = Hostname(HnF(context_wrap(HOSTNAME1)), None, None, None, None)
    sap = Sap(hn, inst, lssap)
    assert 'D50' not in sap
    assert 'HDB00' in sap
    assert sorted(sap.local_instances) == sorted(
        ['HDB88', 'HDB90', 'SMDA91', 'HDB62', 'HDB00'])
    assert sorted(sap.all_instances) == sorted([
        'ASCS07', 'ASCS52', 'D54', 'DVEBMGS09', 'ERS08', 'HDB00', 'HDB62',
        'HDB88', 'HDB90', 'SCS10', 'SMDA91'
    ])
    assert sorted(sap.business_instances) == sorted([
        'ASCS07', 'ASCS52', 'D54', 'DVEBMGS09', 'ERS08', 'HDB00', 'HDB62',
        'HDB88', 'HDB90', 'SCS10'
    ])
    assert sorted(sap.function_instances) == sorted(['SMDA91'])
    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 True
    assert sap.is_hana is True
    assert sap.is_ascs is True
Exemple #3
0
def test_get_facter_hostname():
    ft = Facter(context_wrap(FACTS_FQDN))
    expected = ('ewa-satellite.example.com', 'ewa-satellite', 'example.com')
    result = Hostname(None, None, None, ft, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
Exemple #4
0
def test_get_systemid_hostname():
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = ('example_profile', 'example_profile', '')
    result = Hostname(None, None, None, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
def test_lssap_hana():
    lssap = Lssap(context_wrap(Lssap_hana_TEST))
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, 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
def test_hana_instance_skip():
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES_R_CASE))
    hn = Hostname(HostnameParser(context_wrap(HOSTNAME)), None, None, None)
    sap = Sap(hn, inst, None)
    broker = {Sap: sap}
    broker.update({LocalSpecs.sap_instance: LocalSpecs.sap_instance(broker)})
    with pytest.raises(SkipComponent):
        LocalSpecs.sap_hana_instance(broker)
def test_doc_examples():
    env = {
        'saps':
        Sap(Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None),
            None, Lssap(context_wrap(Lssap_doc_TEST)))
    }
    failed, total = doctest.testmod(sap, globs=env)
    assert failed == 0
Exemple #8
0
def test_lssap_ascs():
    lssap = Lssap(context_wrap(Lssap_ascs_TEST))
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, 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
def test_all():
    lssap = Lssap(context_wrap(Lssap_all_TEST))
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, 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
Exemple #10
0
def test_get_all_hostname():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = Hostname(hnf, hnd, hns, sid)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
def test_lssap_netweaver():
    lssap = Lssap(context_wrap(Lssap_nw_TEST))
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, 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
Exemple #12
0
def test_sid():
    # Good
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES))
    hn = Hostname(HostnameParser(context_wrap(HOSTNAME)), None, None, None)
    sap = Sap(hn, inst, None)
    broker = {Sap: sap}
    broker.update({LocalSpecs.sap_instance: LocalSpecs.sap_instance(broker)})
    result = sap_sid(broker)
    assert result is not None
    assert isinstance(result, list)
    assert result == sorted(set(v.sid.lower() for v in sap.values()))
Exemple #13
0
def test_hostname_doc():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    hns = HnS(context_wrap(HOSTNAME_SHORT))
    hnd = HnD(context_wrap(HOSTNAME_DEF))
    sid = SystemID(context_wrap(SYSTEMID_PROFILE_NAME))
    env = {
            'hostname': Hostname(hnf, hnd, hns, sid),
            'hn': hn_func(hnf, hnd, hns, sid)
          }
    failed, total = doctest.testmod(hostname, globs=env)
    assert failed == 0
def test_r_case():
    saphostctrl = SAPHostCtrlInstances(
        context_wrap(SAPHOSTCTRL_HOSTINSTANCES_R_CASE))
    hn = Hostname(HnF(context_wrap(HOSTNAME2)), None, None, None, None)
    sap = Sap(hn, saphostctrl, None)
    assert sorted(sap.local_instances) == sorted(['W20', 'SMDA98', 'SMDA97'])
    assert sap['DVEBMGS12'].version == '753, patch 501, changelist 1967207'
    assert sap['ASCS10'].hostname == 'r4d01'
    assert sap.is_netweaver is True
    assert sap.is_hana is False
    assert sap.is_ascs is True
Exemple #15
0
def test_get_hostname():
    hnf = HnF(context_wrap(HOSTNAME_FULL))
    expected = (HOSTNAME_FULL, HOSTNAME_SHORT, 'example.com')
    result = Hostname(hnf, None, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]

    hns = HnS(context_wrap(HOSTNAME_SHORT))
    expected = (HOSTNAME_SHORT, HOSTNAME_SHORT, '')
    result = Hostname(None, None, hns, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]

    hnd = HnD(context_wrap(HOSTNAME_DEF))
    expected = (HOSTNAME_DEF, HOSTNAME_DEF, '')
    result = Hostname(None, hnd, None, None)
    assert result.fqdn == expected[0]
    assert result.hostname == expected[1]
    assert result.domain == expected[2]
def test_saphostcrtl_hana():
    lssap = Lssap(context_wrap(Lssap_nw_TEST))
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES))
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, 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
Exemple #17
0
def test_hana_sid_SID_nr():
    # Good
    inst = SAPHostCtrlInstances(context_wrap(SAPHOSTCTRL_HOSTINSTANCES))
    hn = Hostname(HostnameParser(context_wrap(HOSTNAME)), None, None, None)
    sap = Sap(hn, inst, None)
    broker = {Sap: sap}
    broker.update({LocalSpecs.sap_instance: LocalSpecs.sap_instance(broker)})
    broker.update(
        {LocalSpecs.sap_hana_instance: LocalSpecs.sap_hana_instance(broker)})
    result = sap_hana_sid_SID_nr(broker)
    assert result is not None
    assert isinstance(result, list)
    assert result == list((v.sid.lower(), v.sid, v.number)
                          for v in sap.values() if v.type == 'HDB')

    # Bad
    broker.update({LocalSpecs.sap_hana_instance: []})
    with pytest.raises(SkipComponent):
        sap_hana_sid_SID_nr(broker)
def test_ab():
    hn = Hostname(HnF(context_wrap(HOSTNAME)), None, None, None, None)
    with pytest.raises(SkipComponent) as se:
        Sap(hn, None, None)
    assert 'No SAP instance.' in str(se)
Exemple #19
0
def test_hostname_raise():
    with pytest.raises(Exception):
        sid = SystemID(context_wrap(SYSTEMID_NO_PROFILE_NAME))
        Hostname(None, None, None, None, sid)