Example #1
0
def test_kedr_basic_io_raw(module, unload_modules, install_kedr):
    """
    title: Basic IO test with kedr started with memory leaks profile
    description: |
        Load CAS modules, start kedr against one of them, start cache and add core,
        run simple 4 minute random IO, stop cache and unload modules
    pass_criteria:
      - No memory leaks observed
    """
    with TestRun.step("Preparing cache device"):
        cache_device = TestRun.disks['cache']
        cache_device.create_partitions([Size(500, Unit.MebiByte)])
        cache_part = cache_device.partitions[0]

    with TestRun.step("Preparing core device"):
        core_device = TestRun.disks['core']
        core_device.create_partitions([Size(1, Unit.GibiByte)])
        core_part = core_device.partitions[0]

    with TestRun.step("Unload CAS modules if needed"):
        if os_utils.is_kernel_module_loaded(module.value):
            cas_module.unload_all_cas_modules()

    with TestRun.step(f"Starting kedr against {module.value}"):
        Kedr.start(module.value)

    with TestRun.step(f"Loading CAS modules"):
        os_utils.load_kernel_module(cas_module.CasModule.cache.value)

    with TestRun.step("Starting cache"):
        cache = casadm.start_cache(cache_part, force=True)

    with TestRun.step("Adding core"):
        core = cache.add_core(core_dev=core_part)

    with TestRun.step(f"Running IO"):
        (Fio().create_command()
              .io_engine(IoEngine.libaio)
              .run_time(timedelta(minutes=4))
              .time_based()
              .read_write(ReadWrite.randrw)
              .target(f"{core.path}")
              .direct()
         ).run()

    with TestRun.step("Stopping cache"):
        cache.stop()

    with TestRun.step(f"Unloading CAS modules"):
        cas_module.unload_all_cas_modules()

    with TestRun.step(f"Checking for memory leaks for {module.value}"):
        try:
            Kedr.check_for_mem_leaks(module.value)
        except Exception as e:
            TestRun.LOGGER.error(f"{e}")

    with TestRun.step(f"Stopping kedr"):
        Kedr.stop()
def unload_modules():
    TestRun.LOGGER.info("Check if CAS is installed")
    if installer.check_if_installed():
        TestRun.LOGGER.info("Unloading modules")
        cas_module.unload_all_cas_modules()

    TestRun.LOGGER.info("Stop kedr if it is running")
    if Kedr.is_loaded():
        Kedr.stop()

    TestRun.LOGGER.info("Mounting debugfs")
    os_utils.mount_debugfs()
def test_kedr_start_cache(module, unload_modules, install_kedr):
    """
    title: Start cache and add core with kedr started against one of CAS modules
    description: |
        Load CAS modules, start kedr against one of them, start cache and add core,
        stop cache and unload modules
    pass_criteria:
      - No memory leaks observed
    """
    with TestRun.step("Preparing cache device"):
        cache_device = TestRun.disks['cache']
        cache_device.create_partitions([Size(500, Unit.MebiByte)])
        cache_part = cache_device.partitions[0]

    with TestRun.step("Preparing core device"):
        core_device = TestRun.disks['core']
        core_device.create_partitions([Size(1, Unit.GibiByte)])
        core_part = core_device.partitions[0]

    with TestRun.step("Unload CAS modules if needed"):
        if os_utils.is_kernel_module_loaded(module.value):
            cas_module.unload_all_cas_modules()

    with TestRun.step(f"Starting kedr against {module.value}"):
        Kedr.start(module.value)

    with TestRun.step(f"Loading CAS modules"):
        os_utils.load_kernel_module(cas_module.CasModule.cache.value)

    with TestRun.step("Starting cache"):
        cache = casadm.start_cache(cache_part, force=True)

    with TestRun.step("Adding core"):
        cache.add_core(core_dev=core_part)

    with TestRun.step("Stopping cache"):
        cache.stop()

    with TestRun.step(f"Unloading CAS modules"):
        cas_module.unload_all_cas_modules()

    with TestRun.step(f"Checking for memory leaks for {module}"):
        try:
            Kedr.check_for_mem_leaks(module.value)
        except Exception as e:
            TestRun.LOGGER.error(f"{e}")

    with TestRun.step(f"Stopping kedr"):
        Kedr.stop()
def test_init_status():
    """
        title: CAS management device status
        description: |
          Verify that CAS management device is present in OS only when CAS modules are loaded.
        pass_criteria:
          - CAS management device present in OS when CAS modules are loaded.
          - CAS management device not present in OS when CAS modules are not loaded.
    """
    with TestRun.step("Check if CAS management device is present in OS."):
        time.sleep(5)
        if cas_module.is_cas_management_dev_present():
            TestRun.LOGGER.info(
                "CAS management device is present in OS when CAS module is loaded."
            )
        else:
            TestRun.fail(
                "CAS management device is not present in OS when CAS module is loaded."
            )

    with TestRun.step("Remove CAS module."):
        cas_module.unload_all_cas_modules()

    with TestRun.step("Stop CAS service."):
        casctl.stop()

    with TestRun.step("Check if CAS management device is not present in OS."):
        time.sleep(5)
        if not cas_module.is_cas_management_dev_present():
            TestRun.LOGGER.info(
                "CAS management device is not present in OS when CAS module is not loaded."
            )
        else:
            TestRun.fail(
                "CAS management device is present in OS when CAS module is not loaded."
            )

    with TestRun.step("Load CAS modules and start CAS service."):
        os_utils.load_kernel_module(CasModule.cache.value)
        os_utils.load_kernel_module(CasModule.disk.value)
        casctl.start()