Merge pull request #1529 from ludovic111/fix/ds-parity-flake

🤖 Agent: merged after verify and CI parity passed, built merged with current main. The dedicated_server flake was the harness client never resending its position, so a villager whose chunk went out after its only move was never shown to it (0/21 → 21/21 with the server's tick thread stalled after the join). Failing harnesses now print the reason in CI.
This commit is contained in:
Ludovic Marie
2026-10-24 02:52:06 +02:00
committed by GitHub
3 changed files with 54 additions and 7 deletions
@@ -65,6 +65,7 @@ import net.minecraft.network.protocol.game.ServerboundAcceptTeleportationPacket;
import net.minecraft.network.protocol.game.ServerboundChatCommandPacket;
import net.minecraft.network.protocol.game.ServerboundChatPacket;
import net.minecraft.network.protocol.game.ServerboundChunkBatchReceivedPacket;
import net.minecraft.network.protocol.game.ServerboundClientTickEndPacket;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.network.protocol.game.ServerboundPlayerLoadedPacket;
import net.minecraft.network.protocol.handshake.ClientIntent;
@@ -484,6 +485,8 @@ public final class VanillaProtocolClient {
// When the dead player sent a command (ServerGamePacketListenerImpl.handleChatCommand runs it
// whether the player is alive or not); it respawns once the reply came, or 3 s later.
long deadCommandAt = 0;
// When the client last sent where it is.
long positionAt = 0;
while (System.currentTimeMillis() < deadline) {
Received r;
try {
@@ -536,6 +539,7 @@ public final class VanillaProtocolClient {
// acceptance alone, as the 26.3 client sends.
if (!respawning && step < ENTITIES) {
send(new ServerboundMovePlayerPacket.PosRot(position.position(), position.yRot(), position.xRot(), false, false));
positionAt = now;
}
if (!loaded) {
send(new ServerboundPlayerLoadedPacket());
@@ -635,6 +639,17 @@ public final class VanillaProtocolClient {
commandTree(p);
}
}
if (entities == null && loaded && deadCommandAt == 0 && now - positionAt >= 1000) {
// LocalPlayer.sendPosition: once its level is loaded the 26.3 client sends where it is
// every 20 ticks even standing still, and the server then checks again which entities the
// player sees (ChunkMap.move). An entity whose chunk was sent after the player's last move,
// such as the villager when the first chunks come late, is paired at the next one. The tick
// end first (Minecraft.tick sends one every tick): a server takes one position per client tick.
// Until the death: from then on the steps wait only on entities spawned for the player.
send(ServerboundClientTickEndPacket.INSTANCE);
send(new ServerboundMovePlayerPacket.Pos(position.position(), false, false));
positionAt = now;
}
if (entities != null && loaded && lastChunk > 0 && now - lastChunk > 3000 && step == 0) {
// Entity mode: the harness's console summons the scene once it reads this
// line; everything tracked from then on is recorded until the client leaves.
+12 -2
View File
@@ -65,6 +65,7 @@ SHARED = Path(os.environ.get("PARITY_SHARED") or (LOCAL / "minecraft").resolve()
MACHINE_JOBS = int(os.environ.get("PARITY_MACHINE_JOBS") or max(1, (os.cpu_count() or 4) // 2))
HOST = socket.gethostname().split(".")[0]
DEFAULT_MEMORY = 3 << 30 # assumed peak for a harness that never ran here
FAILURE_TAILS, FAILURE_TAIL_LINES = 10, 30 # the summary prints the end of the first failures' logs
def harness_settings(path):
@@ -1361,8 +1362,17 @@ def main():
failed = sorted(name for name, record in results.items() if record["status"] != "pass")
finished_run(failed)
print(f"\n{len(results) - len(failed)} passed, {len(failed)} failed in {elapsed / 60:.1f} min.")
for name in failed:
print(f" {name}: {STATE_DIR / 'logs' / (name + '.log')}")
for index, name in enumerate(failed):
log = STATE_DIR / 'logs' / (name + '.log')
print(f" {name}: {log}")
# The end of a harness's output says why it failed, and CI shows only this output.
if index < FAILURE_TAILS:
try:
lines = log.read_text(encoding='utf-8', errors='replace').splitlines()[-FAILURE_TAIL_LINES:]
except OSError:
lines = []
for line in lines:
print(f" {line[:300]}")
return 1 if failed else 0
+27 -5
View File
@@ -7,7 +7,9 @@ respawn_radius 0) and stops; a vanilla dedicated server and Horizon's
server.properties, server-icon.png and lists. VanillaProtocolClient, a
headless client made of vanilla's own codecs (any byte vanilla would not
read is an error), pings each server, joins it in offline mode through
login, configuration and play, accepts the spawn teleport, receives the
login, configuration and play, accepts the spawn teleport (then, standing
still until its death, sends its position every 20 ticks as LocalPlayer
does: the server checks then which entities it sees), receives the
chunks around the spawn (their bytes are compared: the world is loaded from
the same files), chats, runs /list and commands that fail (`/random value
7..7`, `/random value x`, `/trigger nope`), trades, is made an operator by
@@ -244,6 +246,20 @@ def console_lines(lines):
return out
# What a failure's diff doesn't say: warnings, errors, panics and why a player left.
NOTABLE = re.compile(r'/(WARN|ERROR)\]|Exception|panicked|lost connection')
def notable_lines(path, limit=20):
"""A server's notable lines from its `Done (` on (the startup warnings are every run's), or a client's."""
try:
lines = path.read_text(encoding='utf-8', errors='replace').splitlines()
except OSError:
return []
start = next((i for i, l in enumerate(lines) if 'Done (' in l), 0)
return [f'{path.name}: {l[:300]}' for l in lines[start:] if NOTABLE.search(l)][-limit:]
def server_files(directory):
out = []
for name in ['server.properties', 'eula.txt', 'ops.json', 'whitelist.json', 'banned-players.json', 'banned-ips.json',
@@ -420,9 +436,13 @@ def main():
(world / 'playerdata').mkdir(exist_ok=True)
def client(port, out):
oh.run_logged(['java', '-Xmx1g', '-Duser.timezone=UTC', '-cp', str(classes) + os.pathsep + dependencies,
'dev.horizonlab.parity.VanillaProtocolClient', '127.0.0.1', port, PLAYER, out], build,
out.stem, timeout=300)
try:
oh.run_logged(['java', '-Xmx1g', '-Duser.timezone=UTC', '-cp', str(classes) + os.pathsep + dependencies,
'dev.horizonlab.parity.VanillaProtocolClient', '127.0.0.1', port, PLAYER, out], build,
out.stem, timeout=300)
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as error:
log = (build / f'{out.stem}.log').read_text(encoding='utf-8', errors='replace').splitlines()
raise AssertionError(f'{out.stem}: {error}:\n' + '\n'.join(log[-30:])) from None
results = {}
for label, command in [('vanilla', vanilla_server), ('horizon', horizon_server)]:
@@ -448,8 +468,10 @@ def main():
if a != b:
differences.append(f'chunk {key}: vanilla {a} horizon {b}')
if differences or errors:
notes = [line for name in ('vanilla', 'vanilla-client', 'horizon', 'horizon-client')
for line in notable_lines(build / f'{name}.log')]
raise AssertionError(f'{len([d for d in differences if d[:1] in "+-" and d[:3] not in ("+++", "---")])} differing lines '
f'(see {build}/vanilla.txt and horizon.txt):\n' + '\n'.join(differences[:80]))
f'(see {build}/vanilla.txt and horizon.txt):\n' + '\n'.join(differences[:80] + notes))
lab.write_json(report, dict(
schema=1, minecraft=lock['minecraft']['version'], platform=platform.platform(),
java=subprocess.check_output(['java', '--version'], text=True).splitlines()[0],