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
DS-4499 Fix cleanup of test environment in earlier Integration Test #2759
DS-4499 Fix cleanup of test environment in earlier Integration Test #2759
Conversation
…flowItemRestRepositoryIT
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 have added some inline comments to facilitate the review by other. @Micheleboychuk are going to resolve the conflict and verify that travis complete successful, once done I will remove the work in progress label
dspace-server-webapp/src/test/java/org/dspace/app/rest/builder/AbstractDSpaceObjectBuilder.java
Outdated
Show resolved
Hide resolved
@@ -138,6 +138,8 @@ public void postCommunityAdminGroupCreateAdminGroupSuccess() throws Exception { | |||
.andDo(result -> idRef | |||
.set(UUID.fromString(read(result.getResponse().getContentAsString(), "$.id"))) | |||
); | |||
// no needs to explicitly cleanup the group created as the community comes |
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.
for other reviewers please note this comment as it explains the need of the refactoring done in all the Builder about the cleanup process
collectionService.removeAdministrators(c, collection); | ||
try (Context c = new Context()) { | ||
c.turnOffAuthorisationSystem(); | ||
collection = c.reloadEntity(collection); |
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.
This is a comment for other reviewers to explain the reasoning behind this change (and the same in all the other builder).
It is better to reload the primary object as this will guarantee us to access also fresh related objects during the cleanup, in this case the Admin Group.
Before, all the related objects where reloaded just before to be deleted (see previous implementeation of the deleteWorkflowGroups) but this approach have several issues:
- it is easy to forget about it, indeed when the deleteAdminGroup method was added the first time the build was failing due to that
- doing that manually each time duplicate lot of code
- as you only reload the object that was attached to the "old" copy of the primary object you will fail to find related object created in outside thread. If the admin group has been created via a REST call collection.getAdministrators() run before the refresh of the community object would have returned null
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.
Just a minor comment, I wonder if we should add a small inline comment here to remind ourselves why the reloadEntity
is necessary. That way we don't accidentally refactor it out at a later time.
We could just say:
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
it is ready to review now. A nice side effect of the refactoring seems to be an increased speedup in the test execution. The server tests took 12minutes less compared to the last build on the master |
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.
@Micheleboychuk and @abollini : This looks great overall. I only have a few minor comments inline, and then I'd add a +1. See below.
@@ -1523,6 +1535,8 @@ public void patchMultipleOperationsWithFailure() throws Exception { | |||
.withEmail("Johndoe@example.com") | |||
.build(); | |||
|
|||
context.restoreAuthSystemState(); | |||
|
|||
String token = getAuthToken(admin.getEmail(), password); | |||
|
|||
context.restoreAuthSystemState(); |
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.
It looks like there's accidentally two context.restoreAuthSystemState()
calls in this method now. This second one can be removed.
@@ -67,4 +76,20 @@ public Bundle build() throws SQLException, AuthorizeException { | |||
|
|||
return bundle; | |||
} | |||
|
|||
public static void deleteBundel(UUID uuid) throws SQLException, IOException { |
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.
This method is misspelled. It should be deleteBundle
. Obviously, you'll need to also cleanup the places it's used in ITs.
collectionService.removeAdministrators(c, collection); | ||
try (Context c = new Context()) { | ||
c.turnOffAuthorisationSystem(); | ||
collection = c.reloadEntity(collection); |
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.
Just a minor comment, I wonder if we should add a small inline comment here to remind ourselves why the reloadEntity
is necessary. That way we don't accidentally refactor it out at a later time.
We could just say:
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
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.
👍 This looks good to me now! Thanks @Micheleboychuk and @abollini , as I think these are great improvements...and it's wonderful to hear it also significantly improves the time it takes for the tests to complete.
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.
Can you add detail about the changes:
- Why is it now required to explicitly delete e.g. items from a builder, this used to be automated
- What's the purpose of
.andDo(result -> idRef.set(read(result.getResponse().getContentAsString(), "$.id")))
- What's the purpose of
.andDo(result -> idRefNoEmbeds.set(UUID.fromString(read(result.getResponse().getContentAsString(), "$.id"))))
dspace-server-webapp/src/test/java/org/dspace/app/rest/builder/BitstreamBuilder.java
Show resolved
Hide resolved
dspace-server-webapp/src/test/java/org/dspace/app/rest/builder/BundleBuilder.java
Show resolved
Hide resolved
hi @benbosman
this is not required, no changes in such direction. If we have added an explicit deletion of an item created with an item builder this is most probably superfluous. Can you point to the specific line so that I can eventually double check?
in general they are used to grab the ID of object created via REST request so that they can be cleaned later. Do you have any specific lines that I need to double check? |
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.
Thanks @abollini for the feedback. This looks good to me
I haven't tested it, but since it only affects ITs and Travis succeeds, it shouldn't be a problem
References
https://jira.lyrasis.org/browse/DS-4499
Description
*All IT classes have been reviewed and where the context.restoreAuthSystemState() was missing, it has been added.
*Objects that were not used have been removed.
*Refactoring of the cleanup method in the Builder classes has been done.
Checklist
This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!
400 Bad Request
,401 Unauthorized
,403 Forbidden
,404 Not Found
, etc)pom.xml
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.