Commit dbf2c07f authored by Ramon Nou's avatar Ramon Nou
Browse files

Test Random Slicing CutShift shrink with replicas

parent b8ddfb05
Loading
Loading
Loading
Loading
Loading
+60 −0
Changes for tests/integration/malleability/test_mutate_distributors_integrity.py: 60 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -315,3 +315,63 @@ def test_random_slicing_cutshift_expand_with_replication(
    finally:
        for daemon in daemons:
            daemon.shutdown()


def test_random_slicing_cutshift_shrink_with_replication(
    monkeypatch,
    gkfwd_daemon_factory,
    gkfs_client,
    gkfs_shell,
):
    """CutShift shrink evacuates replicated data before host removal."""
    monkeypatch.setenv("GKFS_DISTRIBUTION_STRATEGY", "random_slicing")
    monkeypatch.setenv("GKFS_RANDOM_SLICING_CUTSHIFT", "ON")
    monkeypatch.setenv("GKFS_DAEMON_NUM_REPL", "1")
    monkeypatch.setenv("LIBGKFS_NUM_REPL", "1")

    for env in (gkfs_client._env, gkfs_shell._env):
        env.update(
            {
                "GKFS_DISTRIBUTION_STRATEGY": "random_slicing",
                "GKFS_RANDOM_SLICING_CUTSHIFT": "ON",
                "LIBGKFS_NUM_REPL": "1",
            }
        )

    daemons = []
    try:
        old_daemons = [
            gkfwd_daemon_factory.create(),
            gkfwd_daemon_factory.create(),
            gkfwd_daemon_factory.create(),
        ]
        daemons.extend(old_daemons)
        time.sleep(3)

        md5_map = {}
        for index in range(3):
            path = old_daemons[0].mountdir / f"random_slicing_shrink_{index}.dat"
            md5_map[path] = _write_file(gkfs_client, path, FILE_SIZE)
        _verify_md5_map(gkfs_client, md5_map)

        removed = old_daemons[-1]
        active = old_daemons[:-1]
        hostfile = Path(old_daemons[0].hostfile)
        _write_workspace(hostfile, active, removing=[removed])
        _run_mutate_cmd(
            gkfs_shell,
            hostfile,
            "mutate start",
            timeout=340,
            logdir=old_daemons[0].logdir,
        )
        _wait_for_mutate_done(gkfs_shell, hostfile)
        _run_mutate_cmd(gkfs_shell, hostfile, "mutate finalize")

        removed._proc.wait(timeout=10)
        assert removed._proc.poll() is not None
        _verify_md5_map(gkfs_client, md5_map, old_daemons[0].logdir, hostfile)
        assert _chunk_files(*(daemon.rootdir for daemon in daemons))
    finally:
        for daemon in daemons:
            daemon.shutdown()
 No newline at end of file