def METHOD_NAME(
    event_listener,
    salt_mm_failover_master_1,
    salt_mm_failover_master_2,
    salt_mm_failover_minion_1,
    salt_mm_failover_minion_2,
    mm_failover_master_1_salt_cli,
    mm_failover_master_2_salt_cli,
    run_salt_cmds,
):
    """
    Test then when the first master is stopped, connected minions failover to the second master.
    """
    event_patterns = [
        (
            salt_mm_failover_master_2.id,
            "salt/minion/{}/start".format(salt_mm_failover_minion_1.id),
        )
    ]
    start_time = time.time()
    with salt_mm_failover_master_1.stopped():
        assert salt_mm_failover_master_2.is_running()
        # We need to wait for them to realize that the master is not alive
        # At this point, only the first minion will need to change masters
        events = event_listener.wait_for_events(
            event_patterns,
            timeout=salt_mm_failover_minion_1.config["master_alive_interval"] * 4,
            after_time=start_time,
        )
        assert salt_mm_failover_minion_1.is_running()
        assert not events.missed
        returns = run_salt_cmds(
            [mm_failover_master_1_salt_cli, mm_failover_master_2_salt_cli],
            [salt_mm_failover_minion_1, salt_mm_failover_minion_2],
        )
        assert len(returns) == 2
        assert (mm_failover_master_2_salt_cli, salt_mm_failover_minion_1) in returns
        assert (mm_failover_master_2_salt_cli, salt_mm_failover_minion_2) in returns