[
https://issues.apache.org/jira/browse/GOBBLIN-1951?focusedWorklogId=889331&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-889331
]
ASF GitHub Bot logged work on GOBBLIN-1951:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 07/Nov/23 19:41
Start Date: 07/Nov/23 19:41
Worklog Time Spent: 10m
Work Description: hanghangliu commented on code in PR #3821:
URL: https://github.com/apache/gobblin/pull/3821#discussion_r1385465402
##########
gobblin-modules/gobblin-orc/src/test/java/org/apache/gobblin/writer/GobblinBaseOrcWriterTest.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gobblin.writer;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.orc.FileFormatException;
+import org.apache.orc.OrcFile;
+import org.mockito.Mockito;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.io.Files;
+
+import org.apache.gobblin.metrics.MetricContext;
+import org.apache.gobblin.metrics.event.GobblinEventBuilder;
+
+import static
org.apache.gobblin.writer.GobblinBaseOrcWriter.CORRUPTED_ORC_FILE_DELETION_EVENT;
+
+
+public class GobblinBaseOrcWriterTest {
+
+ @Test
+ public void testOrcValidation()
+ throws IOException {
+ Configuration conf = new Configuration();
+ FileSystem fs = FileSystem.getLocal(conf);
+ File tmpDir = Files.createTempDir();
+ File corruptedOrcFile = new File(tmpDir, "test.orc");
+ try (FileWriter writer = new FileWriter(corruptedOrcFile)) {
+ // write a corrupted ORC file that only contains the header but without
content
+ writer.write(OrcFile.MAGIC);
+ }
+
+ OrcFile.ReaderOptions readerOptions = new OrcFile.ReaderOptions(conf);
+
+ MetricContext mockContext = Mockito.mock(MetricContext.class);
+ Path p = new Path(corruptedOrcFile.getAbsolutePath());
+ Assert.assertThrows(FileFormatException.class,
+ () -> GobblinBaseOrcWriter.assertOrcFileIsValid(fs, p, readerOptions,
mockContext));
+
+ GobblinEventBuilder eventBuilder = new
GobblinEventBuilder(CORRUPTED_ORC_FILE_DELETION_EVENT,
GobblinBaseOrcWriter.ORC_WRITER_NAMESPACE);
Review Comment:
Do you think test the EventBuilder like
[this](https://github.com/apache/gobblin/blob/10397ab9d85829b86f1a04958742e612dcff234b/gobblin-iceberg/src/test/java/org/apache/gobblin/iceberg/writer/IcebergMetadataWriterTest.java#L179)
makes it easier so you won't need to suppress the warning?
Issue Time Tracking
-------------------
Worklog Id: (was: 889331)
Time Spent: 40m (was: 0.5h)
> GTE emission when deleting a corrupted ORC file written by the OrcWriter
> ------------------------------------------------------------------------
>
> Key: GOBBLIN-1951
> URL: https://issues.apache.org/jira/browse/GOBBLIN-1951
> Project: Apache Gobblin
> Issue Type: Improvement
> Reporter: Matthew Ho
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)