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
test: ITStorage cleanup #439
Conversation
Codecov Report
@@ Coverage Diff @@
## master #439 +/- ##
=========================================
Coverage 63.15% 63.15%
- Complexity 610 619 +9
=========================================
Files 32 32
Lines 5133 5133
Branches 490 489 -1
=========================================
Hits 3242 3242
Misses 1726 1726
Partials 165 165 Continue to review full report at Codecov.
|
// Prepare KMS KeyRing for CMEK tests | ||
prepareKmsKeys(); | ||
} | ||
|
||
@Before | ||
public void beforeEach() { | ||
private static void unsetRequesterPays() { |
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 leave as-is with Before
annotation? Otherwise it can be easily missed when new requester pays tests are added.
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.
@frankyn
The purpose of @Before
annotation here is to invoke the method to mend the shared BUCKET
after requester-pays tests before each test. With this cleanup fix, all the requester-pays tests are "moved" to their dedicated folder, it's no longer required to mend the BUCKET
.
Actually, it's not absolutely necessary to invoke unsetRequesterPays
before requester-pays tests, these tests will work without it. Invocation is only needed to make setRequesterPays(true)
change the value from not true
to true
. So it's not critical if a new requester-pays test misses calling unsetRequesterPays()
.
Generic question. I wrote a utility to run IT cases individually. With a very small change, it could be applied not to ITStorageTest but to any IT test based on JUnit. Not a masterpiece, but could be helpful in the future. Does it make sense to integrate this somewhere:
|
Why do you think the test methods are connected? Where is the shared state? |
@@ -150,6 +149,7 @@ | |||
Metadata.Key.of("x-goog-request-params", Metadata.ASCII_STRING_MARSHALLER); | |||
private static final Logger log = Logger.getLogger(ITStorageTest.class.getName()); | |||
private static final String BUCKET = RemoteStorageHelper.generateBucketName(); |
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.
You might simply need more instance variables and fewer static ones. BUCKET should probably be an instance variable.
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.
BUCKET is a constant standing for a bucket name shared across multiple tests. There is no problem with sharing variables within the VM, some but cases might intersect using a shared resource in the Storage.
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.
yes, and that's why we should use a fresh bucket for each test. I think getting a new name each time will suffice.
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.
Yes, a fresh bucket per test will certainly help, but I'm not sure we can afford to create so many buckets. ITStorageTest often fails because of exceeded rate limit to bucket creation
Test methods should not be connected, but sometimes there are. I found two storage tests that checked that a bucket property set to There could be other non-trivial dependencies between tests which not easy to catch. They could start failing unexpectedly when the test execution order changes. |
@dmitry-fa This is a real YAGNI. If the test methods are coupled, that's what needs to be fixed. Starting up a new VM for each test is way too heavyweight and still won't address the most likely case of test coupling here: shared tests resources outside the VM in the filesystem or GCS. |
@elharo The suggested utility is not a replacement of the current test execution, it's a tool to discover the coupled tests. It could be run from time to time. And my question does it make sense to integrate it somewhere? |
Current changes look reasonable to me. I'm not sure about the additional utility though. This also fixes a mismatch between temporary and eventbased hold in a clean up step. |
The following changes have been done:
testListBlobRequesterPays
,testUpdateBucketRequesterPays
- make independent from other teststestAttemptDeletionObjectTemporaryHold
- restoring operation correctedtestBucketAcl
,testUpdateBucketRequesterPays
,testBucketPolicyV1RequesterPays
- updated to use the dedicated bucketFixes: #409