| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Node.h> |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 36 | 37 | |
| 37 | 38 | #include <opencog/util/Logger.h> |
| … | … | @@ -129,7 +130,7 @@ void AlphaEquivUTest::setup_data(void) |
| 129 | 130 | |
| 130 | 131 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 131 | 132 | StorageNodePtr store = StorageNodeCast(hsn); |
| 132 | store->open(); | |
| 133 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 133 | 134 | TS_ASSERT(store->connected()) |
| 134 | 135 | |
| 135 | 136 | /* Populate the Storage with stuff that we will later query. */ |
| … | … | @@ -157,7 +158,7 @@ void AlphaEquivUTest::test_fetch(void) |
| 157 | 158 | _as = createAtomSpace(); |
| 158 | 159 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 159 | 160 | StorageNodePtr store = StorageNodeCast(hsn); |
| 160 | store->open(); | |
| 161 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 161 | 162 | TS_ASSERT(store->connected()) |
| 162 | 163 | |
| 163 | 164 | // Fetch an alpha-equivalent lambda link. |
| … | … | @@ -203,7 +204,7 @@ void AlphaEquivUTest::test_remove(void) |
| 203 | 204 | _as = createAtomSpace(); |
| 204 | 205 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 205 | 206 | StorageNodePtr store = StorageNodeCast(hsn); |
| 206 | store->open(); | |
| 207 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 207 | 208 | TS_ASSERT(store->connected()) |
| 208 | 209 | |
| 209 | 210 | // Remove the alpha-equivalent lambda link. |
| … | … | @@ -241,7 +242,7 @@ void AlphaEquivUTest::test_recursive_remove(void) |
| 241 | 242 | _as = createAtomSpace(); |
| 242 | 243 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 243 | 244 | StorageNodePtr store = StorageNodeCast(hsn); |
| 244 | store->open(); | |
| 245 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 245 | 246 | TS_ASSERT(store->connected()) |
| 246 | 247 | |
| 247 | 248 | // Recursive remove Concept "A". |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/persist/cog-types/atom_types.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/atomspace/AtomSpace.h> |
| 37 | 38 | |
| 38 | 39 | #include <opencog/persist/api/StorageNode.h> |
| … | … | @@ -92,8 +93,8 @@ void SimpleBasicDeleteUTest::tearDown(void) |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | // 9 more from CogServerNode and gorp; 2 for *-TruthValueKey-* and |
| 95 | // *-IsKeyFlag-* | |
| 96 | int basic_offset = 9 + 2; | |
| 96 | // *-IsKeyFlag-*; 1 more for *-open-* | |
| 97 | int basic_offset = 9 + 3; | |
| 97 | 98 | |
| 98 | 99 | // ============================================================ |
| 99 | 100 | |
| … | … | @@ -106,7 +107,7 @@ void SimpleBasicDeleteUTest::test_duplicates(void) |
| 106 | 107 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 107 | 108 | StorageNodePtr store = StorageNodeCast(hsn); |
| 108 | 109 | |
| 109 | store->open(); | |
| 110 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 110 | 111 | TS_ASSERT(store->connected()) |
| 111 | 112 | |
| 112 | 113 | // Clear out left-over junk, just in case. |
| … | … | @@ -120,23 +121,24 @@ void SimpleBasicDeleteUTest::test_duplicates(void) |
| 120 | 121 | store->store_atom(li); |
| 121 | 122 | store->barrier(); |
| 122 | 123 | |
| 123 | // Verify the atomspace size | |
| 124 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 124 | // Verify the atomspace size (+1 for *-open-* predicate) | |
| 125 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 125 | 126 | |
| 126 | 127 | // Remove the link. Since the link has duplicate atoms |
| 127 | 128 | // in it, this can cause trouble, depending on how the |
| 128 | 129 | // incoming set is managed. |
| 129 | 130 | store->remove_atom(as, li); |
| 130 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 131 | store->close(); | |
| 131 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 132 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 132 | 133 | as->extract_atom(li); |
| 133 | TS_ASSERT_EQUALS(as->get_size(), 3); | |
| 134 | store->open(); | |
| 134 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 135 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 135 | 136 | store->load_atomspace(); |
| 136 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 137 | // +1 for *-close-* predicate from above | |
| 138 | TS_ASSERT_EQUALS(as->get_size(), 4 + basic_offset); | |
| 137 | 139 | |
| 138 | 140 | ::kill_data(store.get(), _test_asp.get()); |
| 139 | store->close(); | |
| 141 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 140 | 142 | |
| 141 | 143 | logger().debug("END TEST: %s", __FUNCTION__); |
| 142 | 144 | } |
| … | … | @@ -152,7 +154,7 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 152 | 154 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 153 | 155 | StorageNodePtr store = StorageNodeCast(hsn); |
| 154 | 156 | |
| 155 | store->open(); | |
| 157 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 156 | 158 | TS_ASSERT(store->connected()) |
| 157 | 159 | |
| 158 | 160 | // Clear out left-over junk, just in case. |
| … | … | @@ -173,8 +175,8 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 173 | 175 | for (const Handle& h : hset) |
| 174 | 176 | printf("Atomspace contains: %s\n", h->to_short_string().c_str()); |
| 175 | 177 | |
| 176 | // Verify the atomspace size | |
| 177 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 178 | // Verify the atomspace size (+1 for *-open-* predicate) | |
| 179 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 178 | 180 | |
| 179 | 181 | // Remove (Concept "a"). Since this appears twice, recursion |
| 180 | 182 | // will hit it twice, in stange ways, and maybe crash. |
| … | … | @@ -186,11 +188,12 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 186 | 188 | for (const Handle& h : hset) |
| 187 | 189 | printf("Post delete: %s\n", h->to_short_string().c_str()); |
| 188 | 190 | |
| 189 | store->close(); | |
| 191 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 190 | 192 | as->extract_atom(ha, true); |
| 191 | store->open(); | |
| 193 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 192 | 194 | store->load_atomspace(); |
| 193 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 195 | // +1 for *-close-* predicate from above | |
| 196 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 194 | 197 | |
| 195 | 198 | // -------------------------------------- |
| 196 | 199 | // Do it again, but with a different order. |
| … | … | @@ -200,17 +203,19 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 200 | 203 | |
| 201 | 204 | store->store_atom(lj); |
| 202 | 205 | store->barrier(); |
| 203 | store->close(); | |
| 204 | store->open(); | |
| 206 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 207 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 205 | 208 | store->load_atomspace(); |
| 206 | TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset); | |
| 209 | // +1 for *-close-* predicate from above | |
| 210 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 207 | 211 | |
| 208 | 212 | store->remove_atom(as, ha, true); |
| 209 | store->close(); | |
| 213 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 210 | 214 | as->extract_atom(ha, true); |
| 211 | store->open(); | |
| 215 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 212 | 216 | store->load_atomspace(); |
| 213 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 217 | // +1 for *-close-* predicate from above | |
| 218 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 214 | 219 | |
| 215 | 220 | // -------------------------------------- |
| 216 | 221 | // Do it again, but with a complex order. |
| … | … | @@ -220,17 +225,19 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 220 | 225 | |
| 221 | 226 | store->store_atom(lj); |
| 222 | 227 | store->barrier(); |
| 223 | store->close(); | |
| 224 | store->open(); | |
| 228 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 229 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 225 | 230 | store->load_atomspace(); |
| 226 | TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset); | |
| 231 | // +1 for *-close-* predicate from above | |
| 232 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 227 | 233 | |
| 228 | 234 | store->remove_atom(as, ha, true); |
| 229 | store->close(); | |
| 235 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 230 | 236 | as->extract_atom(ha, true); |
| 231 | store->open(); | |
| 237 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 232 | 238 | store->load_atomspace(); |
| 233 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 239 | // +1 for *-close-* predicate from above | |
| 240 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 234 | 241 | |
| 235 | 242 | // -------------------------------------- |
| 236 | 243 | // Do it again, but more deeply. |
| … | … | @@ -241,21 +248,23 @@ void SimpleBasicDeleteUTest::test_recursive(void) |
| 241 | 248 | |
| 242 | 249 | store->store_atom(lk); |
| 243 | 250 | store->barrier(); |
| 244 | store->close(); | |
| 245 | store->open(); | |
| 251 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 252 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 246 | 253 | store->load_atomspace(); |
| 247 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 254 | // +1 for *-close-* predicate from above | |
| 255 | TS_ASSERT_EQUALS(as->get_size(), 7 + basic_offset); | |
| 248 | 256 | |
| 249 | 257 | store->remove_atom(as, ha, true); |
| 250 | store->close(); | |
| 258 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 251 | 259 | as->extract_atom(ha, true); |
| 252 | store->open(); | |
| 260 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 253 | 261 | store->load_atomspace(); |
| 254 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 262 | // +1 for *-close-* predicate from above | |
| 263 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 255 | 264 | |
| 256 | 265 | // -------------------------------------- |
| 257 | 266 | ::kill_data(store.get(), _test_asp.get()); |
| 258 | store->close(); | |
| 267 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 259 | 268 | |
| 260 | 269 | logger().debug("END TEST: %s", __FUNCTION__); |
| 261 | 270 | } |
| … | … | @@ -272,7 +281,7 @@ void SimpleBasicDeleteUTest::test_key_deletion(void) |
| 272 | 281 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 273 | 282 | StorageNodePtr store = StorageNodeCast(hsn); |
| 274 | 283 | |
| 275 | store->open(); | |
| 284 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 276 | 285 | TS_ASSERT(store->connected()) |
| 277 | 286 | |
| 278 | 287 | // Clear out left-over junk, just in case. |
| … | … | @@ -291,8 +300,8 @@ void SimpleBasicDeleteUTest::test_key_deletion(void) |
| 291 | 300 | store->store_atom(ha); |
| 292 | 301 | store->barrier(); |
| 293 | 302 | |
| 294 | // Verify the atomspace size (+1 for *-IsKeyFlag-*) | |
| 295 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 303 | // Verify the atomspace size (+1 for *-IsKeyFlag-*, +1 for *-open-*) | |
| 304 | TS_ASSERT_EQUALS(as->get_size(), 7); | |
| 296 | 305 | |
| 297 | 306 | // Verify that there are three keys |
| 298 | 307 | HandleSet hs = ha->getKeys(); |
| … | … | @@ -304,14 +313,14 @@ void SimpleBasicDeleteUTest::test_key_deletion(void) |
| 304 | 313 | // both storage, and the AtomSpace itself block this, |
| 305 | 314 | store->remove_atom(as, kb); |
| 306 | 315 | as->extract_atom(kb); |
| 307 | // +1 for *-IsKeyFlag-* | |
| 308 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 316 | // +1 for *-IsKeyFlag-*, +1 for *-open-* | |
| 317 | TS_ASSERT_EQUALS(as->get_size(), 7); | |
| 309 | 318 | |
| 310 | 319 | // Verify the key was NOT deleted by loading only PredicateNodes. |
| 311 | 320 | as = createAtomSpace(); |
| 312 | 321 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 313 | 322 | store = StorageNodeCast(hsn); |
| 314 | store->open(); | |
| 323 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 315 | 324 | store->fetch_all_atoms_of_type(PREDICATE_NODE); |
| 316 | 325 | |
| 317 | 326 | // All keys should have been loaded. |
| … | … | @@ -333,7 +342,7 @@ void SimpleBasicDeleteUTest::test_key_deletion(void) |
| 333 | 342 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 334 | 343 | store = StorageNodeCast(hsn); |
| 335 | 344 | |
| 336 | store->open(); | |
| 345 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 337 | 346 | TS_ASSERT(store->connected()) |
| 338 | 347 | |
| 339 | 348 | // We expect 5 atoms |
| … | … | @@ -359,7 +368,7 @@ void SimpleBasicDeleteUTest::test_key_deletion(void) |
| 359 | 368 | TS_ASSERT_EQUALS(hs.size(), 3); |
| 360 | 369 | |
| 361 | 370 | ::kill_data(store.get(), _test_asp.get()); |
| 362 | store->close(); | |
| 371 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 363 | 372 | |
| 364 | 373 | logger().debug("END TEST: %s", __FUNCTION__); |
| 365 | 374 | } |
| … | … | @@ -381,7 +390,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 381 | 390 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 382 | 391 | StorageNodePtr store = StorageNodeCast(hsn); |
| 383 | 392 | |
| 384 | store->open(); | |
| 393 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 385 | 394 | TS_ASSERT(store->connected()) |
| 386 | 395 | |
| 387 | 396 | // Clear out left-over junk, just in case. |
| … | … | @@ -397,12 +406,12 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 397 | 406 | store->store_atom(hb); |
| 398 | 407 | store->barrier(); |
| 399 | 408 | |
| 400 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 409 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 401 | 410 | |
| 402 | 411 | // Remove the value |
| 403 | 412 | store->remove_atom(as, hx); |
| 404 | 413 | as->extract_atom(hx); |
| 405 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 414 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 406 | 415 | |
| 407 | 416 | // FYI, we should call store->close() at this point, but we |
| 408 | 417 | // don't, because ... most users forget to do this too. |
| … | … | @@ -418,7 +427,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 418 | 427 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 419 | 428 | store = StorageNodeCast(hsn); |
| 420 | 429 | |
| 421 | store->open(); | |
| 430 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 422 | 431 | TS_ASSERT(store->connected()) |
| 423 | 432 | |
| 424 | 433 | // We expect 5 atoms: b, x, key-x, *-IsKeyFlag-*, StorageNode |
| … | … | @@ -452,14 +461,14 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 452 | 461 | store->remove_atom(as, hx); |
| 453 | 462 | as->extract_atom(hx); |
| 454 | 463 | TS_ASSERT_EQUALS(as->get_size(), 5 + full_offset); |
| 455 | store->close(); | |
| 456 | store->open(); | |
| 464 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 465 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 457 | 466 | store->load_atomspace(); |
| 458 | // Size is 6 because (Concept "x") cannot be deleted. | |
| 459 | TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset); | |
| 467 | // Size is 6 because (Concept "x") cannot be deleted. +1 for *-close-* | |
| 468 | TS_ASSERT_EQUALS(as->get_size(), 7 + full_offset); | |
| 460 | 469 | |
| 461 | 470 | // We are done. |
| 462 | store->close(); | |
| 471 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 463 | 472 | |
| 464 | 473 | // ------------------------------------------------------- |
| 465 | 474 | // Start again, with a fresh connection. |
| … | … | @@ -470,7 +479,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 470 | 479 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 471 | 480 | store = StorageNodeCast(hsn); |
| 472 | 481 | |
| 473 | store->open(); | |
| 482 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 474 | 483 | TS_ASSERT(store->connected()) |
| 475 | 484 | |
| 476 | 485 | // We expect 6 atoms |
| … | … | @@ -490,7 +499,7 @@ void SimpleBasicDeleteUTest::test_key_corruption(void) |
| 490 | 499 | TS_ASSERT_EQUALS(hs.size(), 2); |
| 491 | 500 | |
| 492 | 501 | ::kill_data(store.get(), _test_asp.get()); |
| 493 | store->close(); | |
| 502 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 494 | 503 | |
| 495 | 504 | logger().debug("END TEST: %s", __FUNCTION__); |
| 496 | 505 | } |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/atoms/base/Link.h> |
| 34 | 34 | #include <opencog/atoms/base/Node.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | 38 | |
| 38 | 39 | #include <opencog/util/Logger.h> |
| … | … | @@ -416,7 +417,7 @@ void DeleteUTest::test_remove(void) |
| 416 | 417 | |
| 417 | 418 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16305"); |
| 418 | 419 | StorageNodePtr store = StorageNodeCast(hsn); |
| 419 | store->open(); | |
| 420 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 420 | 421 | TS_ASSERT(store->connected()) |
| 421 | 422 | |
| 422 | 423 | int idx = 0; |
| … | … | @@ -439,10 +440,10 @@ void DeleteUTest::test_remove(void) |
| 439 | 440 | /* Push all atoms out to storage */ |
| 440 | 441 | store->store_atomspace(); |
| 441 | 442 | |
| 442 | // +1 for (Predicate "*-IsKeyFlag-*") | |
| 443 | printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+1); | |
| 443 | // +1 for (Predicate "*-IsKeyFlag-*"), +1 for *-open-* | |
| 444 | printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+2); | |
| 444 | 445 | TSM_ASSERT("Initial unexpected atomspace size", |
| 445 | ((unsigned)(7*idx+1)) == _as->get_size()); | |
| 446 | ((unsigned)(7*idx+2)) == _as->get_size()); | |
| 446 | 447 | /* Delete some atoms with non-empty incoming sets. |
| 447 | 448 | * This should result in thier being removed from the atomspace, |
| 448 | 449 | * but NOT fom the backend! |
| … | … | @@ -452,9 +453,9 @@ void DeleteUTest::test_remove(void) |
| 452 | 453 | for (i=0; i<idx; i++) |
| 453 | 454 | extract_links(i, _as); |
| 454 | 455 | |
| 455 | // +1 for (Predicate "*-IsKeyFlag-*") | |
| 456 | printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+1); | |
| 457 | TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+1)) == _as->get_size()); | |
| 456 | // +1 for (Predicate "*-IsKeyFlag-*"), +1 for *-open-* | |
| 457 | printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+2); | |
| 458 | TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+2)) == _as->get_size()); | |
| 458 | 459 | |
| 459 | 460 | /* Verify that the atoms can still be fetched from storage. */ |
| 460 | 461 | for (i=0; i<idx; i++) { |
| … | … | @@ -466,8 +467,8 @@ void DeleteUTest::test_remove(void) |
| 466 | 467 | for (i=0; i<idx; i++) |
| 467 | 468 | delete_links(i, store); |
| 468 | 469 | |
| 469 | printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3); | |
| 470 | TSM_ASSERT("Post-remove unexpected atomspace size", ((unsigned)(4*idx+3)) == _as->get_size()); | |
| 470 | printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+4); | |
| 471 | TSM_ASSERT("Post-remove unexpected atomspace size", ((unsigned)(4*idx+4)) == _as->get_size()); | |
| 471 | 472 | |
| 472 | 473 | /* Verify that the atoms are really gone from storage. */ |
| 473 | 474 | for (i=0; i<idx; i++) { |
| … | … | @@ -475,8 +476,8 @@ void DeleteUTest::test_remove(void) |
| 475 | 476 | check_remove(i, _as, "verify-gone"); |
| 476 | 477 | } |
| 477 | 478 | |
| 478 | printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3); | |
| 479 | TSM_ASSERT("Post-refetch unexpected atomspace size", ((unsigned)(7*idx+3)) == _as->get_size()); | |
| 479 | printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+4); | |
| 480 | TSM_ASSERT("Post-refetch unexpected atomspace size", ((unsigned)(7*idx+4)) == _as->get_size()); | |
| 480 | 481 | |
| 481 | 482 | /* Kill data for good */ |
| 482 | 483 | _as->clear(); |
| … | … | @@ -497,7 +498,7 @@ void DeleteUTest::test_recurse(void) |
| 497 | 498 | |
| 498 | 499 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16305"); |
| 499 | 500 | StorageNodePtr store = StorageNodeCast(hsn); |
| 500 | store->open(); | |
| 501 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 501 | 502 | TS_ASSERT(store->connected()) |
| 502 | 503 | |
| 503 | 504 | int idx = 0; |
| … | … | @@ -530,8 +531,8 @@ void DeleteUTest::test_recurse(void) |
| 530 | 531 | for (i=0; i<zap; i++) |
| 531 | 532 | extract_nodes(i, _as); |
| 532 | 533 | |
| 533 | // +1 for the *-IsKeyFlag-* predicate | |
| 534 | size_t expsz = 7*(idx-zap) + 3*zap + 1; | |
| 534 | // +1 for the *-IsKeyFlag-* predicate, +1 for *-open-* predicate | |
| 535 | size_t expsz = 7*(idx-zap) + 3*zap + 2; | |
| 535 | 536 | printf("Atomspace size=%lu expect=%lu\n", |
| 536 | 537 | _as->get_size(), expsz); |
| 537 | 538 | TSM_ASSERT("Unexpected atomspace size", expsz == _as->get_size()); |
| … | … | @@ -558,9 +559,9 @@ void DeleteUTest::test_recurse(void) |
| 558 | 559 | } |
| 559 | 560 | |
| 560 | 561 | printf("Post-refetch size=%lu expect=%d\n", |
| 561 | _as->get_size(), 7*idx+3); | |
| 562 | _as->get_size(), 7*idx+4); | |
| 562 | 563 | TSM_ASSERT("Unexpected atomspace size", |
| 563 | ((unsigned) 7*idx+3) == _as->get_size()); | |
| 564 | ((unsigned) 7*idx+4) == _as->get_size()); | |
| 564 | 565 | |
| 565 | 566 | /* Check that the removed atoms really got zapped. */ |
| 566 | 567 | for (i=0; i<zap; i++) { |
| … | … | @@ -30,6 +30,7 @@ |
| 30 | 30 | #include <opencog/atoms/base/Link.h> |
| 31 | 31 | #include <opencog/atoms/base/Node.h> |
| 32 | 32 | #include <opencog/atoms/value/FloatValue.h> |
| 33 | #include <opencog/atoms/value/VoidValue.h> | |
| 33 | 34 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 34 | 35 | |
| 35 | 36 | #include <opencog/util/Logger.h> |
| … | … | @@ -366,7 +367,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 366 | 367 | |
| 367 | 368 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16308"); |
| 368 | 369 | StorageNodePtr store = StorageNodeCast(hsn); |
| 369 | store->open(); | |
| 370 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 370 | 371 | TS_ASSERT(store->connected()) |
| 371 | 372 | |
| 372 | 373 | /* Create a large number of atoms */ |
| … | … | @@ -391,7 +392,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 391 | 392 | /* The clear above nuked the storage, so restart */ |
| 392 | 393 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16308"); |
| 393 | 394 | store = StorageNodeCast(hsn); |
| 394 | store->open(); | |
| 395 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 395 | 396 | TS_ASSERT(store->connected()) |
| 396 | 397 | |
| 397 | 398 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -408,7 +409,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 408 | 409 | /* The clear above nuked the storage, so restart */ |
| 409 | 410 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16308"); |
| 410 | 411 | store = StorageNodeCast(hsn); |
| 411 | store->open(); | |
| 412 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 412 | 413 | TS_ASSERT(store->connected()) |
| 413 | 414 | |
| 414 | 415 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -426,7 +427,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 426 | 427 | for (i=0; i<idx; i++) |
| 427 | 428 | check_empty(i, _as); |
| 428 | 429 | |
| 429 | store->close(); | |
| 430 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 430 | 431 | logger().debug("END TEST: %s", __FUNCTION__); |
| 431 | 432 | } |
| 432 | 433 |
| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 36 | 37 | |
| 37 | 38 | #include <opencog/util/Logger.h> |
| … | … | @@ -291,7 +292,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 291 | 292 | |
| 292 | 293 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16309"); |
| 293 | 294 | StorageNodePtr store = StorageNodeCast(hsn); |
| 294 | store->open(); | |
| 295 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 295 | 296 | TS_ASSERT(store->connected()) |
| 296 | 297 | |
| 297 | 298 | /* Create a large number of atoms */ |
| … | … | @@ -314,7 +315,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 314 | 315 | /* The clear above nuked the storage, so restart */ |
| 315 | 316 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16309"); |
| 316 | 317 | store = StorageNodeCast(hsn); |
| 317 | store->open(); | |
| 318 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 318 | 319 | TS_ASSERT(store->connected()) |
| 319 | 320 | |
| 320 | 321 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -329,7 +330,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 329 | 330 | /* The clear above nuked the storage, so restart */ |
| 330 | 331 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16309"); |
| 331 | 332 | store = StorageNodeCast(hsn); |
| 332 | store->open(); | |
| 333 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 333 | 334 | TS_ASSERT(store->connected()) |
| 334 | 335 | |
| 335 | 336 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -344,7 +345,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 344 | 345 | /* Verify that the atoms are no longer being found. */ |
| 345 | 346 | check_empty(_as); |
| 346 | 347 | |
| 347 | store->close(); | |
| 348 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 348 | 349 | logger().debug("END TEST: %s", __FUNCTION__); |
| 349 | 350 | } |
| 350 | 351 |
| … | … | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <opencog/persist/cog-types/atom_types.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | 36 | #include <opencog/atoms/value/LinkValue.h> |
| 37 | #include <opencog/atoms/value/VoidValue.h> | |
| 37 | 38 | #include <opencog/atomspace/AtomSpace.h> |
| 38 | 39 | |
| 39 | 40 | #include <opencog/persist/api/StorageNode.h> |
| … | … | @@ -154,7 +155,7 @@ void SimpleMultiDeleteUTest::test_add_delete(void) |
| 154 | 155 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 155 | 156 | store = StorageNodeCast(hsn); |
| 156 | 157 | |
| 157 | store->open(); | |
| 158 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 158 | 159 | TS_ASSERT(store->connected()) |
| 159 | 160 | |
| 160 | 161 | // Clear out left-over junk, just in case. |
| … | … | @@ -174,16 +175,16 @@ void SimpleMultiDeleteUTest::test_add_delete(void) |
| 174 | 175 | printf("Post-update AtomSpace size=%lu\n", as->get_size()); |
| 175 | 176 | // printf("AtomSpace contents =\n%s\n", as->to_string().c_str()); |
| 176 | 177 | |
| 177 | // Verify the local AtomSpace size. Should be 34: | |
| 178 | // Verify the local AtomSpace size. Should be 35: | |
| 178 | 179 | // The CogStorageNode itself, the (Concept "aaaa") and |
| 179 | // 16 from thread-id modulo 16 plus 16 ListLinks. | |
| 180 | TS_ASSERT_EQUALS(as->get_size(), 2 + 2*(n_threads+6)); | |
| 180 | // 16 from thread-id modulo 16 plus 16 ListLinks, plus *-open-* predicate | |
| 181 | TS_ASSERT_EQUALS(as->get_size(), 3 + 2*(n_threads+6)); | |
| 181 | 182 | |
| 182 | 183 | // Verify the remote AtomSpace: pull everything from the |
| 183 | 184 | // cogserver, back to here. Do this "independently", by |
| 184 | 185 | // closing the socket; this forces the cogserver through |
| 185 | 186 | // its socket-close code, potentially exposing bugs. |
| 186 | store->close(); | |
| 187 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 187 | 188 | |
| 188 | 189 | HandleSeq hs; |
| 189 | 190 | as->get_handles_by_type(hs, CONCEPT_NODE); |
| … | … | @@ -191,18 +192,20 @@ void SimpleMultiDeleteUTest::test_add_delete(void) |
| 191 | 192 | as->extract_atom(h, true); |
| 192 | 193 | hs.clear(); |
| 193 | 194 | printf("AtomSpace contents =\n%s\n", as->to_string().c_str()); |
| 194 | TS_ASSERT_EQUALS(as->get_size(), 1); | |
| 195 | // CogStorageNode + *-close-* predicate + *-open-* predicate | |
| 196 | TS_ASSERT_EQUALS(as->get_size(), 3); | |
| 195 | 197 | |
| 196 | store->open(); | |
| 198 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 197 | 199 | TS_ASSERT(store->connected()) |
| 198 | 200 | |
| 199 | 201 | store->load_atomspace(); |
| 200 | 202 | printf("Final AtomSpace size=%lu\n", as->get_size()); |
| 201 | 203 | |
| 202 | // Size should be 20: the 18 from before plus | |
| 204 | // Size should be 22: the 18 from before plus | |
| 203 | 205 | // (Predicate "*-TruthValueKey-*") and (Predicate "*-IsKeyFlag-*") |
| 204 | 206 | // Plus 9 more from CogServerNode gorp |
| 205 | size_t expected_size = 9 + 4 + 6 + n_threads; | |
| 207 | // Plus *-open-* and *-close-* predicates | |
| 208 | size_t expected_size = 9 + 4 + 2 + 6 + n_threads; | |
| 206 | 209 | if (as->get_size() != expected_size) |
| 207 | 210 | printf("Error: Bad size! AtomSpace contents =\n%s\n", |
| 208 | 211 | as->to_string().c_str()); |
| … | … | @@ -210,7 +213,7 @@ void SimpleMultiDeleteUTest::test_add_delete(void) |
| 210 | 213 | TS_ASSERT_EQUALS(as->get_size(), expected_size); |
| 211 | 214 | |
| 212 | 215 | ::kill_data(store.get(), _test_asp.get()); |
| 213 | store->close(); | |
| 216 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 214 | 217 | store = nullptr; |
| 215 | 218 | |
| 216 | 219 | logger().debug("END TEST: %s", __FUNCTION__); |
| … | … | @@ -36,6 +36,7 @@ |
| 36 | 36 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | 37 | |
| 38 | 38 | #include <opencog/atoms/value/FloatValue.h> |
| 39 | #include <opencog/atoms/value/VoidValue.h> | |
| 39 | 40 | |
| 40 | 41 | #include <opencog/util/Logger.h> |
| 41 | 42 | #include "../TestCogServer.h" |
| … | … | @@ -132,7 +133,7 @@ void MultiPersistUTest::setUp(void) |
| 132 | 133 | |
| 133 | 134 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16306"); |
| 134 | 135 | store = StorageNodeCast(hsn); |
| 135 | store->open(); | |
| 136 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 136 | 137 | TS_ASSERT(store->connected()) |
| 137 | 138 | } |
| 138 | 139 | |
| … | … | @@ -431,7 +432,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 431 | 432 | /* The clear above nuked the storage, so restart */ |
| 432 | 433 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16306"); |
| 433 | 434 | store = StorageNodeCast(hsn); |
| 434 | store->open(); | |
| 435 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 435 | 436 | TS_ASSERT(store->connected()) |
| 436 | 437 | |
| 437 | 438 | int i, off; |
| … | … | @@ -450,7 +451,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 450 | 451 | /* The clear above nuked the storage, so restart */ |
| 451 | 452 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16306"); |
| 452 | 453 | store = StorageNodeCast(hsn); |
| 453 | store->open(); | |
| 454 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 454 | 455 | TS_ASSERT(store->connected()) |
| 455 | 456 | |
| 456 | 457 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -469,7 +470,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 469 | 470 | for (i=0; i<NATS; i++) |
| 470 | 471 | check_empty(NHACK*off+i, _as); |
| 471 | 472 | |
| 472 | store->close(); | |
| 473 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 473 | 474 | logger().debug("END TEST: %s", __FUNCTION__); |
| 474 | 475 | } |
| 475 | 476 |
| … | … | @@ -36,6 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/base/Node.h> |
| 37 | 37 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 38 | 38 | #include <opencog/atoms/value/FloatValue.h> |
| 39 | #include <opencog/atoms/value/VoidValue.h> | |
| 39 | 40 | |
| 40 | 41 | #include <opencog/util/Logger.h> |
| 41 | 42 | #include "../TestCogServer.h" |
| … | … | @@ -160,7 +161,7 @@ void MultiUserUTest::connect_to_db(int i) |
| 160 | 161 | _as[i] = createAtomSpace(); |
| 161 | 162 | Handle hsn = _as[i]->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16307"); |
| 162 | 163 | _store[i] = StorageNodeCast(hsn); |
| 163 | _store[i]->open(); | |
| 164 | _store[i]->setValue(_as[i]->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 164 | 165 | TS_ASSERT(_store[i]->connected()) |
| 165 | 166 | } |
| 166 | 167 | |
| … | … | @@ -425,7 +426,7 @@ void MultiUserUTest::run_user_test(int thread_id) |
| 425 | 426 | while (n_threads != nstarted.fetch_add(0)) std::this_thread::yield(); |
| 426 | 427 | |
| 427 | 428 | add_atoms(thread_id); |
| 428 | _store[thread_id]->close(); | |
| 429 | _store[thread_id]->setValue(_as[thread_id]->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 429 | 430 | _as[thread_id] = nullptr; |
| 430 | 431 | } |
| 431 | 432 | |
| … | … | @@ -449,7 +450,7 @@ void MultiUserUTest::do_test_multiuser(void) |
| 449 | 450 | AtomSpacePtr aspace = createAtomSpace(); |
| 450 | 451 | Handle hsn = aspace->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16307"); |
| 451 | 452 | StorageNodePtr store = StorageNodeCast(hsn); |
| 452 | store->open(); | |
| 453 | store->setValue(aspace->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 453 | 454 | TS_ASSERT(store->connected()) |
| 454 | 455 | |
| 455 | 456 | for (int off=0; off<n_threads; off++) |
| … | … | @@ -459,7 +460,7 @@ void MultiUserUTest::do_test_multiuser(void) |
| 459 | 460 | } |
| 460 | 461 | |
| 461 | 462 | store->barrier(); |
| 462 | store->close(); | |
| 463 | store->setValue(aspace->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 463 | 464 | aspace = nullptr; |
| 464 | 465 | } |
| 465 | 466 |
| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | |
| 36 | 37 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | 38 | |
| … | … | @@ -317,7 +318,7 @@ void PersistUTest::test_atomspace(void) |
| 317 | 318 | |
| 318 | 319 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16303"); |
| 319 | 320 | StorageNodePtr store = StorageNodeCast(hsn); |
| 320 | store->open(); | |
| 321 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 321 | 322 | TS_ASSERT(store->connected()) |
| 322 | 323 | |
| 323 | 324 | int idx = 0; |
| … | … | @@ -351,7 +352,7 @@ void PersistUTest::test_atomspace(void) |
| 351 | 352 | /* The above clear wiped out the storage node; recreate it. */ |
| 352 | 353 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16303"); |
| 353 | 354 | store = StorageNodeCast(hsn); |
| 354 | store->open(); | |
| 355 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 355 | 356 | TS_ASSERT(store->connected()) |
| 356 | 357 | |
| 357 | 358 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -367,7 +368,7 @@ void PersistUTest::test_atomspace(void) |
| 367 | 368 | /* The above clear wiped out the storage node; recreate it. */ |
| 368 | 369 | hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, "cog://localhost:16303"); |
| 369 | 370 | store = StorageNodeCast(hsn); |
| 370 | store->open(); | |
| 371 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 371 | 372 | TS_ASSERT(store->connected()) |
| 372 | 373 | |
| 373 | 374 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -376,7 +377,7 @@ void PersistUTest::test_atomspace(void) |
| 376 | 377 | check_space(i, _as, "ver-again"); |
| 377 | 378 | } |
| 378 | 379 | |
| 379 | store->close(); | |
| 380 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 380 | 381 | |
| 381 | 382 | /* Kill data for good */ |
| 382 | 383 | _as->clear(); |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 37 | 38 | |
| 38 | 39 | #include <opencog/util/Logger.h> |
| … | … | @@ -123,7 +124,7 @@ void SimpleQueryPersistUTest::setup_data(void) |
| 123 | 124 | _as = createAtomSpace(); |
| 124 | 125 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 125 | 126 | StorageNodePtr store = StorageNodeCast(hsn); |
| 126 | store->open(); | |
| 127 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 127 | 128 | TS_ASSERT(store->connected()) |
| 128 | 129 | |
| 129 | 130 | /* Populate the Storage with stuff that we will later query. */ |
| … | … | @@ -170,7 +171,7 @@ void SimpleQueryPersistUTest::test_meet(void) |
| 170 | 171 | _as = createAtomSpace(); |
| 171 | 172 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 172 | 173 | StorageNodePtr store = StorageNodeCast(hsn); |
| 173 | store->open(); | |
| 174 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 174 | 175 | TS_ASSERT(store->connected()) |
| 175 | 176 | |
| 176 | 177 | // Create a query to find all things that have wheels. |
| … | … | @@ -221,7 +222,7 @@ void SimpleQueryPersistUTest::test_meet(void) |
| 221 | 222 | HandleSet htoo = lvp->to_handle_set(); |
| 222 | 223 | TSM_ASSERT("Expect same results as before", hset == htoo); |
| 223 | 224 | |
| 224 | store->close(); | |
| 225 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 225 | 226 | |
| 226 | 227 | logger().info("END TEST: %s", __FUNCTION__); |
| 227 | 228 | } |
| … | … | @@ -235,7 +236,7 @@ void SimpleQueryPersistUTest::test_join(void) |
| 235 | 236 | _as = createAtomSpace(); |
| 236 | 237 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 237 | 238 | StorageNodePtr store = StorageNodeCast(hsn); |
| 238 | store->open(); | |
| 239 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 239 | 240 | TS_ASSERT(store->connected()) |
| 240 | 241 | |
| 241 | 242 | // Create a join to find all vehicles. |
| … | … | @@ -272,7 +273,7 @@ void SimpleQueryPersistUTest::test_join(void) |
| 272 | 273 | |
| 273 | 274 | TSM_ASSERT_EQUALS("Expecting airplane, bicycle and car", hset, expect); |
| 274 | 275 | |
| 275 | store->close(); | |
| 276 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 276 | 277 | |
| 277 | 278 | logger().info("END TEST: %s", __FUNCTION__); |
| 278 | 279 | } |
| … | … | @@ -28,6 +28,7 @@ |
| 28 | 28 | #include <opencog/atoms/base/Link.h> |
| 29 | 29 | #include <opencog/atoms/base/Node.h> |
| 30 | 30 | #include <opencog/atomspace/AtomSpace.h> |
| 31 | #include <opencog/atoms/value/VoidValue.h> | |
| 31 | 32 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| 32 | 33 | |
| 33 | 34 | #include <opencog/util/Logger.h> |
| … | … | @@ -108,7 +109,7 @@ void ServerHangUTest::test_no_hang(void) |
| 108 | 109 | _as = createAtomSpace(); |
| 109 | 110 | Handle hsn = _as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 110 | 111 | StorageNodePtr store = StorageNodeCast(hsn); |
| 111 | store->open(); | |
| 112 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 112 | 113 | TS_ASSERT(store->connected()); |
| 113 | 114 | |
| 114 | 115 | printf("Triggering an exception (UniqueLink cannot be instantiated)...\n"); |
| … | … | @@ -36,6 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | 37 | #include <opencog/atoms/value/LinkValue.h> |
| 38 | 38 | #include <opencog/atoms/value/StringValue.h> |
| 39 | #include <opencog/atoms/value/VoidValue.h> | |
| 39 | 40 | #include "../TestCogServer.h" |
| 40 | 41 | |
| 41 | 42 | #include <opencog/persist/cog-simple/CogSimpleStorage.h> |
| … | … | @@ -106,7 +107,7 @@ void SimpleValueSaveUTest::test_single_atom_save() |
| 106 | 107 | AtomSpacePtr as = createAtomSpace(); |
| 107 | 108 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 108 | 109 | StorageNodePtr store = StorageNodeCast(hsn); |
| 109 | store->open(); | |
| 110 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 110 | 111 | TS_ASSERT(store->connected()) |
| 111 | 112 | |
| 112 | 113 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -170,7 +171,7 @@ void SimpleValueSaveUTest::check_one(ValuePtr pap, bool fetchkey) |
| 170 | 171 | AtomSpacePtr as = createAtomSpace(); |
| 171 | 172 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 172 | 173 | StorageNodePtr store = StorageNodeCast(hsn); |
| 173 | store->open(); | |
| 174 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 174 | 175 | TS_ASSERT(store->connected()) |
| 175 | 176 | |
| 176 | 177 | Handle key = store->fetch_atom(bkey); |
| … | … | @@ -193,7 +194,7 @@ void SimpleValueSaveUTest::check_one(ValuePtr pap, bool fetchkey) |
| 193 | 194 | as = createAtomSpace(); |
| 194 | 195 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 195 | 196 | store = StorageNodeCast(hsn); |
| 196 | store->open(); | |
| 197 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 197 | 198 | TS_ASSERT(store->connected()) |
| 198 | 199 | |
| 199 | 200 | // Storage uses a different code path if the key is not yet |
| … | … | @@ -218,7 +219,7 @@ void SimpleValueSaveUTest::test_save_restore(bool fkey) |
| 218 | 219 | AtomSpacePtr as = createAtomSpace(); |
| 219 | 220 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 220 | 221 | StorageNodePtr store = StorageNodeCast(hsn); |
| 221 | store->open(); | |
| 222 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 222 | 223 | TS_ASSERT(store->connected()) |
| 223 | 224 | |
| 224 | 225 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -273,7 +274,7 @@ void SimpleValueSaveUTest::test_load_by_type() |
| 273 | 274 | AtomSpacePtr as = createAtomSpace(); |
| 274 | 275 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 275 | 276 | StorageNodePtr store = StorageNodeCast(hsn); |
| 276 | store->open(); | |
| 277 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 277 | 278 | TS_ASSERT(store->connected()) |
| 278 | 279 | |
| 279 | 280 | // Clear out left-over junk, just in case. |
| … | … | @@ -335,7 +336,7 @@ void SimpleValueSaveUTest::test_load_by_type() |
| 335 | 336 | as = createAtomSpace(); |
| 336 | 337 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 337 | 338 | store = StorageNodeCast(hsn); |
| 338 | store->open(); | |
| 339 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 339 | 340 | TS_ASSERT(store->connected()) |
| 340 | 341 | |
| 341 | 342 | // -------------------- |
| … | … | @@ -343,10 +344,11 @@ void SimpleValueSaveUTest::test_load_by_type() |
| 343 | 344 | store->fetch_all_atoms_of_type(CONCEPT_NODE); |
| 344 | 345 | store->barrier(); |
| 345 | 346 | |
| 346 | // Seven: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*", | |
| 347 | // PredicateNode "some pred key", and PredicateNode "*-IsKeyFlag-*" | |
| 347 | // Nine: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*", | |
| 348 | // PredicateNode "some pred key", PredicateNode "*-IsKeyFlag-*", | |
| 349 | // the CogSimpleStorageNode, and the PredicateNode "*-open-*" | |
| 348 | 350 | // -- the preds show up when the attached values are fetched. |
| 349 | TSM_ASSERT_EQUALS("Wrong number of Atoms fetched!", as->get_size(), 8); | |
| 351 | TSM_ASSERT_EQUALS("Wrong number of Atoms fetched!", as->get_size(), 9); | |
| 350 | 352 | |
| 351 | 353 | printf("Got %lu Atoms\n", as->get_size()); |
| 352 | 354 | HandleSeq hset; |
| … | … | @@ -407,7 +409,7 @@ void SimpleValueSaveUTest::test_link_by_type() |
| 407 | 409 | AtomSpacePtr as = createAtomSpace(); |
| 408 | 410 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 409 | 411 | StorageNodePtr store = StorageNodeCast(hsn); |
| 410 | store->open(); | |
| 412 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 411 | 413 | TS_ASSERT(store->connected()) |
| 412 | 414 | |
| 413 | 415 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -494,7 +496,7 @@ void SimpleValueSaveUTest::test_link_by_type() |
| 494 | 496 | as = createAtomSpace(); |
| 495 | 497 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 496 | 498 | store = StorageNodeCast(hsn); |
| 497 | store->open(); | |
| 499 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 498 | 500 | TS_ASSERT(store->connected()) |
| 499 | 501 | |
| 500 | 502 | // -------------------- |
| … | … | @@ -510,10 +512,10 @@ void SimpleValueSaveUTest::test_link_by_type() |
| 510 | 512 | // The B-nodes are added after the fetch. In either case, |
| 511 | 513 | // there should not be any values fetched for either A or B; |
| 512 | 514 | // only the values on the C-links should be fetched. |
| 513 | // +1 for (PredicateNode "*-IsKeyFlag-*") | |
| 515 | // +1 for (PredicateNode "*-IsKeyFlag-*"), +1 for *-open-* | |
| 514 | 516 | store->fetch_all_atoms_of_type(LIST_LINK); |
| 515 | 517 | store->barrier(); |
| 516 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16); | |
| 518 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 17); | |
| 517 | 519 | |
| 518 | 520 | printf("Got %lu Atoms\n", as->get_size()); |
| 519 | 521 | HandleSeq hset; |
| … | … | @@ -628,7 +630,7 @@ void SimpleValueSaveUTest::test_link_by_type_quoted() |
| 628 | 630 | AtomSpacePtr as = createAtomSpace(); |
| 629 | 631 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 630 | 632 | StorageNodePtr store = StorageNodeCast(hsn); |
| 631 | store->open(); | |
| 633 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 632 | 634 | TS_ASSERT(store->connected()) |
| 633 | 635 | |
| 634 | 636 | Handle key = as->add_node(PREDICATE_NODE, "some (\"pred\"))) key"); |
| … | … | @@ -715,7 +717,7 @@ void SimpleValueSaveUTest::test_link_by_type_quoted() |
| 715 | 717 | as = createAtomSpace(); |
| 716 | 718 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 717 | 719 | store = StorageNodeCast(hsn); |
| 718 | store->open(); | |
| 720 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 719 | 721 | TS_ASSERT(store->connected()) |
| 720 | 722 | |
| 721 | 723 | // -------------------- |
| … | … | @@ -734,10 +736,10 @@ void SimpleValueSaveUTest::test_link_by_type_quoted() |
| 734 | 736 | store->fetch_all_atoms_of_type(LIST_LINK); |
| 735 | 737 | store->barrier(); |
| 736 | 738 | |
| 737 | // We created 9 new atoms above, so expect 16 from before plus 9 | |
| 738 | // (+1 for *-IsKeyFlag-*) | |
| 739 | printf ("fetched %lu atoms, expecting 25\n", as->get_size()); | |
| 740 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25); | |
| 739 | // We created 9 new atoms above, so expect 17 from before plus 9 | |
| 740 | // (+1 for *-IsKeyFlag-*, +1 for *-open-*) | |
| 741 | printf ("fetched %lu atoms, expecting 26\n", as->get_size()); | |
| 742 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 26); | |
| 741 | 743 | |
| 742 | 744 | Handle gbf = as->add_node(CONCEPT_NODE, "b float node"); |
| 743 | 745 | Handle gbt = as->add_node(CONCEPT_NODE, "b string node"); |
| … | … | @@ -846,7 +848,7 @@ void SimpleValueSaveUTest::test_incoming() |
| 846 | 848 | AtomSpacePtr as = createAtomSpace(); |
| 847 | 849 | Handle hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 848 | 850 | StorageNodePtr store = StorageNodeCast(hsn); |
| 849 | store->open(); | |
| 851 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 850 | 852 | TS_ASSERT(store->connected()) |
| 851 | 853 | |
| 852 | 854 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -933,7 +935,7 @@ void SimpleValueSaveUTest::test_incoming() |
| 933 | 935 | as = createAtomSpace(); |
| 934 | 936 | hsn = as->add_node(COG_SIMPLE_STORAGE_NODE, std::string(uri)); |
| 935 | 937 | store = StorageNodeCast(hsn); |
| 936 | store->open(); | |
| 938 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 937 | 939 | TS_ASSERT(store->connected()) |
| 938 | 940 | |
| 939 | 941 | // -------------------- |
| … | … | @@ -953,9 +955,9 @@ void SimpleValueSaveUTest::test_incoming() |
| 953 | 955 | store->fetch_incoming_set(gat, false); |
| 954 | 956 | store->fetch_incoming_set(gal, false); |
| 955 | 957 | store->fetch_incoming_set(gav, false); |
| 956 | // +1 for *-IsKeyFlag-* | |
| 957 | printf ("AtomSpace now contains %lu atoms, expecting 16\n", as->get_size()); | |
| 958 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16); | |
| 958 | // +1 for *-IsKeyFlag-*, +1 for *-open-* | |
| 959 | printf ("AtomSpace now contains %lu atoms, expecting 17\n", as->get_size()); | |
| 960 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 17); | |
| 959 | 961 | |
| 960 | 962 | Handle gbf = as->add_node(CONCEPT_NODE, "b float node"); |
| 961 | 963 | Handle gbt = as->add_node(CONCEPT_NODE, "b string node"); |
| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Node.h> |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 36 | 37 | #include "../TestCogServer.h" |
| 37 | 38 | |
| … | … | @@ -129,7 +130,7 @@ void AlphaEquivUTest::setup_data(void) |
| 129 | 130 | |
| 130 | 131 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 131 | 132 | StorageNodePtr store = StorageNodeCast(hsn); |
| 132 | store->open(); | |
| 133 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 133 | 134 | TS_ASSERT(store->connected()) |
| 134 | 135 | |
| 135 | 136 | /* Populate the Storage with stuff that we will later query. */ |
| … | … | @@ -141,7 +142,7 @@ void AlphaEquivUTest::setup_data(void) |
| 141 | 142 | /* Push all atoms out to the database */ |
| 142 | 143 | store->store_atomspace(); |
| 143 | 144 | store->barrier(); |
| 144 | store->close(); | |
| 145 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 145 | 146 | } |
| 146 | 147 | |
| 147 | 148 | // ============================================================ |
| … | … | @@ -156,7 +157,7 @@ void AlphaEquivUTest::test_fetch(void) |
| 156 | 157 | _as = createAtomSpace(); |
| 157 | 158 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 158 | 159 | StorageNodePtr store = StorageNodeCast(hsn); |
| 159 | store->open(); | |
| 160 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 160 | 161 | TS_ASSERT(store->connected()) |
| 161 | 162 | |
| 162 | 163 | // Fetch an alpha-equivalent lambda link. |
| … | … | @@ -185,7 +186,7 @@ void AlphaEquivUTest::test_fetch(void) |
| 185 | 186 | FloatValuePtr fup = FloatValueCast(fu); |
| 186 | 187 | TSM_ASSERT_EQUALS("Expecting three floats", fup->size(), 3); |
| 187 | 188 | |
| 188 | store->close(); | |
| 189 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 189 | 190 | logger().info("END TEST: %s", __FUNCTION__); |
| 190 | 191 | } |
| 191 | 192 | |
| … | … | @@ -201,7 +202,7 @@ void AlphaEquivUTest::test_remove(void) |
| 201 | 202 | _as = createAtomSpace(); |
| 202 | 203 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 203 | 204 | StorageNodePtr store = StorageNodeCast(hsn); |
| 204 | store->open(); | |
| 205 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 205 | 206 | TS_ASSERT(store->connected()) |
| 206 | 207 | |
| 207 | 208 | // Remove the alpha-equivalent lambda link. |
| … | … | @@ -222,7 +223,7 @@ void AlphaEquivUTest::test_remove(void) |
| 222 | 223 | ValuePtr fu = lx->getValue(an(PREDICATE, "foo")); |
| 223 | 224 | TSM_ASSERT("Expecting null value", nullptr == fu); |
| 224 | 225 | |
| 225 | store->close(); | |
| 226 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 226 | 227 | logger().info("END TEST: %s", __FUNCTION__); |
| 227 | 228 | } |
| 228 | 229 | |
| … | … | @@ -238,7 +239,7 @@ void AlphaEquivUTest::test_recursive_remove(void) |
| 238 | 239 | _as = createAtomSpace(); |
| 239 | 240 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 240 | 241 | StorageNodePtr store = StorageNodeCast(hsn); |
| 241 | store->open(); | |
| 242 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 242 | 243 | TS_ASSERT(store->connected()) |
| 243 | 244 | |
| 244 | 245 | // Recursive remove Concept "A". |
| … | … | @@ -258,7 +259,7 @@ void AlphaEquivUTest::test_recursive_remove(void) |
| 258 | 259 | ValuePtr fu = lx->getValue(an(PREDICATE, "foo")); |
| 259 | 260 | TSM_ASSERT("Expecting null value", nullptr == fu); |
| 260 | 261 | |
| 261 | store->close(); | |
| 262 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 262 | 263 | logger().info("END TEST: %s", __FUNCTION__); |
| 263 | 264 | } |
| 264 | 265 |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/persist/cog-types/atom_types.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/atomspace/AtomSpace.h> |
| 37 | 38 | #include "../TestCogServer.h" |
| 38 | 39 | |
| … | … | @@ -92,8 +93,8 @@ void BasicDeleteUTest::tearDown(void) |
| 92 | 93 | } |
| 93 | 94 | |
| 94 | 95 | // 9 more from CogServerNode and gorp; 2 for *-TruthValueKey-* and |
| 95 | // *-IsKeyFlag-* | |
| 96 | int basic_offset = 9 + 2; | |
| 96 | // *-IsKeyFlag-*; 1 more for *-open-* | |
| 97 | int basic_offset = 9 + 3; | |
| 97 | 98 | |
| 98 | 99 | // ============================================================ |
| 99 | 100 | |
| … | … | @@ -106,7 +107,7 @@ void BasicDeleteUTest::test_duplicates(void) |
| 106 | 107 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 107 | 108 | StorageNodePtr store = StorageNodeCast(hsn); |
| 108 | 109 | |
| 109 | store->open(); | |
| 110 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 110 | 111 | TS_ASSERT(store->connected()) |
| 111 | 112 | |
| 112 | 113 | // Clear out left-over junk, just in case. |
| … | … | @@ -120,23 +121,24 @@ void BasicDeleteUTest::test_duplicates(void) |
| 120 | 121 | store->store_atom(li); |
| 121 | 122 | store->barrier(); |
| 122 | 123 | |
| 123 | // Verify the atomspace size | |
| 124 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 124 | // Verify the atomspace size (+1 for *-open-* predicate) | |
| 125 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 125 | 126 | |
| 126 | 127 | // Remove the link. Since the link has duplicate atoms |
| 127 | 128 | // in it, this can cause trouble, depending on how the |
| 128 | 129 | // incoming set is managed. |
| 129 | 130 | store->remove_atom(as, li); |
| 130 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 131 | store->close(); | |
| 131 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 132 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 132 | 133 | as->extract_atom(li); |
| 133 | TS_ASSERT_EQUALS(as->get_size(), 3); | |
| 134 | store->open(); | |
| 134 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 135 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 135 | 136 | store->load_atomspace(); |
| 136 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 137 | // +1 for *-close-* predicate from above | |
| 138 | TS_ASSERT_EQUALS(as->get_size(), 4 + basic_offset); | |
| 137 | 139 | |
| 138 | 140 | ::kill_data(store.get(), _test_asp.get()); |
| 139 | store->close(); | |
| 141 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 140 | 142 | |
| 141 | 143 | logger().debug("END TEST: %s", __FUNCTION__); |
| 142 | 144 | } |
| … | … | @@ -152,7 +154,7 @@ void BasicDeleteUTest::test_recursive(void) |
| 152 | 154 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 153 | 155 | StorageNodePtr store = StorageNodeCast(hsn); |
| 154 | 156 | |
| 155 | store->open(); | |
| 157 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 156 | 158 | TS_ASSERT(store->connected()) |
| 157 | 159 | |
| 158 | 160 | // Clear out left-over junk, just in case. |
| … | … | @@ -173,8 +175,8 @@ void BasicDeleteUTest::test_recursive(void) |
| 173 | 175 | for (const Handle& h : hset) |
| 174 | 176 | printf("Atomspace contains: %s\n", h->to_short_string().c_str()); |
| 175 | 177 | |
| 176 | // Verify the atomspace size | |
| 177 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 178 | // Verify the atomspace size (+1 for *-open-* predicate) | |
| 179 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 178 | 180 | |
| 179 | 181 | // Remove (Concept "a"). Since this appears twice, recursion |
| 180 | 182 | // will hit it twice, in stange ways, and maybe crash. |
| … | … | @@ -186,11 +188,12 @@ void BasicDeleteUTest::test_recursive(void) |
| 186 | 188 | for (const Handle& h : hset) |
| 187 | 189 | printf("Post delete: %s\n", h->to_short_string().c_str()); |
| 188 | 190 | |
| 189 | store->close(); | |
| 191 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 190 | 192 | as->extract_atom(ha, true); |
| 191 | store->open(); | |
| 193 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 192 | 194 | store->load_atomspace(); |
| 193 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 195 | // +1 for *-close-* predicate from above | |
| 196 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 194 | 197 | |
| 195 | 198 | // -------------------------------------- |
| 196 | 199 | // Do it again, but with a different order. |
| … | … | @@ -200,17 +203,19 @@ void BasicDeleteUTest::test_recursive(void) |
| 200 | 203 | |
| 201 | 204 | store->store_atom(lj); |
| 202 | 205 | store->barrier(); |
| 203 | store->close(); | |
| 204 | store->open(); | |
| 206 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 207 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 205 | 208 | store->load_atomspace(); |
| 206 | TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset); | |
| 209 | // +1 for *-close-* predicate from above | |
| 210 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 207 | 211 | |
| 208 | 212 | store->remove_atom(as, ha, true); |
| 209 | store->close(); | |
| 213 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 210 | 214 | as->extract_atom(ha, true); |
| 211 | store->open(); | |
| 215 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 212 | 216 | store->load_atomspace(); |
| 213 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 217 | // +1 for *-close-* predicate from above | |
| 218 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 214 | 219 | |
| 215 | 220 | // -------------------------------------- |
| 216 | 221 | // Do it again, but with a complex order. |
| … | … | @@ -220,17 +225,19 @@ void BasicDeleteUTest::test_recursive(void) |
| 220 | 225 | |
| 221 | 226 | store->store_atom(lj); |
| 222 | 227 | store->barrier(); |
| 223 | store->close(); | |
| 224 | store->open(); | |
| 228 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 229 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 225 | 230 | store->load_atomspace(); |
| 226 | TS_ASSERT_EQUALS(as->get_size(), 5 + basic_offset); | |
| 231 | // +1 for *-close-* predicate from above | |
| 232 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 227 | 233 | |
| 228 | 234 | store->remove_atom(as, ha, true); |
| 229 | store->close(); | |
| 235 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 230 | 236 | as->extract_atom(ha, true); |
| 231 | store->open(); | |
| 237 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 232 | 238 | store->load_atomspace(); |
| 233 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 239 | // +1 for *-close-* predicate from above | |
| 240 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 234 | 241 | |
| 235 | 242 | // -------------------------------------- |
| 236 | 243 | // Do it again, but more deeply. |
| … | … | @@ -241,21 +248,23 @@ void BasicDeleteUTest::test_recursive(void) |
| 241 | 248 | |
| 242 | 249 | store->store_atom(lk); |
| 243 | 250 | store->barrier(); |
| 244 | store->close(); | |
| 245 | store->open(); | |
| 251 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 252 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 246 | 253 | store->load_atomspace(); |
| 247 | TS_ASSERT_EQUALS(as->get_size(), 6 + basic_offset); | |
| 254 | // +1 for *-close-* predicate from above | |
| 255 | TS_ASSERT_EQUALS(as->get_size(), 7 + basic_offset); | |
| 248 | 256 | |
| 249 | 257 | store->remove_atom(as, ha, true); |
| 250 | store->close(); | |
| 258 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 251 | 259 | as->extract_atom(ha, true); |
| 252 | store->open(); | |
| 260 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 253 | 261 | store->load_atomspace(); |
| 254 | TS_ASSERT_EQUALS(as->get_size(), 2 + basic_offset); | |
| 262 | // +1 for *-close-* predicate from above | |
| 263 | TS_ASSERT_EQUALS(as->get_size(), 3 + basic_offset); | |
| 255 | 264 | |
| 256 | 265 | // -------------------------------------- |
| 257 | 266 | ::kill_data(store.get(), _test_asp.get()); |
| 258 | store->close(); | |
| 267 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 259 | 268 | |
| 260 | 269 | logger().debug("END TEST: %s", __FUNCTION__); |
| 261 | 270 | } |
| … | … | @@ -272,7 +281,7 @@ void BasicDeleteUTest::test_key_deletion(void) |
| 272 | 281 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 273 | 282 | StorageNodePtr store = StorageNodeCast(hsn); |
| 274 | 283 | |
| 275 | store->open(); | |
| 284 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 276 | 285 | TS_ASSERT(store->connected()) |
| 277 | 286 | |
| 278 | 287 | // Clear out left-over junk, just in case. |
| … | … | @@ -291,8 +300,8 @@ void BasicDeleteUTest::test_key_deletion(void) |
| 291 | 300 | store->store_atom(ha); |
| 292 | 301 | store->barrier(); |
| 293 | 302 | |
| 294 | // Verify the atomspace size (+1 for *-IsKeyFlag-*) | |
| 295 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 303 | // Verify the atomspace size (+1 for *-IsKeyFlag-*, +1 for *-open-*) | |
| 304 | TS_ASSERT_EQUALS(as->get_size(), 7); | |
| 296 | 305 | |
| 297 | 306 | // Verify that there are three keys |
| 298 | 307 | HandleSet hs = ha->getKeys(); |
| … | … | @@ -304,14 +313,14 @@ void BasicDeleteUTest::test_key_deletion(void) |
| 304 | 313 | // AtomSpace will allow this. |
| 305 | 314 | store->remove_atom(as, kb); |
| 306 | 315 | as->extract_atom(kb); |
| 307 | // +1 for *-IsKeyFlag-* | |
| 308 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 316 | // +1 for *-IsKeyFlag-*, +1 for *-open-* | |
| 317 | TS_ASSERT_EQUALS(as->get_size(), 7); | |
| 309 | 318 | |
| 310 | 319 | // Verify the key was deleted by loading only PredicateNodes. |
| 311 | 320 | as = createAtomSpace(); |
| 312 | 321 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 313 | 322 | store = StorageNodeCast(hsn); |
| 314 | store->open(); | |
| 323 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 315 | 324 | store->fetch_all_atoms_of_type(PREDICATE_NODE); |
| 316 | 325 | store->barrier(); |
| 317 | 326 | |
| … | … | @@ -334,7 +343,7 @@ void BasicDeleteUTest::test_key_deletion(void) |
| 334 | 343 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 335 | 344 | store = StorageNodeCast(hsn); |
| 336 | 345 | |
| 337 | store->open(); | |
| 346 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 338 | 347 | TS_ASSERT(store->connected()) |
| 339 | 348 | |
| 340 | 349 | // We expect 5 atoms |
| … | … | @@ -360,7 +369,7 @@ void BasicDeleteUTest::test_key_deletion(void) |
| 360 | 369 | TS_ASSERT_EQUALS(hs.size(), 3); |
| 361 | 370 | |
| 362 | 371 | ::kill_data(store.get(), _test_asp.get()); |
| 363 | store->close(); | |
| 372 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 364 | 373 | |
| 365 | 374 | logger().debug("END TEST: %s", __FUNCTION__); |
| 366 | 375 | } |
| … | … | @@ -382,7 +391,7 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 382 | 391 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 383 | 392 | StorageNodePtr store = StorageNodeCast(hsn); |
| 384 | 393 | |
| 385 | store->open(); | |
| 394 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 386 | 395 | TS_ASSERT(store->connected()) |
| 387 | 396 | |
| 388 | 397 | // Clear out left-over junk, just in case. |
| … | … | @@ -398,12 +407,12 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 398 | 407 | store->store_atom(hb); |
| 399 | 408 | store->barrier(); |
| 400 | 409 | |
| 401 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 410 | TS_ASSERT_EQUALS(as->get_size(), 6); | |
| 402 | 411 | |
| 403 | 412 | // Remove the value |
| 404 | 413 | store->remove_atom(as, hx); |
| 405 | 414 | as->extract_atom(hx); |
| 406 | TS_ASSERT_EQUALS(as->get_size(), 4); | |
| 415 | TS_ASSERT_EQUALS(as->get_size(), 5); | |
| 407 | 416 | |
| 408 | 417 | // FYI, we should call store->close() at this point, but we |
| 409 | 418 | // don't, because ... most users forget to do this too. |
| … | … | @@ -419,7 +428,7 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 419 | 428 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 420 | 429 | store = StorageNodeCast(hsn); |
| 421 | 430 | |
| 422 | store->open(); | |
| 431 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 423 | 432 | TS_ASSERT(store->connected()) |
| 424 | 433 | |
| 425 | 434 | // We expect 5 atoms: b, x, key-x, *-IsKeyFlag-*, StorageNode |
| … | … | @@ -453,14 +462,14 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 453 | 462 | store->remove_atom(as, hx); |
| 454 | 463 | as->extract_atom(hx); |
| 455 | 464 | TS_ASSERT_EQUALS(as->get_size(), 5 + full_offset); |
| 456 | store->close(); | |
| 457 | store->open(); | |
| 465 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 466 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 458 | 467 | store->load_atomspace(); |
| 459 | // Size is 6 because (Concept "x") cannot be deleted. | |
| 460 | TS_ASSERT_EQUALS(as->get_size(), 6 + full_offset); | |
| 468 | // Size is 6 because (Concept "x") cannot be deleted. +1 for *-close-* | |
| 469 | TS_ASSERT_EQUALS(as->get_size(), 7 + full_offset); | |
| 461 | 470 | |
| 462 | 471 | // We are done. |
| 463 | store->close(); | |
| 472 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 464 | 473 | |
| 465 | 474 | // ------------------------------------------------------- |
| 466 | 475 | // Start again, with a fresh connection. |
| … | … | @@ -471,7 +480,7 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 471 | 480 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 472 | 481 | store = StorageNodeCast(hsn); |
| 473 | 482 | |
| 474 | store->open(); | |
| 483 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 475 | 484 | TS_ASSERT(store->connected()) |
| 476 | 485 | |
| 477 | 486 | // We expect 6 atoms |
| … | … | @@ -491,7 +500,7 @@ void BasicDeleteUTest::test_key_corruption(void) |
| 491 | 500 | TS_ASSERT_EQUALS(hs.size(), 2); |
| 492 | 501 | |
| 493 | 502 | ::kill_data(store.get(), _test_asp.get()); |
| 494 | store->close(); | |
| 503 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 495 | 504 | |
| 496 | 505 | logger().debug("END TEST: %s", __FUNCTION__); |
| 497 | 506 | } |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/atoms/base/Link.h> |
| 34 | 34 | #include <opencog/atoms/base/Node.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 37 | 38 | #include "../TestCogServer.h" |
| 38 | 39 | |
| … | … | @@ -420,7 +421,7 @@ void DeleteUTest::test_remove(void) |
| 420 | 421 | |
| 421 | 422 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16005"); |
| 422 | 423 | StorageNodePtr store = StorageNodeCast(hsn); |
| 423 | store->open(); | |
| 424 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 424 | 425 | TS_ASSERT(store->connected()) |
| 425 | 426 | |
| 426 | 427 | int idx = 0; |
| … | … | @@ -443,10 +444,10 @@ void DeleteUTest::test_remove(void) |
| 443 | 444 | /* Push all atoms out to storage */ |
| 444 | 445 | store->store_atomspace(); |
| 445 | 446 | |
| 446 | // +1 for (Predicate "*-IsKeyFlag-*") | |
| 447 | printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+1); | |
| 447 | // +1 for (Predicate "*-IsKeyFlag-*"), +1 for *-open-* | |
| 448 | printf("Initial Atomspace size=%lu expect=%d\n", _as->get_size(), 7*idx+2); | |
| 448 | 449 | TSM_ASSERT("Initial unexpected atomspace size", |
| 449 | ((unsigned)(7*idx+1)) == _as->get_size()); | |
| 450 | ((unsigned)(7*idx+2)) == _as->get_size()); | |
| 450 | 451 | /* Delete some atoms with non-empty incoming sets. |
| 451 | 452 | * This should result in thier being removed from the atomspace, |
| 452 | 453 | * but NOT fom the backend! |
| … | … | @@ -456,9 +457,9 @@ void DeleteUTest::test_remove(void) |
| 456 | 457 | for (i=0; i<idx; i++) |
| 457 | 458 | extract_links(i, _as); |
| 458 | 459 | |
| 459 | // +1 for (Predicate "*-IsKeyFlag-*") | |
| 460 | printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+1); | |
| 461 | TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+1)) == _as->get_size()); | |
| 460 | // +1 for (Predicate "*-IsKeyFlag-*"), +1 for *-open-* | |
| 461 | printf("Atomspace size=%lu expect=%d\n", _as->get_size(), 4*idx+2); | |
| 462 | TSM_ASSERT("Post-extract unexpected atomspace size", ((unsigned)(4*idx+2)) == _as->get_size()); | |
| 462 | 463 | |
| 463 | 464 | /* Verify that the atoms can still be fetched from storage. */ |
| 464 | 465 | for (i=0; i<idx; i++) { |
| … | … | @@ -470,9 +471,9 @@ void DeleteUTest::test_remove(void) |
| 470 | 471 | for (i=0; i<idx; i++) |
| 471 | 472 | delete_links(i, store); |
| 472 | 473 | |
| 473 | printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+3); | |
| 474 | printf("Post-remove size=%lu expect=%d\n", _as->get_size(), 4*idx+4); | |
| 474 | 475 | TSM_ASSERT("Post-remove unexpected atomspace size", |
| 475 | ((unsigned)(4*idx+3)) == _as->get_size()); | |
| 476 | ((unsigned)(4*idx+4)) == _as->get_size()); | |
| 476 | 477 | |
| 477 | 478 | /* Verify that the atoms are really gone from storage. */ |
| 478 | 479 | for (i=0; i<idx; i++) { |
| … | … | @@ -480,9 +481,9 @@ void DeleteUTest::test_remove(void) |
| 480 | 481 | check_remove(i, _as, "verify-gone"); |
| 481 | 482 | } |
| 482 | 483 | |
| 483 | printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+3); | |
| 484 | printf("Post-referesh size=%lu expect=%d\n", _as->get_size(), 7*idx+4); | |
| 484 | 485 | TSM_ASSERT("Post-refetch unexpected atomspace size", |
| 485 | ((unsigned)(7*idx+3)) == _as->get_size()); | |
| 486 | ((unsigned)(7*idx+4)) == _as->get_size()); | |
| 486 | 487 | |
| 487 | 488 | /* Kill data for good */ |
| 488 | 489 | _as->clear(); |
| … | … | @@ -503,7 +504,7 @@ void DeleteUTest::test_recurse(void) |
| 503 | 504 | |
| 504 | 505 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16005"); |
| 505 | 506 | StorageNodePtr store = StorageNodeCast(hsn); |
| 506 | store->open(); | |
| 507 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 507 | 508 | TS_ASSERT(store->connected()) |
| 508 | 509 | |
| 509 | 510 | int idx = 0; |
| … | … | @@ -536,8 +537,8 @@ void DeleteUTest::test_recurse(void) |
| 536 | 537 | for (i=0; i<zap; i++) |
| 537 | 538 | extract_nodes(i, _as); |
| 538 | 539 | |
| 539 | // +1 for the *-IsKeyFlag-* predicate | |
| 540 | size_t expsz = 7*(idx-zap) + 3*zap + 1; | |
| 540 | // +1 for the *-IsKeyFlag-* predicate, +1 for *-open-* predicate | |
| 541 | size_t expsz = 7*(idx-zap) + 3*zap + 2; | |
| 541 | 542 | printf("Atomspace size=%lu expect=%lu\n", |
| 542 | 543 | _as->get_size(), expsz); |
| 543 | 544 | TSM_ASSERT("Unexpected atomspace size", expsz == _as->get_size()); |
| … | … | @@ -564,9 +565,9 @@ void DeleteUTest::test_recurse(void) |
| 564 | 565 | } |
| 565 | 566 | |
| 566 | 567 | printf("Post-refetch size=%lu expect=%d\n", |
| 567 | _as->get_size(), 7*idx+3); | |
| 568 | _as->get_size(), 7*idx+4); | |
| 568 | 569 | TSM_ASSERT("Unexpected atomspace size", |
| 569 | ((unsigned) 7*idx+3) == _as->get_size()); | |
| 570 | ((unsigned) 7*idx+4) == _as->get_size()); | |
| 570 | 571 | |
| 571 | 572 | /* Check that the removed atoms really got zapped. */ |
| 572 | 573 | for (i=0; i<zap; i++) { |
| … | … | @@ -30,6 +30,7 @@ |
| 30 | 30 | #include <opencog/atoms/base/Link.h> |
| 31 | 31 | #include <opencog/atoms/base/Node.h> |
| 32 | 32 | #include <opencog/atoms/value/FloatValue.h> |
| 33 | #include <opencog/atoms/value/VoidValue.h> | |
| 33 | 34 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 34 | 35 | #include "../TestCogServer.h" |
| 35 | 36 | |
| … | … | @@ -366,7 +367,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 366 | 367 | |
| 367 | 368 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16008"); |
| 368 | 369 | StorageNodePtr store = StorageNodeCast(hsn); |
| 369 | store->open(); | |
| 370 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 370 | 371 | TS_ASSERT(store->connected()) |
| 371 | 372 | |
| 372 | 373 | /* Create a large number of atoms */ |
| … | … | @@ -391,7 +392,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 391 | 392 | /* The clear above nuked the storage, so restart */ |
| 392 | 393 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16008"); |
| 393 | 394 | store = StorageNodeCast(hsn); |
| 394 | store->open(); | |
| 395 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 395 | 396 | TS_ASSERT(store->connected()) |
| 396 | 397 | |
| 397 | 398 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -408,7 +409,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 408 | 409 | /* The clear above nuked the storage, so restart */ |
| 409 | 410 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16008"); |
| 410 | 411 | store = StorageNodeCast(hsn); |
| 411 | store->open(); | |
| 412 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 412 | 413 | TS_ASSERT(store->connected()) |
| 413 | 414 | |
| 414 | 415 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -426,7 +427,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 426 | 427 | for (i=0; i<idx; i++) |
| 427 | 428 | check_empty(i, _as); |
| 428 | 429 | |
| 429 | store->close(); | |
| 430 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 430 | 431 | logger().debug("END TEST: %s", __FUNCTION__); |
| 431 | 432 | } |
| 432 | 433 |
| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 36 | 37 | #include "../TestCogServer.h" |
| 37 | 38 | |
| … | … | @@ -292,7 +293,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 292 | 293 | |
| 293 | 294 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16009"); |
| 294 | 295 | StorageNodePtr store = StorageNodeCast(hsn); |
| 295 | store->open(); | |
| 296 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 296 | 297 | TS_ASSERT(store->connected()) |
| 297 | 298 | |
| 298 | 299 | /* Create a large number of atoms */ |
| … | … | @@ -315,7 +316,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 315 | 316 | /* The clear above nuked the storage, so restart */ |
| 316 | 317 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16009"); |
| 317 | 318 | store = StorageNodeCast(hsn); |
| 318 | store->open(); | |
| 319 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 319 | 320 | TS_ASSERT(store->connected()) |
| 320 | 321 | |
| 321 | 322 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -330,7 +331,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 330 | 331 | /* The clear above nuked the storage, so restart */ |
| 331 | 332 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16009"); |
| 332 | 333 | store = StorageNodeCast(hsn); |
| 333 | store->open(); | |
| 334 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 334 | 335 | TS_ASSERT(store->connected()) |
| 335 | 336 | |
| 336 | 337 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -345,7 +346,7 @@ void LargeZipfUTest::test_atomspace(void) |
| 345 | 346 | /* Verify that the atoms are no longer being found. */ |
| 346 | 347 | check_empty(_as); |
| 347 | 348 | |
| 348 | store->close(); | |
| 349 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 349 | 350 | logger().debug("END TEST: %s", __FUNCTION__); |
| 350 | 351 | } |
| 351 | 352 |
| … | … | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <opencog/persist/cog-types/atom_types.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | 36 | #include <opencog/atoms/value/LinkValue.h> |
| 37 | #include <opencog/atoms/value/VoidValue.h> | |
| 37 | 38 | #include <opencog/atomspace/AtomSpace.h> |
| 38 | 39 | |
| 39 | 40 | #include "../TestCogServer.h" |
| … | … | @@ -152,7 +153,7 @@ void MultiDeleteUTest::test_add_delete(void) |
| 152 | 153 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 153 | 154 | store = StorageNodeCast(hsn); |
| 154 | 155 | |
| 155 | store->open(); | |
| 156 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 156 | 157 | TS_ASSERT(store->connected()) |
| 157 | 158 | |
| 158 | 159 | // Clear out left-over junk, just in case. |
| … | … | @@ -172,16 +173,16 @@ void MultiDeleteUTest::test_add_delete(void) |
| 172 | 173 | printf("Post-update AtomSpace size=%lu\n", as->get_size()); |
| 173 | 174 | // printf("AtomSpace contents =\n%s\n", as->to_string().c_str()); |
| 174 | 175 | |
| 175 | // Verify the local AtomSpace size. Should be 34: | |
| 176 | // The CogStrageNode itself, the (Concept "aaaa") and | |
| 177 | // 16 from thread-id modulo 16 | |
| 178 | TS_ASSERT_EQUALS(as->get_size(), 2 + 2*(n_threads+6)); | |
| 176 | // Verify the local AtomSpace size. Should be 35: | |
| 177 | // The CogStorageNode itself, the (Concept "aaaa") and | |
| 178 | // 16 from thread-id modulo 16, plus *-open-* predicate | |
| 179 | TS_ASSERT_EQUALS(as->get_size(), 3 + 2*(n_threads+6)); | |
| 179 | 180 | |
| 180 | 181 | // Verify the remote AtomSpace: pull everything from the |
| 181 | 182 | // cogserver, back to here. Do this "independently", by |
| 182 | 183 | // closing the socket; this forces the cogserver through |
| 183 | 184 | // its socket-close code, potentially exposing bugs. |
| 184 | store->close(); | |
| 185 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 185 | 186 | |
| 186 | 187 | HandleSeq hs; |
| 187 | 188 | as->get_handles_by_type(hs, CONCEPT_NODE); |
| … | … | @@ -189,9 +190,10 @@ void MultiDeleteUTest::test_add_delete(void) |
| 189 | 190 | as->extract_atom(h, true); |
| 190 | 191 | hs.clear(); |
| 191 | 192 | printf("AtomSpace contents =\n%s\n", as->to_string().c_str()); |
| 192 | TS_ASSERT_EQUALS(as->get_size(), 1); | |
| 193 | // CogStorageNode + *-close-* predicate + *-open-* predicate | |
| 194 | TS_ASSERT_EQUALS(as->get_size(), 3); | |
| 193 | 195 | |
| 194 | store->open(); | |
| 196 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 195 | 197 | TS_ASSERT(store->connected()) |
| 196 | 198 | |
| 197 | 199 | store->load_atomspace(); |
| … | … | @@ -200,11 +202,12 @@ void MultiDeleteUTest::test_add_delete(void) |
| 200 | 202 | // Size should be 20: the 18 from before plus that annoying |
| 201 | 203 | // (Predicate "*-TruthValueKey-*") And also *-IsKeyFlag-* |
| 202 | 204 | // And 9 more from CogServerNode gorp |
| 205 | // Plus *-open-* and *-close-* predicates | |
| 203 | 206 | // Well, actually, there is no guarantee that the removes will |
| 204 | 207 | // happen after the stores. Best we can do is check lower and |
| 205 | // upper bounds of 20 and 36: | |
| 206 | size_t min_size = 9 + 4 + n_threads + 6; | |
| 207 | size_t max_size = 9 + 4 + 2*(n_threads + 6); | |
| 208 | // upper bounds of 22 and 38: | |
| 209 | size_t min_size = 9 + 4 + 2 + n_threads + 6; | |
| 210 | size_t max_size = 9 + 4 + 2 + 2*(n_threads + 6); | |
| 208 | 211 | if (as->get_size() < min_size or max_size < as->get_size()) |
| 209 | 212 | printf("Error: Bad size! AtomSpace contents =\n%s\n", |
| 210 | 213 | as->to_string().c_str()); |
| … | … | @@ -213,7 +216,7 @@ void MultiDeleteUTest::test_add_delete(void) |
| 213 | 216 | TS_ASSERT(as->get_size() <= max_size); |
| 214 | 217 | |
| 215 | 218 | ::kill_data(store.get(), _test_asp.get()); |
| 216 | store->close(); | |
| 219 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 217 | 220 | store = nullptr; |
| 218 | 221 | |
| 219 | 222 | logger().debug("END TEST: %s", __FUNCTION__); |
| … | … | @@ -37,6 +37,7 @@ |
| 37 | 37 | #include "../TestCogServer.h" |
| 38 | 38 | |
| 39 | 39 | #include <opencog/atoms/value/FloatValue.h> |
| 40 | #include <opencog/atoms/value/VoidValue.h> | |
| 40 | 41 | |
| 41 | 42 | #include <opencog/util/Logger.h> |
| 42 | 43 | |
| … | … | @@ -132,13 +133,13 @@ void MultiPersistUTest::setUp(void) |
| 132 | 133 | |
| 133 | 134 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16006"); |
| 134 | 135 | store = StorageNodeCast(hsn); |
| 135 | store->open(); | |
| 136 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 136 | 137 | TS_ASSERT(store->connected()) |
| 137 | 138 | } |
| 138 | 139 | |
| 139 | 140 | void MultiPersistUTest::tearDown(void) |
| 140 | 141 | { |
| 141 | store->close(); | |
| 142 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 142 | 143 | store = nullptr; |
| 143 | 144 | _as = nullptr; |
| 144 | 145 | } |
| … | … | @@ -436,7 +437,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 436 | 437 | /* The clear above nuked the storage, so restart */ |
| 437 | 438 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16006"); |
| 438 | 439 | store = StorageNodeCast(hsn); |
| 439 | store->open(); | |
| 440 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 440 | 441 | TS_ASSERT(store->connected()) |
| 441 | 442 | |
| 442 | 443 | int i, off; |
| … | … | @@ -456,7 +457,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 456 | 457 | /* The clear above nuked the storage, so restart */ |
| 457 | 458 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16006"); |
| 458 | 459 | store = StorageNodeCast(hsn); |
| 459 | store->open(); | |
| 460 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 460 | 461 | TS_ASSERT(store->connected()) |
| 461 | 462 | |
| 462 | 463 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -476,7 +477,7 @@ void MultiPersistUTest::test_atomspace(void) |
| 476 | 477 | for (i=0; i<NATS; i++) |
| 477 | 478 | check_empty(NHACK*off+i, _as); |
| 478 | 479 | |
| 479 | store->close(); | |
| 480 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 480 | 481 | logger().debug("END TEST: %s", __FUNCTION__); |
| 481 | 482 | } |
| 482 | 483 |
| … | … | @@ -38,6 +38,7 @@ |
| 38 | 38 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 39 | 39 | #include "../TestCogServer.h" |
| 40 | 40 | #include <opencog/atoms/value/FloatValue.h> |
| 41 | #include <opencog/atoms/value/VoidValue.h> | |
| 41 | 42 | |
| 42 | 43 | #include <opencog/util/Logger.h> |
| 43 | 44 | |
| … | … | @@ -162,7 +163,7 @@ void MultiUserUTest::connect_to_db(int i) |
| 162 | 163 | _as[i] = createAtomSpace(); |
| 163 | 164 | Handle hsn = _as[i]->add_node(COG_STORAGE_NODE, "cog://localhost:16007"); |
| 164 | 165 | _store[i] = StorageNodeCast(hsn); |
| 165 | _store[i]->open(); | |
| 166 | _store[i]->setValue(_as[i]->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 166 | 167 | TS_ASSERT(_store[i]->connected()) |
| 167 | 168 | } |
| 168 | 169 | |
| … | … | @@ -439,7 +440,7 @@ void MultiUserUTest::run_user_test(int thread_id) |
| 439 | 440 | TSM_ASSERT("Took too long to connect", end - start < 10); |
| 440 | 441 | |
| 441 | 442 | add_atoms(thread_id); |
| 442 | _store[thread_id]->close(); | |
| 443 | _store[thread_id]->setValue(_as[thread_id]->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 443 | 444 | _as[thread_id] = nullptr; |
| 444 | 445 | } |
| 445 | 446 | |
| … | … | @@ -463,7 +464,7 @@ void MultiUserUTest::do_test_multiuser(void) |
| 463 | 464 | AtomSpacePtr aspace = createAtomSpace(); |
| 464 | 465 | Handle hsn = aspace->add_node(COG_STORAGE_NODE, "cog://localhost:16007"); |
| 465 | 466 | StorageNodePtr store = StorageNodeCast(hsn); |
| 466 | store->open(); | |
| 467 | store->setValue(aspace->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 467 | 468 | TS_ASSERT(store->connected()) |
| 468 | 469 | |
| 469 | 470 | for (int off=0; off<n_threads; off++) |
| … | … | @@ -473,7 +474,7 @@ void MultiUserUTest::do_test_multiuser(void) |
| 473 | 474 | } |
| 474 | 475 | |
| 475 | 476 | store->barrier(); |
| 476 | store->close(); | |
| 477 | store->setValue(aspace->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 477 | 478 | aspace = nullptr; |
| 478 | 479 | } |
| 479 | 480 |
| … | … | @@ -32,6 +32,7 @@ |
| 32 | 32 | #include <opencog/atoms/base/Link.h> |
| 33 | 33 | #include <opencog/atoms/base/Node.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | #include <opencog/atoms/value/VoidValue.h> | |
| 35 | 36 | #include "../TestCogServer.h" |
| 36 | 37 | |
| 37 | 38 | #include <opencog/persist/cog-storage/CogStorage.h> |
| … | … | @@ -318,7 +319,7 @@ void PersistUTest::test_atomspace(void) |
| 318 | 319 | |
| 319 | 320 | Handle hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16003"); |
| 320 | 321 | StorageNodePtr store = StorageNodeCast(hsn); |
| 321 | store->open(); | |
| 322 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 322 | 323 | TS_ASSERT(store->connected()) |
| 323 | 324 | |
| 324 | 325 | int idx = 0; |
| … | … | @@ -352,7 +353,7 @@ void PersistUTest::test_atomspace(void) |
| 352 | 353 | /* The above clear wiped out the storage node; recreate it. */ |
| 353 | 354 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16003"); |
| 354 | 355 | store = StorageNodeCast(hsn); |
| 355 | store->open(); | |
| 356 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 356 | 357 | TS_ASSERT(store->connected()) |
| 357 | 358 | |
| 358 | 359 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -368,7 +369,7 @@ void PersistUTest::test_atomspace(void) |
| 368 | 369 | /* The above clear wiped out the storage node; recreate it. */ |
| 369 | 370 | hsn = _as->add_node(COG_STORAGE_NODE, "cog://localhost:16003"); |
| 370 | 371 | store = StorageNodeCast(hsn); |
| 371 | store->open(); | |
| 372 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 372 | 373 | TS_ASSERT(store->connected()) |
| 373 | 374 | |
| 374 | 375 | /* Verify that the atoms can still be fetched from storage. */ |
| … | … | @@ -377,7 +378,7 @@ void PersistUTest::test_atomspace(void) |
| 377 | 378 | check_space(i, _as, "ver-again"); |
| 378 | 379 | } |
| 379 | 380 | |
| 380 | store->close(); | |
| 381 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 381 | 382 | |
| 382 | 383 | /* Kill data for good */ |
| 383 | 384 | _as->clear(); |
| … | … | @@ -33,6 +33,7 @@ |
| 33 | 33 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 34 | #include <opencog/atoms/value/FloatValue.h> |
| 35 | 35 | #include <opencog/atoms/value/LinkValue.h> |
| 36 | #include <opencog/atoms/value/VoidValue.h> | |
| 36 | 37 | #include <opencog/persist/cog-storage/CogStorage.h> |
| 37 | 38 | #include "../TestCogServer.h" |
| 38 | 39 | |
| … | … | @@ -125,7 +126,7 @@ void QueryPersistUTest::setup_data(void) |
| 125 | 126 | _as = createAtomSpace(); |
| 126 | 127 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 127 | 128 | StorageNodePtr store = StorageNodeCast(hsn); |
| 128 | store->open(); | |
| 129 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 129 | 130 | TS_ASSERT(store->connected()) |
| 130 | 131 | |
| 131 | 132 | /* Populate the Storage with stuff that we will later query. */ |
| … | … | @@ -161,7 +162,7 @@ void QueryPersistUTest::setup_data(void) |
| 161 | 162 | /* Push all atoms out to the server */ |
| 162 | 163 | store->store_atomspace(); |
| 163 | 164 | store->barrier(); |
| 164 | store->close(); | |
| 165 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 165 | 166 | } |
| 166 | 167 | |
| 167 | 168 | void QueryPersistUTest::test_meet(void) |
| … | … | @@ -173,7 +174,7 @@ void QueryPersistUTest::test_meet(void) |
| 173 | 174 | _as = createAtomSpace(); |
| 174 | 175 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 175 | 176 | StorageNodePtr store = StorageNodeCast(hsn); |
| 176 | store->open(); | |
| 177 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 177 | 178 | TS_ASSERT(store->connected()) |
| 178 | 179 | |
| 179 | 180 | // Create a query to find all things that have wheels. |
| … | … | @@ -224,7 +225,7 @@ void QueryPersistUTest::test_meet(void) |
| 224 | 225 | HandleSet htoo = lvp->to_handle_set(); |
| 225 | 226 | TSM_ASSERT("Expect same results as before", hset == htoo); |
| 226 | 227 | |
| 227 | store->close(); | |
| 228 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 228 | 229 | logger().info("END TEST: %s", __FUNCTION__); |
| 229 | 230 | } |
| 230 | 231 | |
| … | … | @@ -237,7 +238,7 @@ void QueryPersistUTest::test_join(void) |
| 237 | 238 | _as = createAtomSpace(); |
| 238 | 239 | Handle hsn = _as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 239 | 240 | StorageNodePtr store = StorageNodeCast(hsn); |
| 240 | store->open(); | |
| 241 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 241 | 242 | TS_ASSERT(store->connected()) |
| 242 | 243 | |
| 243 | 244 | // Create a join to find all vehicles. |
| … | … | @@ -274,7 +275,7 @@ void QueryPersistUTest::test_join(void) |
| 274 | 275 | |
| 275 | 276 | TSM_ASSERT_EQUALS("Expecting airplane, bicycle and car", hset, expect); |
| 276 | 277 | |
| 277 | store->close(); | |
| 278 | store->setValue(_as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 278 | 279 | logger().info("END TEST: %s", __FUNCTION__); |
| 279 | 280 | } |
| 280 | 281 |
| … | … | @@ -36,6 +36,7 @@ |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | 37 | #include <opencog/atoms/value/LinkValue.h> |
| 38 | 38 | #include <opencog/atoms/value/StringValue.h> |
| 39 | #include <opencog/atoms/value/VoidValue.h> | |
| 39 | 40 | #include "../TestCogServer.h" |
| 40 | 41 | |
| 41 | 42 | #include <opencog/persist/cog-storage/CogStorage.h> |
| … | … | @@ -108,7 +109,7 @@ void ValueSaveUTest::test_single_atom_save() |
| 108 | 109 | AtomSpacePtr as = createAtomSpace(); |
| 109 | 110 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 110 | 111 | StorageNodePtr store = StorageNodeCast(hsn); |
| 111 | store->open(); | |
| 112 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 112 | 113 | TS_ASSERT(store->connected()) |
| 113 | 114 | |
| 114 | 115 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -154,6 +155,7 @@ void ValueSaveUTest::test_single_atom_save() |
| 154 | 155 | store->store_atom(atom); |
| 155 | 156 | store->barrier(); |
| 156 | 157 | |
| 158 | store->setValue(as->add_node(PREDICATE_NODE, "*-close-*"), createVoidValue()); | |
| 157 | 159 | as = nullptr; |
| 158 | 160 | |
| 159 | 161 | logger().info("END TEST: %s", __FUNCTION__); |
| … | … | @@ -174,7 +176,7 @@ void ValueSaveUTest::check_one(ValuePtr pap, bool fetchkey) |
| 174 | 176 | AtomSpacePtr as = createAtomSpace(); |
| 175 | 177 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 176 | 178 | StorageNodePtr store = StorageNodeCast(hsn); |
| 177 | store->open(); | |
| 179 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 178 | 180 | TS_ASSERT(store->connected()) |
| 179 | 181 | |
| 180 | 182 | Handle key = store->fetch_atom(bkey); |
| … | … | @@ -197,7 +199,7 @@ void ValueSaveUTest::check_one(ValuePtr pap, bool fetchkey) |
| 197 | 199 | as = createAtomSpace(); |
| 198 | 200 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 199 | 201 | store = StorageNodeCast(hsn); |
| 200 | store->open(); | |
| 202 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 201 | 203 | TS_ASSERT(store->connected()) |
| 202 | 204 | |
| 203 | 205 | // Storage uses a different code path if the key is not yet |
| … | … | @@ -222,7 +224,7 @@ void ValueSaveUTest::test_save_restore(bool fkey) |
| 222 | 224 | AtomSpacePtr as = createAtomSpace(); |
| 223 | 225 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 224 | 226 | StorageNodePtr store = StorageNodeCast(hsn); |
| 225 | store->open(); | |
| 227 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 226 | 228 | TS_ASSERT(store->connected()) |
| 227 | 229 | |
| 228 | 230 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -278,7 +280,7 @@ void ValueSaveUTest::test_load_by_type() |
| 278 | 280 | AtomSpacePtr as = createAtomSpace(); |
| 279 | 281 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 280 | 282 | StorageNodePtr store = StorageNodeCast(hsn); |
| 281 | store->open(); | |
| 283 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 282 | 284 | TS_ASSERT(store->connected()) |
| 283 | 285 | |
| 284 | 286 | // Clear out left-over junk, just in case. |
| … | … | @@ -339,7 +341,7 @@ void ValueSaveUTest::test_load_by_type() |
| 339 | 341 | as = createAtomSpace(); |
| 340 | 342 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 341 | 343 | store = StorageNodeCast(hsn); |
| 342 | store->open(); | |
| 344 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 343 | 345 | TS_ASSERT(store->connected()) |
| 344 | 346 | |
| 345 | 347 | // -------------------- |
| … | … | @@ -347,12 +349,13 @@ void ValueSaveUTest::test_load_by_type() |
| 347 | 349 | store->fetch_all_atoms_of_type(CONCEPT_NODE); |
| 348 | 350 | store->barrier(); |
| 349 | 351 | |
| 350 | // Seven: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*", | |
| 351 | // PredicateNode "some pred key", and PredicateNode "*-IsKeyFlag-*" | |
| 352 | // Nine: 4 ConceptNodes, the PredicateNode "*-TruthValueKey-*", | |
| 353 | // PredicateNode "some pred key", PredicateNode "*-IsKeyFlag-*", | |
| 354 | // the CogStorageNode, and PredicateNode "*-open-*" | |
| 352 | 355 | // -- the preds show up when the attached values are fetched. |
| 353 | printf ("fetched %lu atoms, expecting 8\n", as->get_size()); | |
| 356 | printf ("fetched %lu atoms, expecting 9\n", as->get_size()); | |
| 354 | 357 | // printf("contents=%s\n", as->to_string().c_str()); |
| 355 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 8); | |
| 358 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 9); | |
| 356 | 359 | |
| 357 | 360 | Handle gkey = as->add_node(PREDICATE_NODE, "some pred key"); |
| 358 | 361 | Handle gaf = as->add_node(CONCEPT_NODE, "float node"); |
| … | … | @@ -407,7 +410,7 @@ void ValueSaveUTest::test_link_by_type() |
| 407 | 410 | AtomSpacePtr as = createAtomSpace(); |
| 408 | 411 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 409 | 412 | StorageNodePtr store = StorageNodeCast(hsn); |
| 410 | store->open(); | |
| 413 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 411 | 414 | TS_ASSERT(store->connected()) |
| 412 | 415 | |
| 413 | 416 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -494,7 +497,7 @@ void ValueSaveUTest::test_link_by_type() |
| 494 | 497 | as = createAtomSpace(); |
| 495 | 498 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 496 | 499 | store = StorageNodeCast(hsn); |
| 497 | store->open(); | |
| 500 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 498 | 501 | TS_ASSERT(store->connected()) |
| 499 | 502 | |
| 500 | 503 | // -------------------- |
| … | … | @@ -510,12 +513,12 @@ void ValueSaveUTest::test_link_by_type() |
| 510 | 513 | // The B-nodes are added after the fetch. In either case, |
| 511 | 514 | // there should not be any values fetched for either A or B; |
| 512 | 515 | // only the values on the C-links should be fetched. |
| 513 | // +1 for (PredicateNode "*-IsKeyFlag-*") | |
| 516 | // +1 for (PredicateNode "*-IsKeyFlag-*"), +1 for *-open-* | |
| 514 | 517 | store->fetch_all_atoms_of_type(LIST_LINK); |
| 515 | 518 | store->barrier(); |
| 516 | printf ("fetched %lu atoms, expecting 16\n", as->get_size()); | |
| 519 | printf ("fetched %lu atoms, expecting 17\n", as->get_size()); | |
| 517 | 520 | // printf("contents=%s\n", as->to_string().c_str()); |
| 518 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16); | |
| 521 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 17); | |
| 519 | 522 | |
| 520 | 523 | Handle gbf = as->add_node(CONCEPT_NODE, "b float node"); |
| 521 | 524 | Handle gbt = as->add_node(CONCEPT_NODE, "b string node"); |
| … | … | @@ -616,7 +619,7 @@ void ValueSaveUTest::test_link_by_type_quoted() |
| 616 | 619 | AtomSpacePtr as = createAtomSpace(); |
| 617 | 620 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 618 | 621 | StorageNodePtr store = StorageNodeCast(hsn); |
| 619 | store->open(); | |
| 622 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 620 | 623 | TS_ASSERT(store->connected()) |
| 621 | 624 | |
| 622 | 625 | Handle key = as->add_node(PREDICATE_NODE, "some (\"pred\"))) key"); |
| … | … | @@ -703,7 +706,7 @@ void ValueSaveUTest::test_link_by_type_quoted() |
| 703 | 706 | as = createAtomSpace(); |
| 704 | 707 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 705 | 708 | store = StorageNodeCast(hsn); |
| 706 | store->open(); | |
| 709 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 707 | 710 | TS_ASSERT(store->connected()) |
| 708 | 711 | |
| 709 | 712 | // -------------------- |
| … | … | @@ -722,10 +725,10 @@ void ValueSaveUTest::test_link_by_type_quoted() |
| 722 | 725 | store->fetch_all_atoms_of_type(LIST_LINK); |
| 723 | 726 | store->barrier(); |
| 724 | 727 | |
| 725 | // We created 9 new atoms above, so expect 16 from before plus 9 | |
| 726 | // (+1 for *-IsKeyFlag-*) | |
| 727 | printf ("fetched %lu atoms, expecting 25\n", as->get_size()); | |
| 728 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 25); | |
| 728 | // We created 9 new atoms above, so expect 17 from before plus 9 | |
| 729 | // (+1 for *-IsKeyFlag-*, +1 for *-open-*) | |
| 730 | printf ("fetched %lu atoms, expecting 26\n", as->get_size()); | |
| 731 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 26); | |
| 729 | 732 | |
| 730 | 733 | Handle gbf = as->add_node(CONCEPT_NODE, "b float node"); |
| 731 | 734 | Handle gbt = as->add_node(CONCEPT_NODE, "b string node"); |
| … | … | @@ -829,7 +832,7 @@ void ValueSaveUTest::test_incoming() |
| 829 | 832 | AtomSpacePtr as = createAtomSpace(); |
| 830 | 833 | Handle hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 831 | 834 | StorageNodePtr store = StorageNodeCast(hsn); |
| 832 | store->open(); | |
| 835 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 833 | 836 | TS_ASSERT(store->connected()) |
| 834 | 837 | |
| 835 | 838 | Handle key = as->add_node(PREDICATE_NODE, "some pred key"); |
| … | … | @@ -916,7 +919,7 @@ void ValueSaveUTest::test_incoming() |
| 916 | 919 | as = createAtomSpace(); |
| 917 | 920 | hsn = as->add_node(COG_STORAGE_NODE, std::string(uri)); |
| 918 | 921 | store = StorageNodeCast(hsn); |
| 919 | store->open(); | |
| 922 | store->setValue(as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 920 | 923 | TS_ASSERT(store->connected()) |
| 921 | 924 | |
| 922 | 925 | // -------------------- |
| … | … | @@ -937,8 +940,8 @@ void ValueSaveUTest::test_incoming() |
| 937 | 940 | store->fetch_incoming_set(gal, false); |
| 938 | 941 | store->fetch_incoming_set(gav, false); |
| 939 | 942 | store->barrier(); |
| 940 | // +1 for *-IsKeyFlag-* | |
| 941 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 16); | |
| 943 | // +1 for *-IsKeyFlag-*, +1 for *-open-* | |
| 944 | TSM_ASSERT("Wrong number of Atoms fetched!", as->get_size() == 17); | |
| 942 | 945 | |
| 943 | 946 | Handle gbf = as->add_node(CONCEPT_NODE, "b float node"); |
| 944 | 947 | Handle gbt = as->add_node(CONCEPT_NODE, "b string node"); |