Exemplo n.º 1
0
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
Exemplo n.º 2
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()))
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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)
Exemplo n.º 7
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.º 8
0
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
Exemplo n.º 9
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)
Exemplo n.º 10
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
Exemplo n.º 11
0
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
Exemplo n.º 12
0
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
Exemplo n.º 13
0
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)
Exemplo n.º 14
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)