PLUGIN-498 Add integration test for GCS Sink/Multisink content type#1083
PLUGIN-498 Add integration test for GCS Sink/Multisink content type#1083ardian4 wants to merge 1 commit intocdapio:developfrom
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
| @Test | ||
| public void testMultiSinkContentType() throws Exception { | ||
| String bucketName = "cask-gcs-multisink-" + UUID.randomUUID().toString(); | ||
| Bucket bucket = createBucket(bucketName); |
There was a problem hiding this comment.
would be good to delete the bucket at the end of the test.
As a best practice, all the resources created in the test should be deleted upon test assertion completion.
There was a problem hiding this comment.
We already doing it, if you follow the method createBucket(bucketName) the bucket name is marked for delete after the test is done, also we run the the test and the bucket is deleted when the test is finished
CuriousVini
left a comment
There was a problem hiding this comment.
Please fix and squash
| inputSourceConfig.put("format", "csv"); | ||
| inputSourceConfig.put("referenceName", "source_" + UUID.randomUUID().toString()); | ||
| inputSourceConfig.put("project", getProjectId()); | ||
| inputSourceConfig.put("path", createPath(bucket, inputPath)); |
There was a problem hiding this comment.
could you make it a macro.
There was a problem hiding this comment.
In GCSMultiBatchSink if the format is macro (null) this always fails with null pointer exception.
Please check the line 75 in this file:
src/main/java/io/cdap/plugin/gcp/gcs/sink/GCSMultiBatchSink.java.
That is the reason why we can not implement it right now.
There was a problem hiding this comment.
I see. We should still include it as a macro and have that bug fixed.
Could you please file a corresponding jira?
There was a problem hiding this comment.
Done.
Jira Ticket regarding null pointer exception in GCSMultiBatchSink if the format is macro:
https://cdap.atlassian.net/browse/PLUGIN-553
| for (String format : formats) { | ||
| String path = String.format("%s/%s/%s", createPath(bucket, OUTPUT_BLOB_NAME), format, suffix); | ||
| ETLStage sink = new ETLStage(format, createSinkPlugin(format, path, schema)); | ||
| ETLStage sink = new ETLStage(format, createSinkPlugin(format, path, schema, DEFAULT_CONTENT_TYPE)); |
There was a problem hiding this comment.
why do we need to specify this? If nothing is specified, the sink would interpret default content type right?
There was a problem hiding this comment.
If this is not specified, the integration test still passes, is that correct?
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
7c04d82 to
435b096
Compare
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
CuriousVini
left a comment
There was a problem hiding this comment.
Could we make all the fields as macro except GCSMultiSink format type?
For GCSMultiSink format type, add a TODO to make it macro with the jira number
| return createSinkPlugin(format, path, schema, null); | ||
| } | ||
|
|
||
| private ETLPlugin createSinkPlugin(String format, String path, Schema schema, String contentType) { |
There was a problem hiding this comment.
If contentType can be nullable, annotate it
| Schema.Field.of("id", Schema.of(Schema.Type.INT)), | ||
| Schema.Field.of("name", Schema.nullableOf(Schema.of(Schema.Type.STRING))), | ||
| Schema.Field.of("email", Schema.nullableOf(Schema.of(Schema.Type.STRING))) | ||
| ); |
There was a problem hiding this comment.
nit: no need for separate line
| String line3 = "3,Jack Ferguson,jferguson2@example.com,DepartmentA"; | ||
| String inputPath = "input"; | ||
|
|
||
| bucket.create(inputPath, String.join("\n", Arrays.asList(line1, line2, line3)).getBytes(StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
do we not have existing function for this? how do we insert values for other gcs tests?
There was a problem hiding this comment.
There is no existing function for this, also other test use same logic.
There was a problem hiding this comment.
could you refactor it into a single method
There was a problem hiding this comment.
Please check the updated PR. This part is now handled.
| private ETLPlugin createMultiSinkPlugin(String path, Schema schema, String splitField) { | ||
| Map<String, String> map = new HashMap<>(); | ||
| map.put("path", path); | ||
| map.put("format", "${sinkFormat}"); |
There was a problem hiding this comment.
If format is a macro, this will fail right?
https://cdap.atlassian.net/browse/PLUGIN-553
There was a problem hiding this comment.
Right, we have comment this line, format will not be macro.
There was a problem hiding this comment.
Lets not comment the line. Lets remove macro and add it as a regular argument along with TODO in similar format
https://github.com/cdapio/cdap/blob/22718583995305aa9898eb54b5c7c2571ff1e3bb/cdap-app-fabric/src/main/java/io/cdap/cdap/internal/app/runtime/plugin/CollectMacroEvaluator.java#L33
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
9adb339 to
d9ce2a7
Compare
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
1 similar comment
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
5067e9e to
88f5ed7
Compare
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Integration test for issue: https://cdap.atlassian.net/browse/PLUGIN-498