Skip to content

Nested sourced from acceptance test cleanup#1311

Open
ellisandrews-toast wants to merge 5 commits into
mainfrom
nested-sourced-from-acceptance-test-cleanup
Open

Nested sourced from acceptance test cleanup#1311
ellisandrews-toast wants to merge 5 commits into
mainfrom
nested-sourced-from-acceptance-test-cleanup

Conversation

@ellisandrews-toast

Copy link
Copy Markdown
Collaborator

Addresses the review threads on #1252 that remained open after it merged, specifically pertaining to the acceptance tests.

This fills the coverage gaps identified in review — mostly around the __nested_sourced_data buffer's edge cases — and reworks the spec for readability, so that every detail a test's assertions depend on is visible in the test body rather than hidden in helper defaults.

@myronmarston myronmarston left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking good! I left a couple more suggestions that would be good to include when you merge.

source = fetch_team_source("t1")
coaches_by_id = coaches_by_id_in(source)
expect(coaches_by_id.fetch("c1")).to eq("id" => "c1", "name" => "Alice", "salary" => 200)
# The sibling coach was never sourced, so `salary` is absent and applying c1's events leaves it alone.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# The sibling coach was never sourced, so `salary` is absent and applying c1's events leaves it alone.
# c2's profile was never sourced, so `salary` is absent and applying c1's events leaves it alone.

expect(source.fetch(LIST_COUNTS_FIELD)).to include("staff|coaches" => 2)
end

it "ignores a stale (lower-version) source event for an already-sourced nested element" do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
it "ignores a stale (lower-version) source event for an already-sourced nested element" do
it "ignores a stale (event.version <= stored.version) source event for an already-sourced nested element" do


indexer.processor.process([team], refresh_indices: true)
indexer.processor.process([coach_profile_event("c1", 200, id: "prof-c1", version: 5)], refresh_indices: true)
indexer.processor.process([coach_profile_event("c1", 100, id: "prof-c1", version: 2)], refresh_indices: true)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
indexer.processor.process([coach_profile_event("c1", 100, id: "prof-c1", version: 2)], refresh_indices: true)
indexer.processor.process([
coach_profile_event("c1", 100, id: "prof-c1", version: 2), # ignored since 2 <= 5
coach_profile_event("c1", 300, id: "prof-c1", version: 5) # ignored since 5 <= 5
], refresh_indices: true)

To go along with my suggested test description change, would be good to also cover the event.version == stored.version case.

expect(coaches_by_id_in(fetch_team_source("t1")).fetch("c3")).to eq("id" => "c3", "name" => "Dana", "salary" => 300)
end

it "materializes a ghost document from a source event targeting a singleton object path" do

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Elsewhere we call this an "incomplete document" (compare a search for incomplete_doc vs ghost...).

Would be good to use the existing term (here and anywhere else you use that term).

I do kinda like "ghost document" and am open to switching our terminology to it, but I'd want that to be a separate PR.


# The full ghost document: no `staff` (or any other team field) yet--just the identity, bookkeeping,
# and the buffered salary awaiting its target element. The ghost is the one document small enough to
# pin in full, which also pins the `__nested_sourced_data` buffer entry (real docs carry it too--it's

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't understand what "small enough to pin in full" means. In what sense are we "pinning" anything here? And what does document size have to do with it?

I think this paragraph can be de-slopified and shortened significantly.

"21:staff.coaches.profile|5:staff|2:cø|" => {"prof-cø" => 12},
"29:staff.general_manager.profile|5:staff|15:general_manager|" => {"prof-gm1" => 13}
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# The top-level team event has no nested sourced fields, so `__self` should not get added to `__nested_sourced_data` even
# though `__self` shows up in `__versions`.
expect(source.fetch("__nested_sourced_data").keys).to match_array(source.fetch("__versions").except("__self").keys)

This covers the optimization we have have here:

(Without it, I think nothing fails if we remove that guard).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants