Skip to content

Added users deletion at the end of tests#240

Merged
asisayag2 merged 1 commit into
masterfrom
fix/fix_tests_user_deletion
Aug 3, 2021
Merged

Added users deletion at the end of tests#240
asisayag2 merged 1 commit into
masterfrom
fix/fix_tests_user_deletion

Conversation

@asisayag2
Copy link
Copy Markdown
Contributor

Today, we have failing tests that are caused from users that are created during build time and are not cleaned-up for some reason.
For reducing the probability of this to happen, I added a delete user call at the end of every relevant test.
In addition, the TearDown also cleans up users in case some of them were skipped/failed during the test itself.


@AfterClass
public static void tearDownClass() {
System.out.println("Start TearDownClass");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe use logger or completely remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added on purpose so we have better visibility if the teardown happened or not. This for trying and catch the instances where users are not being cleaned-up.
It needs to be sent to the Travis log and system.out.println is the way.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TearDown must always happen, unless there was a complete disaster and the process just died.
I find this print completely redundant. you can check it in this branch, I would avoid committing it to master.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the thing... it doesn't always happen. This is why we have leftovers that blocks the testing account.
I added this so the next time it'll happen, we can track if the tearDown happened or not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok

e.printStackTrace();
}
}
System.out.println("### Deleted - SubAccounts:"+createdSubAccountIds.size()+", Users:"+createdUserIds.size()+ ", UserGroups:"+createdGroupIds.size());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe use logger or completely remove this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same here... will help us track why it's sometimes not cleaning up

assertTrue("User2 id should be in the result set", returnedIds.contains(id2));
assertTrue("User1 id should be in the result set", returnedIds.contains(user1Id));
assertTrue("User2 id should be in the result set", returnedIds.contains(user2Id));
deleteUser(user1Id);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

putting deleteUser before assertions would provide a better chance for it to happen, like you perform request, then delete user, then assert results

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What has better chances to happen?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you put deleteUser(user1Id); before all assertions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understood what you suggested, but couldn't figure out why is that better?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it is better because because deleteUser(user1Id) will happen even if assertion fails, so we perform cleanup any way.
Not critical.

@patrick-tolosa
Copy link
Copy Markdown
Contributor

@asisayag2 This looks much better now, the only instance in one test that failed in Travis is unrelated:

com.cloudinary.test.UploaderTest > testEvalUploadParameter FAILED
    java.lang.RuntimeException: General Error`

but this is one build instance out of 20 that failed, looks like a timeout.

@asisayag2 asisayag2 merged commit 27daaf7 into master Aug 3, 2021
@asisayag2 asisayag2 deleted the fix/fix_tests_user_deletion branch August 3, 2021 13:30
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.

3 participants