コード例 #1
0
def test_system_ntp_modify():
    """
    Test that ntp servers were initially configured and can be reconfigured

    Test Steps:
        - Execute system ntp-show
        - Verify that ntpservers field contains a list of 3 ntp servers
        - Update ntp with new ntp servers
        - Lock/unlock controllers to get rid of config out of date alarm
        - After lock and unlock verify that alarms cleared
    """

    LOG.tc_step("Check 'system ntp-show' contains expected fields")
    table_ = table_parser.table(cli.system('ntp-show')[1])
    expt_sub_fields = ['uuid', 'ntpservers', 'isystem_uuid', 'created_at', 'updated_at']

    actual_fields = table_parser.get_column(table_, 'Property')
    LOG.tc_step("Actual ntp fields Names are {}".format(actual_fields))
    assert set(expt_sub_fields) <= set(actual_fields), "Some expected fields are not included in system show table."

    LOG.tc_step("Modify 'system ntp-modify' and verify that it contains expected fields")
    ntp_pool = NtpPool.NTP_POOL_1
    if sorted(system_helper.get_ntp_values(fields='ntpservers')[0].split(',')) == sorted(ntp_pool.split(',')):
        ntp_pool = NtpPool.NTP_POOL_2

    system_helper.modify_ntp(ntp_servers=ntp_pool)
コード例 #2
0
def test_ptp_parameter_modify(mode, transport, mechanism, default_config):
    """
         This test is to verify  PTP parameters.
         Note: There are some hardware dependency to support all the parameters.
    Args:
        mode:
        transport:
        mechanism:
        default_config:


         Test steps: 1. Check PTP enabled
                     2. Change parameter and clear alarm

    """

    LOG.tc_step("PTP Enabled check")
    ptp_enabled = system_helper.get_ptp_values(fields='enabled')
    if ptp_enabled[0] != 'True':
        system_helper.modify_ntp(enabled=False, clear_alarm=False)
        system_helper.modify_ptp(enabled=True, clear_alarm=False)
    LOG.tc_step("PTP Modify parameters")
    ret_value, output = system_helper.modify_ptp(mode=mode,
                                                 transport=transport,
                                                 mechanism=mechanism)
    LOG.info(format(output))
コード例 #3
0
def test_ptp_and_ntp_disable():
    """
        This test is to verify disabling both NTP and PTP


        Test steps: 1. Disable NTP enabled
                    2.  Disable PTP and clear alarm.

    """
    system_helper.modify_ntp(enabled=False, clear_alarm=False)
    system_helper.modify_ptp(enabled=False, clear_alarm=True)
コード例 #4
0
    def revert():
        reverted = False
        try:
            LOG.fixture_step("Manage primary subcloud {} if unmanaged".format(primary_subcloud))
            dc_helper.manage_subcloud(primary_subcloud)

            LOG.fixture_step("Revert NTP config if changed")
            res = system_helper.modify_ntp(ntp_servers=central_ntp, auth_info=central_auth, check_first=True,
                                           clear_alarm=False)[0]
            if res != -1:
                LOG.fixture_step("Lock unlock config out-of-date hosts in central region")
                system_helper.wait_and_clear_config_out_of_date_alarms(auth_info=central_auth,
                                                                       wait_with_best_effort=True)

                LOG.fixture_step("Lock unlock config out-of-date hosts in {}".format(primary_subcloud))
                dc_helper.wait_for_subcloud_ntp_config(subcloud=primary_subcloud, expected_ntp=central_ntp,
                                                       clear_alarm=True)

                if managed_subcloud:
                    LOG.fixture_step("Lock unlock config out-of-date hosts in {}".format(managed_subcloud))
                    dc_helper.wait_for_subcloud_ntp_config(subcloud=managed_subcloud, expected_ntp=central_ntp,
                                                           clear_alarm=True)

            if subclouds_to_revert:
                LOG.fixture_step("Manage unmanaged subclouds and check they are unaffected")
                for subcloud in subclouds_to_revert:
                    dc_helper.manage_subcloud(subcloud)
                    assert not system_helper.get_alarms(alarm_id=EventLogID.CONFIG_OUT_OF_DATE,
                                                        auth_info=Tenant.get('admin_platform', dc_region=subcloud))
            reverted = True

        finally:
            if not reverted:
                for subcloud in subclouds_to_revert:
                    dc_helper.manage_subcloud(subcloud)
コード例 #5
0
def test_system_ptp_enable_negative():
    """
       This test is to veirfy the Negative senario by trying to enable both PTP and NTP together
       Test steps:  1. Change PTP enabled
                    2. Verify string for PTP failure
                    3. PTP is neabled success change NTP enabled
                    4. Verify sting for NTP enabled
    """

    ret_value, output = system_helper.modify_ptp(enabled=True,
                                                 clear_alarm=True,
                                                 wait_with_best_effort=True,
                                                 fail_ok=True)

    if ret_value != 0:
        find_string = output.find(
            'PTP cannot be configured alongside with NTP')
        assert find_string == 0, 'Test Failed: Error message \"PTP cannot be configured alongside with NTP\"' \
                                 ' not found'
    if ret_value == 0:
        ret_value, output = system_helper.modify_ntp(
            enabled=True,
            clear_alarm=True,
            wait_with_best_effort=True,
            fail_ok=True)
        if ret_value > 0:
            find_string = output.find(
                'NTP cannot be configured alongside with PTP')
            assert find_string == 0, 'Test Failed: Error message \"NTP cannot be configured alongside ' \
                                     'with PTP\" not found'
コード例 #6
0
 def restore_default_confg():
     LOG.info('Restoring Ptp values= {} {} {} {}'.format(
         ptp_default[0], ptp_default[1], ptp_default[2], ptp_default[3]))
     if ptp_default[0] == 'False':
         system_helper.modify_ptp(enabled=False,
                                  mode=ptp_default[1],
                                  transport=ptp_default[2],
                                  mechanism=ptp_default[3],
                                  clear_alarm=True)
         system_helper.modify_ntp(enabled=True, clear_alarm=True)
     else:
         system_helper.modify_ntp(enabled=False, clear_alarm=True)
         system_helper.modify_ptp(enabled=False,
                                  mode=ptp_default[1],
                                  transport=ptp_default[2],
                                  mechanism=ptp_default[3],
                                  clear_alarm=True)
コード例 #7
0
def test_system_ntp_modify_reject_server_name_too_long():
    """
    Test that attempting to configure more than 3 ntp servers is rejected

    Test Steps:
        - Attempt to configure ntp server with longer than 255 characters
        - Verify that the operation is rejected and that
        - system ntp-modify exits with return code 1
    """

    LOG.tc_step("Test system ntp-modify is rejected if server name is > than 255 characters")
    code, output = system_helper.modify_ntp(ntp_servers=NtpPool.NTP_NAME_TOO_LONG, fail_ok=True,
                                            wait_with_best_effort=True)

    assert 1 == code, 'Expect ntp-modify is not rejected with server name longer than 255 characters'
コード例 #8
0
def test_system_ntp_modify_reject_too_many_servers():
    """
    Test that attempting to configure more than 3 ntp servers is rejected

    Test Steps:
        - Attempt to configure more than 3 ntp servers
        - Verify that the operation is rejected and that
        - system ntp-modify exits with return code 1
    """

    LOG.tc_step("Test system ntp-modify is rejected if more than 3 NTP servers defined in the list")
    code, output = system_helper.modify_ntp(ntp_servers=NtpPool.NTP_POOL_TOO_LONG, fail_ok=True,
                                            wait_with_best_effort=True)

    assert 1 == code, 'Expect ntp-modify is not rejected with more than 3 NPT servers defined'
コード例 #9
0
def test_dc_ntp_modify(ntp_precheck):
    """
    Update NTP servers on central region and check it is propagated to subclouds
    Args:
        ntp_precheck (fixture for test setup and teardown)

    Setups:
        - Ensure primary subcloud is manged and NTP config is in sync with central region
        - Un-manage rest of the subclouds except one

    Test Steps:
        - Un-manage primary subcloud
        - Configure NTP servers on above unmanaged subcloud to remove the first NTP server
        - Configure NTP servers on central region to add an invalid server 8.8.8.8
        - Lock/unlock controllers on central region to apply the config
        - Wait for new NTP config to sync over to the only managed osubcloud and config out-of-date alarms appear
        - Lock/unlock controllers on managed subcloud to apply config
        - Ensure central NTP config does not sync to unmanaged primary subcloud
        - Re-manage primary subcloud and ensure NTP config syncs over
        - Lock/unlock controllers in primary subcloud to apply new NTP configuration
        - Verify fm alarm 100.114 appears for invalid/unreachable NTP server on central region and managed

    Teardown:
        - Reset NTP servers to original value
        - Lock/unlock controllers on all managed subclouds to clear the config out of date alarm
        - Re-manage subclouds that were umanaged in setup
        - Verify no config out-of-date alarms on the re-managed subclouds

    """
    primary_subcloud, managed_subcloud, prev_central_ntp = ntp_precheck
    new_central_ntp = ['8.8.8.8'] + prev_central_ntp[:-1]
    local_subcloud_ntp = prev_central_ntp[1:]

    central_auth = Tenant.get('admin_platform', dc_region='RegionOne')
    primary_sub_auth = Tenant.get('admin_platform', dc_region=primary_subcloud)
    auth_list = [central_auth, primary_sub_auth]
    if managed_subcloud:
        managed_sub_auth = Tenant.get('admin_platform', dc_region=managed_subcloud)
        auth_list.append(managed_sub_auth)

    LOG.tc_step("Unmanage {}".format(primary_subcloud))
    dc_helper.unmanage_subcloud(subcloud=primary_subcloud, check_first=True)

    LOG.tc_step("While {} is unmanaged, modify its NTP servers locally from {} to {}".
                format(primary_subcloud, prev_central_ntp, local_subcloud_ntp))
    system_helper.modify_ntp(ntp_servers=local_subcloud_ntp, auth_info=primary_sub_auth)

    LOG.tc_step("Reconfigure NTP servers on central region from {} to {}".format(prev_central_ntp, new_central_ntp))
    system_helper.modify_ntp(ntp_servers=new_central_ntp, auth_info=central_auth)

    if managed_subcloud:
        LOG.tc_step("Wait for new NTP config to sync over to managed subcloud: {}".format(managed_subcloud))
        dc_helper.wait_for_subcloud_ntp_config(subcloud=managed_subcloud, expected_ntp=new_central_ntp)

    LOG.tc_step("Ensure NTP config is not updated on unmanaged subcloud: {}".format(primary_subcloud))
    code = dc_helper.wait_for_subcloud_ntp_config(subcloud=primary_subcloud, expected_ntp=new_central_ntp,
                                                  timeout=60, fail_ok=True, clear_alarm=False)[0]
    assert 1 == code, "Actual return code: {}".format(code)
    assert local_subcloud_ntp == system_helper.get_ntp_servers(auth_info=primary_sub_auth)

    LOG.tc_step('Re-manage {} and ensure NTP config syncs over'.format(primary_subcloud))
    dc_helper.manage_subcloud(subcloud=primary_subcloud, check_first=False)
    dc_helper.wait_for_subcloud_ntp_config(subcloud=primary_subcloud, expected_ntp=new_central_ntp)

    LOG.tc_step('Verify NTP alarm appeared for invalid server 8.8.8.8 on central and managed subclouds')
    for auth_info in auth_list:
        system_helper.wait_for_alarm(alarm_id=EventLogID.NTP_ALARM, auth_info=auth_info, timeout=660)