-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Handle P2P with SourceHub ACP #2848
feat: Handle P2P with SourceHub ACP #2848
Conversation
Instead of once per node
fb4e41f
to
103a658
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2848 +/- ##
===========================================
- Coverage 79.40% 79.29% -0.11%
===========================================
Files 323 323
Lines 24691 24693 +2
===========================================
- Hits 19604 19578 -26
- Misses 3684 3698 +14
- Partials 1403 1417 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 13 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a few comments
tests/integration/acp.go
Outdated
if acpType == SourceHubACPType { | ||
addedToSourceHub = true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: why not to put in the end of the loop body this:
if acpType == SourceHubACPType {
break
}
todo: and please leave a short comment reminding why we do it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not to put in the end of the loop body this
That would be much nicer lol, thanks 😁
- Simplify addedToSourceHub stuff
testUtils.AddPolicy{ | ||
Identity: immutable.Some(1), | ||
Policy: ` | ||
name: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: this seems like a regular policy and doesn't really improve testing readability. Would be nice to extract it to a const.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to shrug this one off as personal preference, as I prefer it inline - partly so that I can see that it is just a regular policy. I could store it in a var called totallyNormalAndUnimportantUserPolicy
, but that would make me even more suspicious and would cause me to read it even more carefully than if it was inline (and I'd have to bounce around out of the test to do so) :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good! One potential issue to resolve.
internal/db/p2p_replicator.go
Outdated
// TODO-ACP: remove this check/loop after https://github.com/sourcenetwork/defradb/issues/2366 | ||
if col.Description().Policy.HasValue() { | ||
return ErrReplicatorSomeColsHavePolicy | ||
if db.acp.HasValue() && !db.acp.Value().SupportsP2P() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: the switch case above this also checks for a policy (unsure why there is not a todo there). It might be cleaner to combine both checks outside of the switch case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice spot! Yeah I'll pull them both out of the switch and remove one of the error types. Thanks Keenan :)
- replicator error stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely work, finally ties a lot of pieces together.
Just left some todos and questions. Please resolve before merge.
acp/README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Would be nice to add a complete p2p flow example using sourcehub acp below under a new heading called Sourcehub P2P
or something, similar to how we have other examples in this README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that is too lengthy to include in this document and it will help drown out the information currently contained within it.
// This test documents that we don't allow adding p2p collections that have a policy | ||
// until the following is implemented: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: Still makes sense to have the comment that this test documents that we don't allow adding p2p collections that have a policy for local acp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will delete the test
- Delete test
@@ -110,6 +111,12 @@ func addPolicyACP( | |||
|
|||
expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError) | |||
assertExpectedErrorRaised(s.t, s.testCase.Description, action.ExpectedError, expectedErrorRaised) | |||
|
|||
// The policy should only be added to a SourceHub chain once - there is no need to loop through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: What happens if a node tries to re-add the same exact policy ? Guessing it will output a new policyID and still add the policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That has not changed, the test framework will still attempt to re-add the policy.
// until the following is implemented: | ||
// TODO-ACP: ACP <> P2P https://github.com/sourcenetwork/defradb/issues/2366 | ||
func TestACP_P2POneToOneReplicatorWithPermissionedCollection_Error(t *testing.T) { | ||
func TestACP_P2POneToOneReplicatorWithPermissionedCollection_LocalACP(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: I like the documentation on what the test does (can just add that its for local acp case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think it is worth the eye/brain-space here. This one-liner should have been in the description, and I have a large dislike for the description prop as they are very often misleading.
It will save us time in the long run to let the test definition define itself.
testUtils.AddPolicy{ | ||
Identity: immutable.Some(1), | ||
Policy: ` | ||
name: test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy as is
Relevant issue(s)
Resolves #2366
Description
Handles P2P with SourceHub ACP.
Local ACP remains blocked off, as documents synced would essentially become public unless encrypted.
The testing assumes that a distributed SourceHub chain would be tested in the SourceHub repo, and so it doesn't bother spinning up a chain per node and dealing with SourceHub sync stuff. Long term we'll want some Defra-based testing around this, but I think we can get away without it. Feel very free to argue against this :)