-
Notifications
You must be signed in to change notification settings - Fork 175
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
Integration Tests for s3-sink related to Github-issue#1048 #2401
Integration Tests for s3-sink related to Github-issue#1048 #2401
Conversation
Signed-off-by: Deepak Sahu <deepak.sahu562@gmail.com>
Collection<Record<Event>> records = setEventQueue(); | ||
s3SinkService.processRecods(records); | ||
s3SinkService.accumulateBufferEvents(s3SinkWorker); | ||
assertNotNull(recordsGenerator); |
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 is this being done here? You should check the impact of the previous statement here.
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.
Modified asserting "not null" for the records instead of recordsGenerator.
March'2023. Signed-off-by: Deepak Sahu <deepak.sahu562@gmail.com>
Signed-off-by: Deepak Sahu <deepak.sahu562@gmail.com>
Collection<Record<Event>> records = setEventQueue(); | ||
s3SinkService.processRecords(records); | ||
s3SinkService.accumulateBufferEvents(s3SinkWorker); | ||
verify(s3SinkService, atLeastOnce()).processRecords(records); |
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.
Please validate if accumulateBufferEvents() worked correctly by checking its functionality. This verification is not that useful
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 made a few comments. At a high-level, the integration test should work this way.
- Create the object under test. This is
S3Sink
itself. Use real objects only. (You can mock the input config classes, that is acceptable). - Generate a bunch of Events, and wrap them in Records.
- Call
objectUnderTest.output(events)
- Perform an S3 list request to get the actual object created. Hint: In step 1, You can configure the
key_prefix
to use a unique value in each test. Then you can list using that prefix and the work is quite easy. - Verify you found the S3 object
- Read the S3 object
- Verify the actual data inside the S3 object.
That is the basic overview of any test. You may have some different variations as well. One example might be calling output
without enough records to write. Or calling output
twice when two calls are needed to write.
|
||
RecordsGenerator recordsGenerator = new JsonRecordsGenerator(); | ||
assertNotNull(recordsGenerator); | ||
S3SinkWorker s3SinkWorker = new S3SinkWorker(s3Client, s3SinkConfig, recordsGenerator.getCodec(), |
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.
We should move this up to testing the S3Sink
class itself.
In the S3 source, you will see that we have two sets of tests. This is in part because there are two very significant components involved in the source - S3 and SQS. This is not the case here. So testing only the sink is ideal.
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.
Resolved.
@Test | ||
void copy_s3_object_correctly_into_s3_bucket() { | ||
|
||
RecordsGenerator recordsGenerator = new JsonRecordsGenerator(); |
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.
These two lines of code are not providing any value. You can remove them.
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.
Removed two unused files related to RecordsGenerator
and JsonRecordsGenerator
.
import com.fasterxml.jackson.core.JsonFactory; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
|
||
class JsonRecordsGenerator implements RecordsGenerator { |
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 don't need this class. The S3 sink is responsible for generating the JSON - not the test.
You may want to have a JsonRecordsReader
which can read an actual object from S3.
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.
Removed two unused files related to RecordsGenerator
and JsonRecordsGenerator
.
s3Client = S3Client.builder().region(Region.of(System.getProperty("tests.s3source.region"))).build(); | ||
String bucket = System.getProperty("tests.s3source.bucket"); | ||
|
||
s3SinkConfig = mock(S3SinkConfig.class); |
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 an integration test and should not be using mocks. Please create real objects.
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.
Created real objects except for s3SinkConfig
class.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #2401 +/- ##
============================================
- Coverage 93.39% 93.26% -0.14%
+ Complexity 2093 2090 -3
============================================
Files 247 247
Lines 5861 5861
Branches 478 478
============================================
- Hits 5474 5466 -8
- Misses 262 271 +9
+ Partials 125 124 -1 see 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Deepak Sahu <deepak.sahu562@gmail.com>
int s3ObjectCountAfterIngest = gets3ObjectCount(); | ||
|
||
Assert.assertNotSame(s3ObjectCountBeforeIngest, s3ObjectCountAfterIngest); | ||
assertThat(s3ObjectCountAfterIngest, greaterThan(s3ObjectCountBeforeIngest)); |
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 greaterThan
? Is it not possible to know the exact count?
Description
Integration tests for #1048
Issues Resolved
Resolves: Integration tests for #1048
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.