From 5ff22f49c8c05c7c2332b8cf8ace29bd4795af59 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sat, 18 Mar 2023 14:05:52 +0100 Subject: [PATCH] make timings testing more robust ci servers are sometimes busy, and then it is failing --- .../interaction/breaking/BreakHandlerInputTest.kt | 14 ++++++++++---- .../breaking/executor/SequencedExecutorTest.kt | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/BreakHandlerInputTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/BreakHandlerInputTest.kt index ed9710626..db252702b 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/BreakHandlerInputTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/BreakHandlerInputTest.kt @@ -20,7 +20,9 @@ import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.asser import de.bixilon.minosoft.protocol.network.connection.play.PacketTestUtil.assertPacket import de.bixilon.minosoft.protocol.packets.c2s.play.PlayerActionC2SP import de.bixilon.minosoft.protocol.packets.c2s.play.move.SwingArmC2SP +import org.testng.SkipException import org.testng.annotations.Test +import kotlin.system.measureTimeMillis @Test(groups = ["input"]) class BreakHandlerInputTest { @@ -43,13 +45,15 @@ class BreakHandlerInputTest { val handler = BreakHandler(connection.camera.interactions) BreakHandlerTest.createTarget(connection, RockBlock.Stone.identifier, 1.0) + Thread.currentThread().priority = Thread.MAX_PRIORITY + handler.press() // key down connection.assertPacket(PlayerActionC2SP::class.java) connection.assertPacket(SwingArmC2SP::class.java) handler.release() // key not down anymore connection.assertPacket(PlayerActionC2SP::class.java) - Thread.sleep(55) + if (measureTimeMillis { Thread.sleep(55) } > 60) throw SkipException("system busy") connection.assertNoPacket() } @@ -60,17 +64,19 @@ class BreakHandlerInputTest { BreakHandlerTest.createTarget(connection, RockBlock.Stone.identifier, 1.0) + Thread.currentThread().priority = Thread.MAX_PRIORITY + handler.press() // key down connection.assertPacket(PlayerActionC2SP::class.java) connection.assertPacket(SwingArmC2SP::class.java) connection.assertNoPacket() - Thread.sleep(20) + if (measureTimeMillis { Thread.sleep(20) } > 30) throw SkipException("system busy") connection.assertNoPacket() - Thread.sleep(35) + if (measureTimeMillis { Thread.sleep(35) } > 45) throw SkipException("system busy") connection.assertPacket(SwingArmC2SP::class.java) connection.assertNoPacket() - Thread.sleep(50) + if (measureTimeMillis { Thread.sleep(50) } > 55) throw SkipException("system busy") connection.assertPacket(SwingArmC2SP::class.java) connection.assertNoPacket() handler.release() diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/executor/SequencedExecutorTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/executor/SequencedExecutorTest.kt index dd064f3b3..614b223d1 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/executor/SequencedExecutorTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/input/interaction/breaking/executor/SequencedExecutorTest.kt @@ -48,6 +48,7 @@ class SequencedExecutorTest { // connection.world[Vec3i(1, 1, 1)] = state // <- set the same block -> revert/cancel executor.finish() + Thread.sleep(10) // async, wait for thread to complete assertEquals(connection.world[Vec3i(1, 1, 1)], state) }