-
-
Notifications
You must be signed in to change notification settings - Fork 859
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
Federation tests replication round1 - demonstrate absent replication of comment deletes #3657
Changes from 8 commits
fb7df85
83cdac2
7bd3b20
7dfb6ee
0384675
9f742e2
9769721
71d5ae7
5cd2852
a72590b
6c74f9f
fb32d19
24f3d02
bdb7381
46b7e6a
a3658a9
9cb9ca3
4e741fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,22 +112,59 @@ test("Update a comment", async () => { | |
}); | ||
|
||
test("Delete a comment", async () => { | ||
// creating a comment on alpha (remote from home of community) | ||
let commentRes = await createComment(alpha, postRes.post_view.post.id); | ||
|
||
// Find the comment on beta (home of community) | ||
let betaComment = ( | ||
await resolveComment(beta, commentRes.comment_view.comment) | ||
).comment; | ||
|
||
if (!betaComment) { | ||
throw "Missing beta comment before delete"; | ||
} | ||
|
||
// Find the comment on gamma | ||
// This is testing replication from remote-home-remote (alpha-beta-gamma) | ||
let gammaComment = ( | ||
await resolveComment(gamma, commentRes.comment_view.comment) | ||
).comment; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isnt really testing replication. If the comment failed to be federated, resolve will fetch it instead. You could instead use resolvePost and then getComments for that post to check if its included there. Or add a new getComments variant which retrieves all newest comments for the whole instance.
This comment was marked as abuse.
Sorry, something went wrong. |
||
|
||
if (!gammaComment) { | ||
throw "Missing gamma comment (remote-home-remote replication) before delete"; | ||
} | ||
|
||
let deleteCommentRes = await deleteComment( | ||
alpha, | ||
true, | ||
commentRes.comment_view.comment.id, | ||
); | ||
expect(deleteCommentRes.comment_view.comment.deleted).toBe(true); | ||
|
||
// Make sure that comment is undefined on beta | ||
// Make sure that comment is undefined on beta after delete | ||
let betaCommentRes = (await resolveComment( | ||
beta, | ||
commentRes.comment_view.comment, | ||
)) as any; | ||
if (betaCommentRes) { | ||
console.log(betaCommentRes.comment); | ||
} | ||
expect(betaCommentRes.error).toBe("couldnt_find_object"); | ||
|
||
// Make sure that comment is undefined on gamma after delete | ||
// This is testing replication from remote-home-remote (alpha-beta-gamma) | ||
let gammaCommentRes = (await resolveComment( | ||
gamma, | ||
commentRes.comment_view.comment, | ||
)) as any; | ||
if (gammaCommentRes) { | ||
if (gammaCommentRes.comment) { | ||
console.log("gamma has deleted comment", gammaCommentRes.comment.comment); | ||
} | ||
} | ||
expect(gammaCommentRes.error).toBe("couldnt_find_object"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay turns out its like I mentioned in my other comment, the problem is in activity_lists.rs. Removing the line
This comment was marked as abuse.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI the way to debug this is by looking at the Lemmy logs in |
||
|
||
// Test undeleting the comment | ||
let undeleteCommentRes = await deleteComment( | ||
alpha, | ||
false, | ||
|
@@ -227,17 +264,39 @@ test("Remove a comment from admin and community on different instance", async () | |
|
||
test("Unlike a comment", async () => { | ||
let commentRes = await createComment(alpha, postRes.post_view.post.id); | ||
|
||
// Lemmy automatically creates 1 like (vote) by author of comment. | ||
// Make sure that comment is liked (voted up) on gamma, downstream peer | ||
// This is testing replication from remote-home-remote (alpha-beta-gamma) | ||
let gammaComment1 = ( | ||
await resolveComment(gamma, commentRes.comment_view.comment) | ||
).comment; | ||
expect(gammaComment1).toBeDefined(); | ||
expect(gammaComment1?.community.local).toBe(false); | ||
expect(gammaComment1?.creator.local).toBe(false); | ||
expect(gammaComment1?.counts.score).toBe(1); | ||
|
||
let unlike = await likeComment(alpha, 0, commentRes.comment_view.comment); | ||
expect(unlike.comment_view.counts.score).toBe(0); | ||
|
||
// Make sure that post is unliked on beta | ||
// Make sure that comment is unliked on beta | ||
let betaComment = ( | ||
await resolveComment(beta, commentRes.comment_view.comment) | ||
).comment; | ||
expect(betaComment).toBeDefined(); | ||
expect(betaComment?.community.local).toBe(true); | ||
expect(betaComment?.creator.local).toBe(false); | ||
expect(betaComment?.counts.score).toBe(0); | ||
|
||
// Make sure that comment is unliked on gamma, downstream peer | ||
// This is testing replication from remote-home-remote (alpha-beta-gamma) | ||
let gammaComment = ( | ||
await resolveComment(gamma, commentRes.comment_view.comment) | ||
).comment; | ||
expect(gammaComment).toBeDefined(); | ||
expect(gammaComment?.community.local).toBe(false); | ||
expect(gammaComment?.creator.local).toBe(false); | ||
expect(gammaComment?.counts.score).toBe(0); | ||
}); | ||
|
||
test("Federated comment like", async () => { | ||
|
@@ -515,31 +574,63 @@ test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde | |
}); | ||
|
||
test("Report a comment", async () => { | ||
let betaCommunity = (await resolveBetaCommunity(beta)).community; | ||
let betaCommunityRes = await resolveBetaCommunity(beta); | ||
// ToDo: this does not check for JSON { error: "message" } | ||
let betaCommunity = betaCommunityRes?.community; | ||
if (!betaCommunity) { | ||
throw "Missing beta community"; | ||
} | ||
let postRes = (await createPost(beta, betaCommunity.community.id)).post_view | ||
.post; | ||
expect(postRes).toBeDefined(); | ||
let commentRes = (await createComment(beta, postRes.id)).comment_view.comment; | ||
expect(commentRes).toBeDefined(); | ||
|
||
let alphaComment = (await resolveComment(alpha, commentRes)).comment?.comment; | ||
// NOTE: createPost tests outbound Internet connection | ||
let betaPost = await createPost(beta, betaCommunity.community.id); | ||
// let betaPost = await createNoLinkPost(beta, betaCommunity.community.id); | ||
expect(betaPost.post_view?.post).toBeDefined(); | ||
// ToDo: not enough of a test, "{ error: 'couldnt_send_webmention' }" passes | ||
let createCommentRes = await createComment(beta, betaPost.post_view.post.id); | ||
expect(createCommentRes?.comment_view?.comment).toBeDefined(); | ||
let commentRes = createCommentRes.comment_view.comment; | ||
|
||
let alphaCommentRes = await resolveComment(alpha, commentRes); | ||
let alphaComment = alphaCommentRes?.comment?.comment; | ||
// ToDo: this does not check for JSON { error: "message" } | ||
if (!alphaComment) { | ||
throw "Missing alpha comment"; | ||
} | ||
|
||
let alphaReport = ( | ||
await reportComment(alpha, alphaComment.id, randomString(10)) | ||
).comment_report_view.comment_report; | ||
|
||
let betaReport = (await listCommentReports(beta)).comment_reports[0] | ||
.comment_report; | ||
expect(alphaCommentRes?.comment?.comment).toBeDefined(); | ||
|
||
// For the sake of completeness, also confirm Gamma has the comment before later checking if reported. | ||
// This raises an issue with replication design: gamma has only resolved the comment, it did not have anyone subscribe and join that community. | ||
// Or is that automatically done by beforeAll function? | ||
// Should this test be using more normal getComments instead of resolveComment? | ||
let gammaCommentRes = await resolveComment(gamma, commentRes); | ||
// ToDo: this does not check for JSON { error: "message" } | ||
expect(gammaCommentRes?.comment?.comment).toBeDefined(); | ||
|
||
// Alpha will report the comment (reminder that the comment was made on beta, so this is a remote action). | ||
let alphaReportRes = await reportComment(alpha, alphaComment.id, randomString(10)); | ||
// ToDo: this does not check for JSON { error: "message" } | ||
expect(alphaReportRes?.comment_report_view?.comment_report).toBeDefined(); | ||
let alphaReport = alphaReportRes.comment_report_view.comment_report; | ||
|
||
let betaReports = await listCommentReports(beta); | ||
expect(betaReports?.comment_reports?.length).toBe(1); | ||
let betaReport = betaReports.comment_reports[0].comment_report; | ||
expect(betaReport).toBeDefined(); | ||
expect(betaReport.resolved).toBe(false); | ||
expect(betaReport.original_comment_text).toBe( | ||
alphaReport.original_comment_text, | ||
); | ||
expect(betaReport.reason).toBe(alphaReport.reason); | ||
|
||
// This is testing replication from remote-home-remote(s) (alpha-beta-gamma) | ||
// The sitaution could be that a remote moderator is on Gamma and needs to see the report in doing their moderator duty. | ||
let gammaReports = await listCommentReports(gamma); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably fails because report is not announcable, so it will only go to the community instance but not anywhere else.
This comment was marked as abuse.
Sorry, something went wrong. |
||
expect(gammaReports?.comment_reports?.length).toBe(1); | ||
let gammaReport = gammaReports.comment_reports[0].comment_report; | ||
expect(gammaReport).toBeDefined(); | ||
expect(gammaReport.resolved).toBe(false); | ||
expect(gammaReport.original_comment_text).toBe( | ||
alphaReport.original_comment_text, | ||
); | ||
expect(gammaReport.reason).toBe(alphaReport.reason); | ||
}); |
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.
Without this there were still lemmy processes left running after tests completed.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
Sorry, something went wrong.