Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Convert to MTEExtension #94

Merged
merged 13 commits into from
Nov 2, 2021
Merged

test: Convert to MTEExtension #94

merged 13 commits into from
Nov 2, 2021

Conversation

keturn
Copy link
Contributor

@keturn keturn commented Mar 20, 2021

Fixes errors about tests failing to resolve modules.

Also re-enabled some tests and got them working. I changed enough of the test file that GitHub PR interface doesn't recognize it as a file that moved, but it is making the same assertions.

This PR is also notable because it takes care of the last use of the deprecated ModuleTestingEnvironment superclass in Omega.

To Do

…sion

# Conflicts:
#	src/test/java/regions/RegionEntitiesTest.java
use parameterized test to help clarify in the test runner which things are passing
@keturn
Copy link
Contributor Author

keturn commented Sep 1, 2021

Results improve slightly, at the cost of a much much longer runtime, by using IsolatedMTEExtension.

Which I find puzzling in itself, because the code executed in the tests looks like it should all be read-only operations? So why would they benefit from increased isolation?

@keturn
Copy link
Contributor Author

keturn commented Sep 1, 2021

Also: The cellIsLoaded tests failing for anything that isn't (0, 0) could be explained by it only loading the one thing at the origin, and it returns false for everything else.

Except there is a failing test saying the cell at (98, -124) is loaded when it shouldn't be?

@keturn keturn self-assigned this Sep 2, 2021
@keturn keturn marked this pull request as draft September 2, 2021 04:30
@keturn keturn added the Category: Test/QA Requests, Issues and Changes targeting tests and quality assurance label Sep 2, 2021
@keturn
Copy link
Contributor Author

keturn commented Sep 2, 2021

This led to some MTE work for untangling interactions between test cases: Terasology/ModuleTestingEnvironment#64

also: a lot of the code under test here in RegionEntitesTest changed for JOML in #86. If these tests were disabled (or just ignored) at the time, something might have slipped through then.

skaldarnar
skaldarnar previously approved these changes Sep 6, 2021
@@ -75,18 +72,18 @@ public void postBegin() {
}
regionEntitiesComponent = new RegionEntitiesComponent(gridSize);
regionStoreEntity = entityManager.create(regionEntitiesComponent, new RegionMainStoreComponent());
regionStoreEntity.setAlwaysRelevant(true);
regionStoreEntity.setScope(EntityScope.GLOBAL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @DarkWeird mentioned something about removing sectors (and therefore scopes?). Just to make people aware ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was because setAlwaysRelevant is deprecated, and setScope is what it pointed me to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global scope exists yet.

@keturn
Copy link
Contributor Author

keturn commented Sep 6, 2021

1 similar comment
@keturn
Copy link
Contributor Author

keturn commented Sep 6, 2021

@keturn keturn marked this pull request as ready for review September 7, 2021 21:10
@keturn keturn requested a review from pollend September 7, 2021 21:10
@keturn keturn added the Status: Needs Testing Requires to be tested in-game label Sep 11, 2021
DarkWeird
DarkWeird previously approved these changes Sep 14, 2021
jdrueckert
jdrueckert previously approved these changes Sep 14, 2021
Copy link
Member

@jdrueckert jdrueckert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keturn I'm approving this assuming that you checked in MetalRenegades, that cities and buildings still show up with your change in the RegionEntitiesManager. Please only merge if you did ^^

@@ -273,10 +272,8 @@ public void setNameTagForRegion(EntityRef region) {
region.addComponent(nT);
}

@Command(shortDescription = "Toggles the view of nametags for region entities", runOnServer = true,
requiredPermission = PermissionManager.DEBUG_PERMISSION)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this permission not required after all? Or why was it removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code inspection told me that DEBUG_PERMISSION is the default and suggested omitting it.

@keturn
Copy link
Contributor Author

keturn commented Sep 15, 2021

I'm approving this assuming that you checked in MetalRenegades, that cities and buildings still show up […]

Cities? We know, after several months of playtesting, that Cities are a myth. Propaganda by the liberal elite to destabilize the traditional way of life by putting stories in the minds of our children, fantasies about the great named Cities and their buildings taller than trees. Hah!


Oh, you mean in single-player, I should still expect to see cities and buildings in single-player?

Well, I have this much:
1

Is that a city?

As for buildings, well,

12:02:12.454 [main] ERROR o.t.engine.core.TerasologyEngine - Uncaught exception, attempting clean game shutdown
java.lang.NullPointerException: null
at org.terasology.dynamicCities.settlements.SettlementEntityManager.growSettlement(SettlementEntityManager.java:531)
at org.terasology.dynamicCities.settlements.SettlementEntityManager.onWorldTimeEvent(SettlementEntityManager.java:168)

/*
Create roads between settlements
*/
SettlementsCacheComponent container = settlementCachingSystem.getSettlementCacheEntity().getComponent(SettlementsCacheComponent.class);
Vector2f source = new Vector2f(center.x, center.z);
Vector2f dest = new Vector2f(source);
float min = Float.MAX_VALUE;
for (EntityRef entity : container.settlementEntities.values()) {
if (!settlement.equals(entity)) {
Vector3fc location = entity.getComponent(LocationComponent.class).getLocalPosition();
Vector2fc location2D = new Vector2f(location.x(), location.z());
if (!roadCache.containsEntry(source.toString(), location2D.toString()) && source.distance(location2D) <= min) {
dest.set(location2D);
min = source.distance(location2D);

@keturn keturn dismissed jdrueckert’s stale review September 15, 2021 19:19

review was conditional on seeing buildings; have not seen buildings

@keturn
Copy link
Contributor Author

keturn commented Sep 15, 2021

Second attempt: didn't get that crash, but didn't get buildings.

Tried on develop for comparison: also has Problems. See thread.

@pollend
Copy link
Member

pollend commented Sep 16, 2021

Second attempt: didn't get that crash, but didn't get buildings.

Tried on develop for comparison: also has Problems. See thread.

the code is way to fragile ;/ might have something to do with all the terrain features.

@Cervator
Copy link
Member

Can confirm an apparent and distinct lack of buildings - darn termites!

Noticed some logging I don't recall seeing before about broken parcels?

15:35:54.794 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:36:00.089 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1094), capping to 1000
15:36:46.281 [main] ERROR o.t.e.e.e.internal.PojoEntityManager - Adding a component (class org.terasology.engine.network.NetworkComponent) over an existing component for entity 23300
15:36:46.299 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4cce9387 couldn't be completed. Status: NONE
15:36:46.309 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7be79549 couldn't be completed. Status: NONE
15:36:53.422 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:36:53.423 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:36:54.878 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:37:01.166 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1004), capping to 1000
15:37:05.165 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:37:05.167 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:37:07.380 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:37:21.675 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:37:21.677 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:37:22.151 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@649b9ed couldn't be completed. Status: NONE
15:37:22.151 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4cce9387 couldn't be completed. Status: NONE
15:37:22.162 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7ebbda4f couldn't be completed. Status: NONE
15:37:22.162 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7be79549 couldn't be completed. Status: NONE
15:37:24.184 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:37:27.554 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:37:27.555 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:37:30.346 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:37:32.961 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:37:32.962 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:37:33.787 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:37:37.137 [main] WARN  o.terasology.biomesAPI.BiomeManager - Missing biome information for ( 3.510E+2  2.100E+1  1.183E+3)
15:37:44.864 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1903), capping to 1000
15:37:49.489 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1069), capping to 1000
15:37:59.223 [main] ERROR o.t.e.e.e.internal.PojoEntityManager - Adding a component (class org.terasology.engine.network.NetworkComponent) over an existing component for entity 42586
15:37:59.231 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@649b9ed couldn't be completed. Status: NONE
15:37:59.232 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4cce9387 couldn't be completed. Status: NONE
15:37:59.232 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@1bc6d1ba couldn't be completed. Status: NONE
15:37:59.246 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@2bcf9031 couldn't be completed. Status: NONE
15:37:59.257 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7ebbda4f couldn't be completed. Status: NONE
15:37:59.257 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@6666978e couldn't be completed. Status: NONE
15:37:59.257 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7be79549 couldn't be completed. Status: NONE
15:38:00.033 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:38:00.034 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:38:04.709 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:38:15.173 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1523), capping to 1000
15:38:21.449 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:38:21.451 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:38:21.761 [main] INFO  o.t.engine.logic.console.ConsoleImpl - [CONSOLE] Player86648 (local) entered Kinhestcasou
15:38:24.690 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished
15:38:26.112 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1152), capping to 1000
15:38:32.781 [main] INFO  o.t.engine.logic.console.ConsoleImpl - [CONSOLE] Player86648 (local) left Kinhestcasou
15:38:33.899 [main] INFO  o.t.engine.logic.console.ConsoleImpl - [CONSOLE] Player86648 (local) entered Kinhestcasou
15:38:35.816 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@649b9ed couldn't be completed. Status: NONE
15:38:35.817 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4cce9387 couldn't be completed. Status: NONE
15:38:35.817 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@643f2816 couldn't be completed. Status: NONE
15:38:35.817 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@1bc6d1ba couldn't be completed. Status: NONE
15:38:35.838 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4b313414 couldn't be completed. Status: NONE
15:38:35.838 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@2bcf9031 couldn't be completed. Status: NONE
15:38:35.850 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@484f898e couldn't be completed. Status: NONE
15:38:35.850 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7ebbda4f couldn't be completed. Status: NONE
15:38:35.850 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@6666978e couldn't be completed. Status: NONE
15:38:35.850 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7be79549 couldn't be completed. Status: NONE
15:38:42.151 [main] WARN  o.t.engine.core.internal.TimeBase - Delta too great (1010), capping to 1000
15:38:52.640 [o.t.e.r.n.l.m.a.AdvancedGameSetupScreen-0] INFO  o.t.e.c.module.ModuleListDownloader - Retrieved 185 entries
15:38:57.322 [main] INFO  o.t.engine.logic.console.ConsoleImpl - [CONSOLE] Ghost mode toggled
15:39:11.796 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@649b9ed couldn't be completed. Status: NONE
15:39:11.797 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@2031e024 couldn't be completed. Status: NONE
15:39:11.797 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4cce9387 couldn't be completed. Status: NONE
15:39:11.797 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@643f2816 couldn't be completed. Status: NONE
15:39:11.797 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@1bc6d1ba couldn't be completed. Status: NONE
15:39:11.806 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@22d7be07 couldn't be completed. Status: NONE
15:39:11.806 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@4b313414 couldn't be completed. Status: NONE
15:39:11.806 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@2bcf9031 couldn't be completed. Status: NONE
15:39:11.813 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@484f898e couldn't be completed. Status: NONE
15:39:11.813 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7ebbda4f couldn't be completed. Status: NONE
15:39:11.813 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@704f88f8 couldn't be completed. Status: NONE
15:39:11.813 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@6666978e couldn't be completed. Status: NONE
15:39:11.813 [main] WARN  o.t.d.s.SettlementEntityManager - Parcel org.terasology.dynamicCities.parcels.RoadParcel@7be79549 couldn't be completed. Status: NONE
15:39:21.460 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Creating game snapshot
15:39:21.461 [main] INFO  o.t.e.p.i.ReadWriteStorageManager - Auto Saving - Snapshot created: Writing phase starts
15:39:23.477 [Saving-0] INFO  o.t.e.p.internal.SaveTransaction - Save game finished

Checked two city spots, then also 0, 0, 0 as some past bugs have sent buildings back there, but nope, nothing. So maybe something is keep parcels from forming correctly? Otherwise the new MR worlds are gorgeous :-)

@jdrueckert jdrueckert dismissed DarkWeird’s stale review September 25, 2021 19:49

needs more investigation and fixing wrt cities spawning

@keturn
Copy link
Contributor Author

keturn commented Oct 7, 2021

Example to compare to: Earlier used seed ​iTKAXPCM7KkMFnBj and found a city at (-530, 12, -70) that looked like this:

At least half a dozen buildings of several kinds, widely spaced.

# Conflicts:
#	module.txt
#	src/main/java/org/terasology/dynamicCities/region/RegionEntityManager.java
@keturn
Copy link
Contributor Author

keturn commented Oct 8, 2021

Okay, now that #107 is merged (thank you Niruandaleth for the review) we have a properly failing test in this branch!

and I've confirmed that if I re-add the -1s in RegionEntityManager, it makes some warnings that come up during the placeParcel test go away. Worryingly, it doesn't make it pass.

I still want to track down where the setter for that is and figure out an interface that lets us avoid re-doing the math in different places.

@keturn
Copy link
Contributor Author

keturn commented Oct 8, 2021

The location that getNearest is trying to match is set by RegionEntityProvider:

LocationComponent locationComponent = new LocationComponent(worldRegion.center(new Vector3f()));
entityStore.addComponent(locationComponent);

(It makes entities with an UnregisteredRegionComponent, and the RegionEntityManager system has an OnActivatedComponent handler that receives those and invokes add() with them.)

My notes so far:

  • getNearest should always succeed for any coordinates (x, z) for which the world has generated a chunk at the surface for that location.
    • That is, it should only fail if, say, there is a very very tall cliff, and when we stand at the top of the cliff, the surface below is so low that it hasn't even been close enough to us to generate yet.
    • Every location on the surface should map to some region entity.
  • The location is set as the center of the Region given to the EntityProvider.
  • getNearest tries to calculate a location to align with that, assuming that regions are always aligned along chunk boundaries. That could be true, but the assumption violates some abstraction and it's fragile if the world generator ever changes some decisions about regions.
  • I still haven't figured out what did change. Seems like the RegionEntityProvider code has always used center() for that Location. Did the pre-JOML center method round differently? Or is it something else about regions that changed, like their boundary size?

@keturn
Copy link
Contributor Author

keturn commented Oct 8, 2021

Next steps?

  • Does the engine offer any better way to store data aggregated by chunk?
    • (or, perhaps in this case, the column of chunks at (x, z)?)
  • If not and we do continue with the current implementation, is there a better way to normalize these coordinates?
    • Is "Region" a concept we expect to extend to non-World-Generation game systems at all?
    • Is there any guarantee that a Region contains only one Chunk that is unique to it?

@keturn
Copy link
Contributor Author

keturn commented Oct 30, 2021

We had a discussion about Dynamic Cities in today's meeting, and it went sprawling as these things do, but I think the the parts that are relevant for next steps here are:

  • We don't want to drop Metal Renegades. So Dynamic Cities is sticking around. This did spark some discussion about whether Static Cities would replace Dynamic Cities in the Metal Renegades lineup, whether that would actually be more maintainable, whether it would need additional features to get there, etc, but that's all To Be Determined.

  • We don't want our confusion around Dynamic Cities to block the original goal of this PR: completing the removal of the deprecated ModuleTestingEnvironment superclass. So we should @Disable or kludge things as necessary here to get this code to a place where the tests that are enabled aren't misleading, and manual testing shows no regressions (i.e. cities have buildings in single-player mode).

adjust tests to compensate for the mysterious -1
@keturn
Copy link
Contributor Author

keturn commented Nov 2, 2021

I've set aside my quest to track down the origin of the -1 and reverted my change to getNearest so that the placeParcel test passes again.

I started a new MR world with the known seed and did find a city with two buildings there.

I'd offer a screenshot, but the screenshot pushed the RAM usage over the edge and it crashed.

@jdrueckert
Copy link
Member

Have a screenshot 🤲
Terasology-211102195103-2560x1395

@jdrueckert jdrueckert merged commit 98f5c41 into develop Nov 2, 2021
@jdrueckert jdrueckert deleted the test/jupiter-extension branch November 2, 2021 19:09
@keturn keturn restored the test/jupiter-extension branch November 5, 2021 00:18
@keturn keturn deleted the test/jupiter-extension branch November 5, 2021 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Test/QA Requests, Issues and Changes targeting tests and quality assurance Status: Needs Testing Requires to be tested in-game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants