Exemplo n.º 1
0
    def test_trap_config_save_after_reboot(self, duthosts, localhost, enum_rand_one_per_hwsku_frontend_hostname, ptfhost,check_image_version, copp_testbed, dut_type, backup_restore_config_db, request):
        """
        Validates that the trap configuration is saved or not after reboot(reboot, fast-reboot, warm-reboot)

        1. Set always_enabled of a trap(e.g. bgp) to true
        2. Config save -y
        3. Do reboot according to the specified parameter of copp_reboot_type (reboot/warm-reboot/fast-reboot/soft-reboot)
        4. Verify configuration are saved successfully
        5. Verify the trap status is installed by sending traffic
        """

        duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]

        logger.info("Set always_enabled of {} to true".format(self.trap_id))
        copp_utils.configure_always_enabled_for_trap(duthost, self.trap_id, "true")

        logger.info("Config save")
        duthost.command("sudo config save -y")

        reboot_type = request.config.getoption("--copp_reboot_type")
        logger.info("Do {}".format(reboot_type))
        reboot(duthost, localhost, reboot_type=reboot_type, reboot_helper=None, reboot_kwargs=None)

        logger.info("Verify always_enable of {} == {} in config_db".format(self.trap_id, "true"))
        copp_utils.verify_always_enable_value(duthost, self.trap_id, "true")
        logger.info("Verify {} trap status is installed by sending traffic".format(self.trap_id))
        pytest_assert(
            wait_until(100, 20, 0, _copp_runner, duthost, ptfhost, self.trap_id.upper(), copp_testbed, dut_type),
            "Installing {} trap fail".format(self.trap_id))
Exemplo n.º 2
0
    def test_add_new_trap(self, duthosts, enum_rand_one_per_hwsku_frontend_hostname, ptfhost, check_image_version, copp_testbed, dut_type, backup_restore_config_db):
        """
        Validates that one new trap(bgp) can be installed

        1. The trap(bgp) should be uninstalled
        2. Set always_enabled of bgp to true
        3. Verify the trap status is installed by sending traffic
        """
        duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname]

        logger.info("Uninstall trap {}".format(self.trap_id))
        copp_utils.uninstall_trap(duthost, self.feature_name, self.trap_id)

        logger.info("Verify {} trap status is uninstalled by sending traffic".format(self.trap_id))
        _copp_runner(duthost,
                     ptfhost,
                     self.trap_id.upper(),
                     copp_testbed,
                     dut_type,
                     has_trap=False)

        logger.info("Set always_enabled of {} to true".format(self.trap_id))
        copp_utils.configure_always_enabled_for_trap(duthost, self.trap_id, "true")

        logger.info("Verify {} trap status is installed by sending traffic".format(self.trap_id))
        pytest_assert(
            wait_until(60, 20, 0, _copp_runner, duthost, ptfhost, self.trap_id.upper(), copp_testbed, dut_type),
            "Installing {} trap fail".format(self.trap_id))
Exemplo n.º 3
0
def pre_condition_install_trap(ptfhost, duthost, copp_testbed, trap_id, feature_name):
    copp_utils.install_trap(duthost, feature_name)
    logger.info("Set always_enabled of {} to false".format(trap_id))
    copp_utils.configure_always_enabled_for_trap(duthost, trap_id, "false")

    logger.info("Verify {} trap status is installed by sending traffic in pre_condition".format(trap_id))
    pytest_assert(
        wait_until(100, 20, 0, _copp_runner, duthost, ptfhost, trap_id.upper(), copp_testbed, dut_type),
        "Installing {} trap fail".format(trap_id))