more testing stuff
This commit is contained in:
@@ -801,7 +801,9 @@ public class NodeManager {
|
|||||||
|
|
||||||
//Assume that this is always a top node
|
//Assume that this is always a top node
|
||||||
// FIXME: DONT DO THIS
|
// FIXME: DONT DO THIS
|
||||||
this.topLevelNodeIds.add(id);
|
if (!this.topLevelNodeIds.add(id)) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
this.clearAllocId(id);
|
this.clearAllocId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1042,6 +1044,12 @@ public class NodeManager {
|
|||||||
throw new IllegalStateException("Unknown node type: " + nodeType);
|
throw new IllegalStateException("Unknown node type: " + nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (WorldEngine.getLevel(pos) == 0) {
|
||||||
|
Logger.error("Requests cannot exist for bottom level nodes. at: " + WorldEngine.pprintPos(pos) + ". Ignoring request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: ADJUST AND FIX THIS TO MAKE IT REMOVE THE LAST THING IN QUEUE OR SOMETHING
|
//TODO: ADJUST AND FIX THIS TO MAKE IT REMOVE THE LAST THING IN QUEUE OR SOMETHING
|
||||||
//if (this.activeNodeRequestCount > 100 && WorldEngine.getLevel(pos) < 2) {
|
//if (this.activeNodeRequestCount > 100 && WorldEngine.getLevel(pos) < 2) {
|
||||||
//Logger.info("Many active requests, declining request at " + WorldEngine.pprintPos(pos));
|
//Logger.info("Many active requests, declining request at " + WorldEngine.pprintPos(pos));
|
||||||
@@ -1070,6 +1078,7 @@ public class NodeManager {
|
|||||||
// in this case we should not mark the node as inflight as it casuse very bad things to happen
|
// in this case we should not mark the node as inflight as it casuse very bad things to happen
|
||||||
// we should only mark inflight when there is actually a request
|
// we should only mark inflight when there is actually a request
|
||||||
if (nodeType == NODE_TYPE_LEAF) {
|
if (nodeType == NODE_TYPE_LEAF) {
|
||||||
|
|
||||||
if (this.nodeData.getNodeGeometry(nodeId) == NULL_GEOMETRY_ID) {
|
if (this.nodeData.getNodeGeometry(nodeId) == NULL_GEOMETRY_ID) {
|
||||||
//Weird case that not sure how possible
|
//Weird case that not sure how possible
|
||||||
Logger.warn("Got request for leaf that doesnt have geometry, this should not be possible at pos " + WorldEngine.pprintPos(pos));
|
Logger.warn("Got request for leaf that doesnt have geometry, this should not be possible at pos " + WorldEngine.pprintPos(pos));
|
||||||
@@ -1632,5 +1641,26 @@ public class NodeManager {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IntSet tln = new IntOpenHashSet(this.topLevelNodeIds.size());
|
||||||
|
for (long p : this.topLevelNodes) {
|
||||||
|
int n = this.activeSectionMap.get(p);
|
||||||
|
if (n == -1) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
if ((n&NODE_TYPE_MSK)!=NODE_TYPE_REQUEST) {
|
||||||
|
if (!tln.add(n&NODE_ID_MSK)) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.topLevelNodeIds.containsAll(tln)) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tln.containsAll(this.topLevelNodeIds)) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,21 +312,43 @@ public class TestNodeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval) {
|
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval) {
|
||||||
long POS_A = WorldEngine.getWorldSectionId(4, 0, 0, 0);
|
|
||||||
|
|
||||||
Random r = new Random(testIdx * 1234L);
|
Random r = new Random(testIdx * 1234L);
|
||||||
try {
|
try {
|
||||||
var test = new TestBase();
|
var test = new TestBase();
|
||||||
LongList tops = new LongArrayList();
|
LongList tops = new LongArrayList();
|
||||||
|
|
||||||
|
int R = 1;
|
||||||
|
if (r.nextBoolean()) {
|
||||||
|
R++;
|
||||||
|
if (r.nextBoolean()) {
|
||||||
|
R++;
|
||||||
|
if (r.nextBoolean()) {
|
||||||
|
R++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Fuzzy bruteforce everything
|
//Fuzzy bruteforce everything
|
||||||
test.putTopPos(POS_A);
|
for (int x = -R; x<=R; x++) {
|
||||||
tops.add(POS_A);
|
for (int z = -R; z<=R; z++) {
|
||||||
|
tops.add(WorldEngine.getWorldSectionId(4, x, 0, z));
|
||||||
|
tops.add(WorldEngine.getWorldSectionId(4, x, 1, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (long p : tops) {
|
||||||
|
test.putTopPos(p);
|
||||||
|
test.meshUpdate(p, -1, 18);
|
||||||
|
fillInALl(test, p, a->-1);
|
||||||
|
test.printNodeChanges();
|
||||||
|
test.verifyIntegrity();
|
||||||
|
}
|
||||||
for (int i = 0; i < ITERS; i++) {
|
for (int i = 0; i < ITERS; i++) {
|
||||||
long pos = rPos(r, tops);
|
long pos = rPos(r, tops);
|
||||||
int op = r.nextInt(5);
|
int op = r.nextInt(5);
|
||||||
int extra = r.nextInt(256);
|
int extra = r.nextInt(256);
|
||||||
boolean hasGeometry = r.nextBoolean();
|
boolean hasGeometry = r.nextBoolean();
|
||||||
boolean addRemTLN = r.nextInt(512) == 0;
|
boolean addRemTLN = r.nextInt(64) == 0;
|
||||||
boolean extraBool = r.nextBoolean();
|
boolean extraBool = r.nextBoolean();
|
||||||
if (op == 0 && addRemTLN) {
|
if (op == 0 && addRemTLN) {
|
||||||
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(5)-2, r.nextInt(5)-2);
|
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(5)-2, r.nextInt(5)-2);
|
||||||
|
|||||||
Reference in New Issue
Block a user