Commit 7ffd0ca8 authored by Ramon Nou's avatar Ramon Nou
Browse files

Test Random Slicing CutShift with two replicas

parent ce61e047
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
@@ -316,6 +316,66 @@ def test_random_slicing_cutshift_expand_with_replication(
            daemon.shutdown()


def test_random_slicing_cutshift_expand_with_two_replicas(
    monkeypatch,
    gkfwd_daemon_factory,
    gkfs_client,
    gkfs_shell,
):
    """CutShift expansion preserves data with two replica copies."""
    monkeypatch.setenv("GKFS_DISTRIBUTION_STRATEGY", "random_slicing")
    monkeypatch.setenv("GKFS_RANDOM_SLICING_CUTSHIFT", "ON")
    monkeypatch.setenv("GKFS_NUM_REPL", "2")

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

    daemons = []
    try:
        old_daemons = [
            gkfwd_daemon_factory.create(),
            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_repl2_{index}.dat"
            md5_map[path] = _write_file(gkfs_client, path, FILE_SIZE)
        _verify_md5_map(gkfs_client, md5_map)

        added = gkfwd_daemon_factory.create(expand_mode=True)
        daemons.append(added)
        time.sleep(2)

        hostfile = Path(old_daemons[0].hostfile)
        _write_workspace(hostfile, old_daemons, adding=[added])
        _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")

        _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()


def test_random_slicing_cutshift_shrink_with_replication(
    monkeypatch,
    gkfwd_daemon_factory,