Commit Graph

10112 Commits

Author SHA1 Message Date
Antonio Scandurra
369d85b82e Print RepoId as a number in tests
We are not going to generate repository ids randomly, so we can
take advantage of that and print a nicer representation of
the repository id.

Co-Authored-By: Julia Risley <julia@zed.dev>
2023-07-25 15:33:14 +02:00
Antonio Scandurra
cbdb83fb43 Extract test operation generation and application into methods
Co-Authored-By: Julia Risley <julia@zed.dev>
2023-07-25 15:25:54 +02:00
Antonio Scandurra
309e307fa8 Remove warning
Co-Authored-By: Julia Risley <julia@zed.dev>
2023-07-25 15:25:40 +02:00
Antonio Scandurra
e9342e1b47 Deterministically assign repo IDs in tests 2023-07-25 15:10:16 +02:00
Antonio Scandurra
edc63ee3ff Avoid panicking when previous stack trace doesn't have the same length 2023-07-25 15:10:16 +02:00
Antonio Scandurra
88829dfe21 Use test-support feature for collections in dev 2023-07-25 15:10:13 +02:00
Antonio Scandurra
1ada3722e5 Avoid creating empty document fragments 2023-07-25 12:40:50 +02:00
Antonio Scandurra
1e644b7a45 Keep insertion fragments up-to-date 2023-07-25 12:02:13 +02:00
Antonio Scandurra
eb36bc5b62 Use preceding fragment when edit starts at the beginning of a fragment 2023-07-25 11:27:43 +02:00
Antonio Scandurra
31f84cef14 Broadcast operations when synchronizing with the server 2023-07-25 10:05:59 +02:00
Antonio Scandurra
9358958b1f Observe lamport timestamps when applying operations 2023-07-25 09:58:38 +02:00
Antonio Scandurra
bbe126818f Avoid skipping sentinel as it'll happen organically when applying edit 2023-07-25 09:51:56 +02:00
Antonio Scandurra
7d02462abd Broadcast operations only after server acknowledges them
There was a test failure that was caused by the following sequence of
events:

1. Client 1 generates an operation and broadcasted it.
2. Client 2 joins, but it was too late to receive the operation from the network.
3. Client 2 synchronizes with the server, but it was too early to receive
operations from the server.
4. Client 1 finally sends the operation to the server.
2023-07-24 17:53:01 +02:00
Antonio Scandurra
fa48d59de4 Generate edit operation correctly when range is at the end of fragment 2023-07-24 16:55:17 +02:00
Antonio Scandurra
439f6ba616 Use end fragment to determine the new insertion's fragment location 2023-07-24 16:46:43 +02:00
Antonio Scandurra
729ea89fef Create room before inserting repo into database
This ensures that clones of the repo will either see the repo and
be able to join the room, or not see the repo at all.
2023-07-24 16:40:09 +02:00
Antonio Scandurra
8c5eab6933 Assert branches are the same between client and server 2023-07-24 16:24:43 +02:00
Antonio Scandurra
5118218a9c Start on a randomized test for CRDB 2023-07-24 15:16:57 +02:00
Antonio Scandurra
3dee2faa44 Assign a valid location after intersecting fragments 2023-07-23 18:51:21 +02:00
Antonio Scandurra
c1f72328ff Avoid taking fragment when not fully consuming it 2023-07-23 18:50:57 +02:00
Antonio Scandurra
18b32304e2 Serialize message envelope instead of directly serializing operation 2023-07-23 18:49:54 +02:00
Nathan Sobo
3920bff5e0 WIP: Add a test for relaying edits between clients
Still not passing, but added:

- Connect the network room before creating checkouts.
- Blow up in tests when there are errors applying operations on the server.
- Avoid overshooting the last fragment when in fragment_locations.
2023-07-21 22:21:53 -06:00
Nathan Sobo
b7e79d5241 Get basic test of repository cloning working 2023-07-21 14:31:11 -06:00
Antonio Scandurra
a81fde36e0 WIP 2023-07-21 19:52:27 +02:00
Antonio Scandurra
60f5dca222 Rework operations::Edit::apply
It still doesn't work but it's in a coherent state now at least.
2023-07-21 19:32:26 +02:00
Antonio Scandurra
45037eb7a0 WIP 2023-07-21 16:55:31 +02:00
Antonio Scandurra
4e085a6f2d Apply operations only via revision 2023-07-21 12:00:38 +02:00
Antonio Scandurra
517d073806 Remove unused use statement 2023-07-21 11:28:19 +02:00
Antonio Scandurra
cbc4b90df8 Apply missing operations to the common ancestor revision
Interestingly, when applying an `Edit` operation, we need to know the
parent revision, which makes the `revision` method recursive.
2023-07-21 11:19:00 +02:00
Antonio Scandurra
1ddd3971d8 Use the new RepoSnapshot::revision method 2023-07-21 10:50:00 +02:00
Antonio Scandurra
939eaaa973 💄 2023-07-21 10:35:19 +02:00
Antonio Scandurra
baf06043cb Reify a RevisionId struct 2023-07-21 10:30:28 +02:00
Antonio Scandurra
12acc7418e Refine finding of common ancestor revision and find missing operations 2023-07-21 09:44:17 +02:00
Nathan Sobo
02ea88aa51 Start on a RepoSnapshot::revision method to find/construct a revision from an id 2023-07-20 21:38:53 -06:00
Antonio Scandurra
9d04228853 Add document_id to Edit operation 2023-07-20 17:45:31 +02:00
Antonio Scandurra
56b1aaa6cb WIP: start on Edit::apply 2023-07-20 14:23:51 +02:00
Antonio Scandurra
e771ede830 Test accessing branches and documents from a different client 2023-07-20 14:12:34 +02:00
Antonio Scandurra
55232486d7 Remove ancestors of the new operation from the head revision 2023-07-20 13:43:03 +02:00
Antonio Scandurra
8c1973c5a2 Make CreateDocument infallible 2023-07-20 13:12:44 +02:00
Antonio Scandurra
287dfc0460 Take a revision instead of a repo snapshot when applying branch ops 2023-07-20 13:11:07 +02:00
Antonio Scandurra
4a8556cd81 Save operation in the DAG only when we're able to apply it 2023-07-20 12:56:46 +02:00
Antonio Scandurra
900deaab50 Apply CreateBranch and CreateDocument operations 2023-07-20 11:56:22 +02:00
Antonio Scandurra
30bac17749 Save deferred operation ids only and store operations separately 2023-07-20 09:17:55 +02:00
Nathan Sobo
d675f10447 Flush deferred operations 2023-07-19 22:37:56 -06:00
Nathan Sobo
b774d83a50 Map sum_tree types to crdb::btree::{Map, Set, Sequence} 2023-07-19 15:49:52 -06:00
Nathan Sobo
b636398093 WIP 2023-07-19 15:38:16 -06:00
Nathan Sobo
88c46e091e Defer operations when their parent is missing 2023-07-19 15:28:22 -06:00
Antonio Scandurra
8003e84d11 WIP 2023-07-19 19:41:12 +02:00
Antonio Scandurra
2c27e875e5 Move apply_operations to Repo
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
2023-07-19 19:40:58 +02:00
Antonio Scandurra
9e03e9d6df Sketch in a bi-directional sync (not yet tested) 2023-07-19 10:25:18 -06:00