OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-cog commits / 177b3d4

Revise counts for CogServerNode gorp
177b3d4809be217b04a338c2b78419278c03840b
by Linas Vepstas <linasvepstas@gmail.com> · 2025-12-13T05:48:01.000Z

Changed files (2) +58 -71

tests/persist/cog-simple/SimpleBasicDeleteUTest.cxxtest +33 -39
……@@ -91,6 +91,10 @@ void SimpleBasicDeleteUTest::tearDown(void)
9191{
9292}
9393
94// 9 more from CogServerNode and gorp; 2 for *-TruthValueKey-* and
95// *-IsKeyFlag-*
96int basic_offset = 9 + 2;
97
9498// ============================================================
9599
96100void SimpleBasicDeleteUTest::test_duplicates(void)
……@@ -106,7 +110,7 @@ void SimpleBasicDeleteUTest::test_duplicates(void)
106110 TS_ASSERT(store->connected())
107111
108112 // Clear out left-over junk, just in case.
109 store->erase();
113 ::kill_data(store.get(), _test_asp.get());
110114
111115 Handle ha(as->add_node(CONCEPT_NODE, "a"));
112116 Handle hb(as->add_node(CONCEPT_NODE, "b"));
……@@ -129,9 +133,9 @@ void SimpleBasicDeleteUTest::test_duplicates(void)
129133 TS_ASSERT_EQUALS(as->get_size(), 3);
130134 store->open();
131135 store->load_atomspace();
132 TS_ASSERT_EQUALS(as->get_size(), 5);
136 TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset);
133137
134 store->erase();
138 ::kill_data(store.get(), _test_asp.get());
135139 store->close();
136140
137141 logger().debug("END TEST: %s", __FUNCTION__);
……@@ -152,7 +156,7 @@ void SimpleBasicDeleteUTest::test_recursive(void)
152156 TS_ASSERT(store->connected())
153157
154158 // Clear out left-over junk, just in case.
155 store->erase();
159 ::kill_data(store.get(), _test_asp.get());
156160
157161 Handle ha(as->add_node(CONCEPT_NODE, "a"));
158162 Handle hb(as->add_node(CONCEPT_NODE, "b"));
……@@ -186,8 +190,7 @@ void SimpleBasicDeleteUTest::test_recursive(void)
186190 as->extract_atom(ha, true);
187191 store->open();
188192 store->load_atomspace();
189 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
190 TS_ASSERT_EQUALS(as->get_size(), 4);
193 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
191194
192195 // --------------------------------------
193196 // Do it again, but with a different order.
……@@ -200,16 +203,14 @@ void SimpleBasicDeleteUTest::test_recursive(void)
200203 store->close();
201204 store->open();
202205 store->load_atomspace();
203 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
204 TS_ASSERT_EQUALS(as->get_size(), 7);
206 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
205207
206208 store->remove_atom(as, ha, true);
207209 store->close();
208210 as->extract_atom(ha, true);
209211 store->open();
210212 store->load_atomspace();
211 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
212 TS_ASSERT_EQUALS(as->get_size(), 4);
213 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
213214
214215 // --------------------------------------
215216 // Do it again, but with a complex order.
……@@ -222,16 +223,14 @@ void SimpleBasicDeleteUTest::test_recursive(void)
222223 store->close();
223224 store->open();
224225 store->load_atomspace();
225 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
226 TS_ASSERT_EQUALS(as->get_size(), 7);
226 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
227227
228228 store->remove_atom(as, ha, true);
229229 store->close();
230230 as->extract_atom(ha, true);
231231 store->open();
232232 store->load_atomspace();
233 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
234 TS_ASSERT_EQUALS(as->get_size(), 4);
233 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
235234
236235 // --------------------------------------
237236 // Do it again, but more deeply.
……@@ -245,19 +244,17 @@ void SimpleBasicDeleteUTest::test_recursive(void)
245244 store->close();
246245 store->open();
247246 store->load_atomspace();
248 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
249 TS_ASSERT_EQUALS(as->get_size(), 8);
247 TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset);
250248
251249 store->remove_atom(as, ha, true);
252250 store->close();
253251 as->extract_atom(ha, true);
254252 store->open();
255253 store->load_atomspace();
256 // +2 for *-TruthValueKey-* and *-IsKeyFlag-*
257 TS_ASSERT_EQUALS(as->get_size(), 4);
254 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
258255
259256 // --------------------------------------
260 store->erase();
257 ::kill_data(store.get(), _test_asp.get());
261258 store->close();
262259
263260 logger().debug("END TEST: %s", __FUNCTION__);
……@@ -279,7 +276,7 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
279276 TS_ASSERT(store->connected())
280277
281278 // Clear out left-over junk, just in case.
282 store->erase();
279 ::kill_data(store.get(), _test_asp.get());
283280
284281 Handle ha(as->add_node(CONCEPT_NODE, "a"));
285282 Handle ka(as->add_node(PREDICATE_NODE, "key-a"));
……@@ -339,10 +336,10 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
339336 store->open();
340337 TS_ASSERT(store->connected())
341338
342 // We expect 6 atoms (+1 for *-IsKeyFlag-*)
339 // We expect 5 atoms
343340 printf("Loading the atomspace ...\n");
344341 store->load_atomspace();
345 TS_ASSERT_EQUALS(as->get_size(), 6);
342 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
346343
347344 // Verify that there are only two keys .. haha no, three.
348345 // That is because the deleted key gets restored when the
……@@ -361,7 +358,7 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
361358 printf("key=%s\n", k->get_name().c_str());
362359 TS_ASSERT_EQUALS(hs.size(), 3);
363360
364 store->erase();
361 ::kill_data(store.get(), _test_asp.get());
365362 store->close();
366363
367364 logger().debug("END TEST: %s", __FUNCTION__);
……@@ -369,6 +366,9 @@ void SimpleBasicDeleteUTest::test_key_deletion(void)
369366
370367// ============================================================
371368
369// A few more that cannot be deleted.
370int full_offset = basic_offset + 3;
371
372372// This tests for a nasty off-by-one bug that showed up
373373// in RocksDB. Make sure it never happens again.
374374void SimpleBasicDeleteUTest::test_key_corruption(void)
……@@ -385,7 +385,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
385385 TS_ASSERT(store->connected())
386386
387387 // Clear out left-over junk, just in case.
388 store->erase();
388 ::kill_data(store.get(), _test_asp.get());
389389
390390 Handle hb(as->add_node(CONCEPT_NODE, "b"));
391391 Handle hx(as->add_node(CONCEPT_NODE, "x"));
……@@ -397,13 +397,11 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
397397 store->store_atom(hb);
398398 store->barrier();
399399
400 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
401400 TS_ASSERT_EQUALS(as->get_size(), 5);
402401
403402 // Remove the value
404403 store->remove_atom(as, hx);
405404 as->extract_atom(hx);
406 // +1 for *-IsKeyFlag-*
407405 TS_ASSERT_EQUALS(as->get_size(), 4);
408406
409407 // FYI, we should call store->close() at this point, but we
……@@ -434,9 +432,8 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
434432 for (const Handle& h: hset)
435433 printf("Atomspace contains h=%s\n", h->to_short_string().c_str());
436434
437 // Size is 5 because (Concept "x") cannot be deleted.
438 // +1 for *-IsKeyFlag-*
439 TS_ASSERT_EQUALS(as->get_size(), 5);
435 // Size is 4 because (Concept "x") cannot be deleted.
436 TS_ASSERT_EQUALS(as->get_size(), 4 + full_offset);
440437
441438 hb = as->add_node(CONCEPT_NODE, "b");
442439 hx = as->add_node(CONCEPT_NODE, "x");
……@@ -449,20 +446,17 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
449446 store->store_atom(hb);
450447 store->barrier();
451448
452 // +1 for *-IsKeyFlag-*
453 TS_ASSERT_EQUALS(as->get_size(), 7);
449 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
454450
455451 // Remove the value .. again
456452 store->remove_atom(as, hx);
457453 as->extract_atom(hx);
458 // +1 for *-IsKeyFlag-*
459 TS_ASSERT_EQUALS(as->get_size(), 6);
454 TS_ASSERT_EQUALS(as->get_size(), 5 + full_offset);
460455 store->close();
461456 store->open();
462457 store->load_atomspace();
463 // Size is 7 because (Concept "x") cannot be deleted.
464 // +1 for *-IsKeyFlag-*
465 TS_ASSERT_EQUALS(as->get_size(), 7);
458 // Size is 6 because (Concept "x") cannot be deleted.
459 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
466460
467461 // We are done.
468462 store->close();
……@@ -479,10 +473,10 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
479473 store->open();
480474 TS_ASSERT(store->connected())
481475
482 // We expect 7 atoms (+1 for *-IsKeyFlag-*)
476 // We expect 6 atoms
483477 printf("Loading the atomspace ...\n");
484478 store->load_atomspace();
485 TS_ASSERT_EQUALS(as->get_size(), 7);
479 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
486480
487481 // Verify that there are two keys
488482 hb = as->add_node(CONCEPT_NODE, "b");
……@@ -495,7 +489,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void)
495489 }
496490 TS_ASSERT_EQUALS(hs.size(), 2);
497491
498 store->erase();
492 ::kill_data(store.get(), _test_asp.get());
499493 store->close();
500494
501495 logger().debug("END TEST: %s", __FUNCTION__);
tests/persist/cog-storage/BasicDeleteUTest.cxxtest +25 -32
……@@ -91,6 +91,10 @@ void BasicDeleteUTest::tearDown(void)
9191{
9292}
9393
94// 9 more from CogServerNode and gorp; 2 for *-TruthValueKey-* and
95// *-IsKeyFlag-*
96int basic_offset = 9 + 2;
97
9498// ============================================================
9599
96100void BasicDeleteUTest::test_duplicates(void)
……@@ -129,8 +133,7 @@ void BasicDeleteUTest::test_duplicates(void)
129133 TS_ASSERT_EQUALS(as->get_size(), 3);
130134 store->open();
131135 store->load_atomspace();
132 // +1 for *-IsKeyFlag-*
133 TS_ASSERT_EQUALS(as->get_size(), 5);
136 TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset);
134137
135138 ::kill_data(store.get(), _test_asp.get());
136139 store->close();
……@@ -187,8 +190,7 @@ void BasicDeleteUTest::test_recursive(void)
187190 as->extract_atom(ha, true);
188191 store->open();
189192 store->load_atomspace();
190 // +1 for *-IsKeyFlag-*
191 TS_ASSERT_EQUALS(as->get_size(), 4);
193 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
192194
193195 // --------------------------------------
194196 // Do it again, but with a different order.
……@@ -201,16 +203,14 @@ void BasicDeleteUTest::test_recursive(void)
201203 store->close();
202204 store->open();
203205 store->load_atomspace();
204 // +1 for *-IsKeyFlag-*
205 TS_ASSERT_EQUALS(as->get_size(), 7);
206 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
206207
207208 store->remove_atom(as, ha, true);
208209 store->close();
209210 as->extract_atom(ha, true);
210211 store->open();
211212 store->load_atomspace();
212 // +1 for *-IsKeyFlag-*
213 TS_ASSERT_EQUALS(as->get_size(), 4);
213 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
214214
215215 // --------------------------------------
216216 // Do it again, but with a complex order.
……@@ -223,16 +223,14 @@ void BasicDeleteUTest::test_recursive(void)
223223 store->close();
224224 store->open();
225225 store->load_atomspace();
226 // +1 for *-IsKeyFlag-*
227 TS_ASSERT_EQUALS(as->get_size(), 7);
226 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
228227
229228 store->remove_atom(as, ha, true);
230229 store->close();
231230 as->extract_atom(ha, true);
232231 store->open();
233232 store->load_atomspace();
234 // +1 for *-IsKeyFlag-*
235 TS_ASSERT_EQUALS(as->get_size(), 4);
233 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
236234
237235 // --------------------------------------
238236 // Do it again, but more deeply.
……@@ -246,16 +244,14 @@ void BasicDeleteUTest::test_recursive(void)
246244 store->close();
247245 store->open();
248246 store->load_atomspace();
249 // +1 for *-IsKeyFlag-*
250 TS_ASSERT_EQUALS(as->get_size(), 8);
247 TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset);
251248
252249 store->remove_atom(as, ha, true);
253250 store->close();
254251 as->extract_atom(ha, true);
255252 store->open();
256253 store->load_atomspace();
257 // +1 for *-IsKeyFlag-*
258 TS_ASSERT_EQUALS(as->get_size(), 4);
254 TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset);
259255
260256 // --------------------------------------
261257 ::kill_data(store.get(), _test_asp.get());
……@@ -341,10 +337,10 @@ void BasicDeleteUTest::test_key_deletion(void)
341337 store->open();
342338 TS_ASSERT(store->connected())
343339
344 // We expect 6 keys (includes *-TruthValueKey-* and *-IsKeyFlag-*)
340 // We expect 5 atoms
345341 printf("Loading the atomspace ...\n");
346342 store->load_atomspace();
347 TS_ASSERT_EQUALS(as->get_size(), 6);
343 TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset);
348344
349345 // Verify that there are only two keys .. haha no, three.
350346 // That is because the deleted key gets restored when the
……@@ -371,6 +367,9 @@ void BasicDeleteUTest::test_key_deletion(void)
371367
372368// ============================================================
373369
370// A few more that cannot be deleted.
371int full_offset = basic_offset + 3;
372
374373// This tests for a nasty off-by-one bug that showed up
375374// in RocksDB. Make sure it never happens again.
376375void BasicDeleteUTest::test_key_corruption(void)
……@@ -399,13 +398,11 @@ void BasicDeleteUTest::test_key_corruption(void)
399398 store->store_atom(hb);
400399 store->barrier();
401400
402 // Verify the atomspace size (+1 for *-IsKeyFlag-*)
403401 TS_ASSERT_EQUALS(as->get_size(), 5);
404402
405403 // Remove the value
406404 store->remove_atom(as, hx);
407405 as->extract_atom(hx);
408 // +1 for *-IsKeyFlag-*
409406 TS_ASSERT_EQUALS(as->get_size(), 4);
410407
411408 // FYI, we should call store->close() at this point, but we
……@@ -436,9 +433,8 @@ void BasicDeleteUTest::test_key_corruption(void)
436433 for (const Handle& h: hset)
437434 printf("Atomspace contains h=%s\n", h->to_short_string().c_str());
438435
439 // Size is 5 because (Concept "x") cannot be deleted.
440 // +1 for *-IsKeyFlag-*
441 TS_ASSERT_EQUALS(as->get_size(), 5);
436 // Size is 4 because (Concept "x") cannot be deleted.
437 TS_ASSERT_EQUALS(as->get_size(), 4 + full_offset);
442438
443439 hb = as->add_node(CONCEPT_NODE, "b");
444440 hx = as->add_node(CONCEPT_NODE, "x");
……@@ -451,20 +447,17 @@ void BasicDeleteUTest::test_key_corruption(void)
451447 store->store_atom(hb);
452448 store->barrier();
453449
454 // +1 for *-IsKeyFlag-*
455 TS_ASSERT_EQUALS(as->get_size(), 7);
450 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
456451
457452 // Remove the value .. again
458453 store->remove_atom(as, hx);
459454 as->extract_atom(hx);
460 // +1 for *-IsKeyFlag-*
461 TS_ASSERT_EQUALS(as->get_size(), 6);
455 TS_ASSERT_EQUALS(as->get_size(), 5 + full_offset);
462456 store->close();
463457 store->open();
464458 store->load_atomspace();
465 // Size is 7 because (Concept "x") cannot be deleted.
466 // +1 for *-IsKeyFlag-*
467 TS_ASSERT_EQUALS(as->get_size(), 7);
459 // Size is 6 because (Concept "x") cannot be deleted.
460 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
468461
469462 // We are done.
470463 store->close();
……@@ -481,10 +474,10 @@ void BasicDeleteUTest::test_key_corruption(void)
481474 store->open();
482475 TS_ASSERT(store->connected())
483476
484 // We expect 7 atoms (+1 for *-IsKeyFlag-*)
477 // We expect 6 atoms
485478 printf("Loading the atomspace ...\n");
486479 store->load_atomspace();
487 TS_ASSERT_EQUALS(as->get_size(), 7);
480 TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset);
488481
489482 // Verify that there are two keys
490483 hb = as->add_node(CONCEPT_NODE, "b");