integration test: reduce test time, minor performance optimizations

This commit is contained in:
Bixilon 2023-03-18 22:57:32 +01:00
parent 2d197237f8
commit d7beac6eae
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
11 changed files with 61 additions and 26 deletions

View File

@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.packets.factory.PacketTypeRegistry
import de.bixilon.minosoft.protocol.versions.Versions
import de.bixilon.minosoft.test.IT
import de.bixilon.minosoft.test.ITUtil
import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
@ -32,6 +33,7 @@ internal object MinosoftSIT {
@BeforeSuite
fun setup() {
Log.ASYNC_LOGGING = false
KUtil.initUtilClasses()
disableGC()
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Setting up integration tests...." }
initAssetsManager()

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -13,6 +13,7 @@
package de.bixilon.minosoft.config.profile
import de.bixilon.minosoft.assets.minecraft.index.IndexAssetsType
import de.bixilon.minosoft.config.profile.profiles.audio.AudioProfile
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfile
import de.bixilon.minosoft.config.profile.profiles.connection.ConnectionProfile
@ -27,13 +28,20 @@ import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfile
object ProfileTestUtil {
private fun createResources(): ResourcesProfile {
val profile = ResourcesProfile()
profile.assets.indexAssetsTypes -= IndexAssetsType.SOUNDS // we can't play them anyways
profile.verify = false // this just slows down the process, the pipeline will fail no matter what if anything is corrupted
return profile
}
fun createProfiles(): ConnectionProfiles {
return ConnectionProfiles(
eros = ErosProfile(),
particle = ParticleProfile(),
audio = AudioProfile(),
entity = EntityProfile(),
resources = ResourcesProfile(),
resources = createResources(),
rendering = RenderingProfile(),
block = BlockProfile(),
connection = ConnectionProfile(),

View File

@ -25,7 +25,7 @@ import java.util.*
object TestAccount : Account("Bixilon") {
override val id: String = "id"
override val type: ResourceLocation = minosoft("test_account")
override val properties: PlayerProperties? = null
override val properties: PlayerProperties = PlayerProperties()
override val uuid: UUID = "9e6ce7c5-40d3-483e-8e5a-b6350987d65f".toUUID()
override var state: AccountStates
get() = AccountStates.WORKING

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -30,14 +30,13 @@ class StairsTest : BlockTest<Block>() {
super.retrieveBlock(MinecraftBlocks.OAK_STAIRS)
}
@Test(enabled = false)
@Test(enabled = false) // ToDo: This test is correct, but failing
fun testLightPropertiesNorth() {
// ToDo: This test is correct, but failing
block.withProperties(BlockProperties.FACING to Directions.NORTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, false, true, true, true))
}
@Test(enabled = false) // ToDo: This test is correct, but failing
fun testLightPropertiesSouth() {
// ToDo: This test is correct, but failing
block.withProperties(BlockProperties.FACING to Directions.SOUTH).testLightProperties(0, true, true, false, booleanArrayOf(false, true, true, false, true, true))
}

View File

@ -143,20 +143,21 @@ object VerifyIntegratedBlockRegistry {
if (value["class"] == "AirBlock") {
continue
}
val parsed = PixLyzerBlock.deserialize(registries, id.toResourceLocation(), value).unsafeCast<PixLyzerBlock>()
registries.block.updateStates(parsed, value, registries)
parsed.postInit(registries)
parsed.inject(registries)
val integrated = registries.block[parsed.identifier] ?: Broken("Block $id does not exist in the registry?")
val identifier = id.toResourceLocation()
val integrated = registries.block[identifier] ?: Broken("Block $id does not exist in the registry?")
if (integrated is PixLyzerBlock) {
// useless to compare
continue
}
if (integrated is FluidBlock || integrated is BubbleColumnBlock) {
// they work different in minosoft
continue
}
val parsed = PixLyzerBlock.deserialize(registries, identifier, value).unsafeCast<PixLyzerBlock>()
registries.block.updateStates(parsed, value, registries)
parsed.postInit(registries)
parsed.inject(registries)
compare(parsed, integrated, error)
}

View File

@ -34,7 +34,7 @@ class OfflineAccount(username: String) : Account(username) {
override val supportsSkins: Boolean get() = false
@JsonIgnore
override val properties: PlayerProperties? = null
override val properties: PlayerProperties = PlayerProperties()
override fun join(serverId: String) = Unit

View File

@ -18,6 +18,7 @@ import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSide
import de.bixilon.minosoft.data.registries.shapes.side.VoxelSideSet
import de.bixilon.minosoft.data.registries.shapes.voxel.AbstractVoxelShape
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
class DirectedProperty(
private val directions: BooleanArray,
@ -72,7 +73,7 @@ class DirectedProperty(
// ToDo: This whole calculation is technically wrong, it could be that 2 different sides of 2 blocks are "free". That means that light can still not pass the blocks, but
// this algorithm does not cover it. Let's see it as performance hack
val sides: MutableSet<VoxelSide> = mutableSetOf()
val sides: MutableSet<VoxelSide> = ObjectOpenHashSet()
for (aabb in this) {
when (side.axis) {

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -13,12 +13,16 @@
package de.bixilon.minosoft.data.registries.shapes.side
import com.google.common.base.Objects
import de.bixilon.kotlinglm.vec2.Vec2
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
data class VoxelSide(
val min: Vec2,
val max: Vec2,
) {
private val hashCode = Objects.hashCode(min.hashCode(), max.hashCode())
constructor(minX: Float, minZ: Float, maxX: Float, maxZ: Float) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
constructor(minX: Double, minZ: Double, maxX: Double, maxZ: Double) : this(Vec2(minOf(minX, maxX), minOf(minZ, maxZ)), Vec2(maxOf(minX, maxX), maxOf(minZ, maxZ)))
@ -37,7 +41,7 @@ data class VoxelSide(
}
infix operator fun minus(set: VoxelSideSet): VoxelSideSet {
val result: MutableSet<VoxelSide> = mutableSetOf()
val result: MutableSet<VoxelSide> = ObjectOpenHashSet()
for (side in set.sides) {
result += (this minus side).sides
@ -47,7 +51,7 @@ data class VoxelSide(
}
infix operator fun minus(other: VoxelSide): VoxelSideSet {
val result: MutableSet<VoxelSide> = mutableSetOf()
val result: MutableSet<VoxelSide> = ObjectOpenHashSet()
if (other.min.x > min.x && other.min.x < max.x) {
@ -97,4 +101,8 @@ data class VoxelSide(
return VoxelSideSet(setOf(VoxelSide(minX, minY, maxX, maxY)))
}
override fun hashCode(): Int {
return hashCode
}
}

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
* Copyright (C) 2020-2023 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
@ -13,6 +13,8 @@
package de.bixilon.minosoft.data.registries.shapes.side
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
class VoxelSideSet(
val sides: Set<VoxelSide>,
) : Iterable<VoxelSide> {
@ -28,7 +30,7 @@ class VoxelSideSet(
return this
}
val next: MutableSet<VoxelSide> = mutableSetOf()
val next: MutableSet<VoxelSide> = ObjectOpenHashSet()
val array = this.sides.toTypedArray()
for (i in 1 until sides.size) {

View File

@ -366,6 +366,8 @@ class ChunkLight(private val chunk: Chunk) {
val maxHeightSection = maxHeight.sectionHeight
val skylightStart = getNeighbourMaxHeight(neighbours, x, z, heightmapIndex)
if (maxHeight == Int.MIN_VALUE && skylightStart == Int.MIN_VALUE) return
val skylightStartSectionHeight = skylightStart.sectionHeight
if (skylightStart.inSectionHeight == 1) {
// Create section below max section
@ -416,10 +418,7 @@ class ChunkLight(private val chunk: Chunk) {
if (this == null) {
return false
}
if (!this.skyLight || !this.effects.skylight) {
return false
}
return true
return !(!this.skyLight || !this.effects.skylight)
}
}
}

View File

@ -91,7 +91,22 @@ internal class DirectedPropertyTest {
assertFalse(shape.isSideCovered(Directions.UP))
assertTrue(shape.isSideCovered(Directions.NORTH))
assertFalse(shape.isSideCovered(Directions.SOUTH))
assertTrue(shape.isSideCovered(Directions.WEST))
assertTrue(shape.isSideCovered(Directions.EAST))
assertFalse(shape.isSideCovered(Directions.WEST))
assertFalse(shape.isSideCovered(Directions.EAST))
}
@Test
fun testSideCovered7() {
val shape = VoxelShape(
AABB(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f),
AABB(0.0f, 0.5f, 0.5f, 1.0f, 1.0f, 1.0f),
)
assertTrue(shape.isSideCovered(Directions.DOWN))
assertFalse(shape.isSideCovered(Directions.UP))
assertFalse(shape.isSideCovered(Directions.NORTH))
assertTrue(shape.isSideCovered(Directions.SOUTH))
assertFalse(shape.isSideCovered(Directions.WEST))
assertFalse(shape.isSideCovered(Directions.EAST))
}
}