Closed evomimic closed 4 months ago
The goal of this test step is to ensure the actual holons retrieved from the persistent store in this step match the expected holons accumulated during prior steps in this test case. Some challenges have arisen during the design and implementation of this enhancement.
Two questions arise:
match_db_content
test step?There are two sets of holons that are candidates for the expected holons set:
commit
steps within the test case execution. In the current implementation of this issue, the execute_commit
function was enhanced to accumulated saved holons in test_state.created_holons
. However, the holons in neither set will exactly match the holons in the actual_holons
set.
actual_holons
, when retrieved in the match_db_content
step will be in a Fetched
state and will have saved_node
populated. fixture holons
will NOT have saved_node
populated and will be in a New
state.created holons
will have saved_node
populated, but will be in a Saved
state.test_state.created_holons
as the expected holons.For the first part of the proposal...
essential_content(&self)
method for Holon that returns an EssentialHolonContent
struct:pub struct EssentialHolonContent {
pub property_map: PropertyMap,
pub relationship_map: RelationshipMap,
key: Option<MapString>,
pub errors: Vec<HolonError>,
}
Note that EssentialHolonContent
excludes saved_node
and the Holon's state variables.
Use this struct when matching expected and actual holons:
assert_eq!(expected_holon.essential_content(), actual_holon.essential_content())
The second part of the proposal is a bit trickier, because it needs to take into account:
The exact design for handling these cases is TBD.
We could have the DancesTestCase contain the fixture holons
saved _node
part is tricky (we could at least check that it exists upon commit)execute_commit
that it is Saved
The second part of the proposal is a bit trickier, because it needs to take into account:
multiple commits, partial commits (where some staged_holons are successfully saved and others are not), recommits where staged holons that had errors in one commit are corrected and then successfully saved as a result of a subsequent commit.
Perhaps this should be a separate issue? @evomimic
Go ahead with fixture based approach.
Actually may not need to add to the fixture.. EssentialHolonContent fixed the issue since execute_match_db_content takes a mutable reference to test_case and can get 'expected_holons' from the test_case.created_holons. A cautionary note is that this is possible because this is the last step in the order (it's worth noting that maybe this could be pulled out into the test file itself - it all depends on whether other steps would come after it and need to access the 'created_holons" field, in which case we we need a top level Vec to push to after each commit step)
@evomimic pushed changes, test as is passes.
As currently, coded the complications noted above have not been addressed:
But the fix for these probably won't involve the execute_match_db_content logic per se. The changes will need to be the other test step execution functions. So I'm OK with this as coded for now.
The match_db_count step is failing while attempting the get_holon_by_id dance. The source of the error seems to be on guest-side code. To aid debugging this, I approved PR #82 and intend to approve PR #72, so we can use guest-side tracing to help debug the issue.
This enhancement delivers the
get_holon_by_id
dance and thematch_db_content
test step. The latter allows expected database content to be compared against actual database content. It can be used at various stages within a test case. Theget_holon_by_id
dance is used to implement thematch_db_content
test step and therefore, is tested by that step (without needing to introduce a separateget_holon_by_id
test step).Current State
In order to compare expected vs. actual db content, we need some way of accumulating the set of expected holons that have been committed within a test case. Issue #69 also enhanced the commit dance function to return the set of Holons created by that commit, but the test_commit function is not currently doing anything with those results.
The get_all_holons dance gets ALL of the holons in the database. To provide the ability to match content for a subset of holons, we need the ability to retrieve individual holons. The
get_holon_by_id
dance is one we need anyway, so we will bundle the introduction of that dance into this enhancement.Proposal
Dances Zome
Holons Adapter
build_get_holon_by_id_dance_request
function for the above danceEnhance Dance Testing
test_match_db_content.rs
file.