Savonitar commented on code in PR #29819:
URL: https://github.com/apache/flink/pull/29819#discussion_r4657886620


##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/GSTestCredentials.java:
##########
@@ -50,4 +59,21 @@ static String getTestBucketUri() {
         }
         return "gs://" + GCS_TEST_BUCKET + "/temp/";
     }
+
+    /**
+     * Deletes the temporary objects the recoverable writer created for files 
under {@code
+     * basePath}. They live under the in-progress prefix at the bucket root, 
outside {@code
+     * basePath}, and only a commit removes them, so uncommitted streams leave 
them behind.
+     */
+    static void deleteTemporaryObjects(Path basePath) {
+        final GSFileSystemFactory factory = new GSFileSystemFactory();
+        factory.configure(new Configuration());
+        final GSBlobStorage storage = new 
GSBlobStorageImpl(factory.getStorage());
+        final GSBlobIdentifier base = BlobUtils.parseUri(basePath.toUri());
+        final List<GSBlobIdentifier> temporaryObjects =
+                storage.list(base.bucketName, 
BlobUtils.getTemporaryObjectPartialName(base));
+        if (!temporaryObjects.isEmpty()) {
+            storage.delete(temporaryObjects);

Review Comment:
   Should we check the batch-delete results and if they are false, re-list this 
test's prefix and assert it's empty? 
   I think GCS client returns false for individual deletion errors, so teardown 
can currently pass with a staged object still in the bucket.



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSFileSystemITCase.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.runtime.fs.hdfs.AbstractHadoopFileSystemITTest;
+
+import org.junit.jupiter.api.BeforeAll;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Integration tests for GCS file system support. */
+class HadoopGSFileSystemITCase extends AbstractHadoopFileSystemITTest {

Review Comment:
   With `IT_CASE_GCS_BUCKET` unset, the GCS ITCases still initialise the GCS 
factory: JUnit runs the inherited `@AfterAll` even when `@BeforeAll` aborts on 
the assumption, and it calls `FileSystem.initialize(...)`, which eagerly loads 
the credentials file. If `GOOGLE_APPLICATION_CREDENTIALS` points to a missing 
file, zero tests run but every class reports an error.
   
   I reproduced this locally: the three new classes fail, and so do the 
existing `GSFileSystemBehaviorITCase` and `GSRecoverableWriterITCase`, so it is 
not new in this PR.
   
   Would a class-level `@EnabledIfEnvironmentVariable(named = 
"IT_CASE_GCS_BUCKET", matches = ".+")` make sense, so the lifecycle methods 
don't run at all? Fine as a follow-up for all five classes.
   



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSRecoverableWriterExceptionITCase.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import 
org.apache.flink.runtime.fs.hdfs.AbstractHadoopRecoverableWriterExceptionITCase;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Integration tests for exception handling in {@link
+ * org.apache.flink.fs.gs.writer.GSRecoverableWriter}.
+ */
+class HadoopGSRecoverableWriterExceptionITCase
+        extends AbstractHadoopRecoverableWriterExceptionITCase {

Review Comment:
   nit: could we wrap `stream = writer.open(path)` in try-with-resources in the 
inherited `testResumeWithWrongOffset`, so it is closed after writing 
`testData3` and before the first recovery? The last write opens a GCS resumable 
upload session that is never closed, the two `closeForCommit()` calls below 
only close the recovered streams.



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSRecoverableWriterITCase.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.core.fs.RecoverableWriter;
+import org.apache.flink.runtime.fs.hdfs.AbstractHadoopRecoverableWriterITCase;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+/** Integration tests for {@link 
org.apache.flink.fs.gs.writer.GSRecoverableWriter}. */
+class HadoopGSRecoverableWriterITCase extends 
AbstractHadoopRecoverableWriterITCase {
+
+    @BeforeAll
+    static void setup() throws IOException {
+        GSTestCredentials.assumeCredentialsAvailable();
+        // The smallest chunk size GCS accepts, so each 7 MiB component of the 
*WithMultiPart
+        // tests is uploaded in several chunks instead of one (the default is 
16 MiB).
+        final Configuration config = new Configuration();
+        config.set(GSFileSystemOptions.WRITER_CHUNK_SIZE, 
MemorySize.parse("256kb"));
+        FileSystem.initialize(config, null);
+        basePath = new Path(GSTestCredentials.getTestBucketUri() + "tests-" + 
UUID.randomUUID());
+        assertThat(basePath.getFileSystem().exists(basePath)).isFalse();
+        bigDataChunk = createBigDataChunk(BIG_CHUNK_DATA_PATTERN, 7L << 20);

Review Comment:
   nit: could we give the first, second, and third multipart components 
distinct contents while keeping them the same size? Since all three currently 
use `bigDataChunk`, the final-content assertion still passes if recovery 
assembles them in the wrong order.



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSRecoverableWriterExceptionITCase.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import 
org.apache.flink.runtime.fs.hdfs.AbstractHadoopRecoverableWriterExceptionITCase;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Integration tests for exception handling in {@link
+ * org.apache.flink.fs.gs.writer.GSRecoverableWriter}.
+ */
+class HadoopGSRecoverableWriterExceptionITCase
+        extends AbstractHadoopRecoverableWriterExceptionITCase {

Review Comment:
   On GCS the inherited `testResumeWithWrongOffset` passes for the same reason 
as `testResumeAfterCommit`: once `recoverable1` is committed, any further 
commit fails with "Blob ... already exists" (committing `recoverable1` a second 
time fails identically), so the missing-data path is never reached.
   
   Would a GCS-only test be worth it: keep the destination absent, delete the 
component that only `recoverable2` references, check that committing 
`recoverable2` fails and that `recoverable1` still commits? 
   
   Fine as a follow-up.
   



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSRecoverableWriterITCase.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.core.fs.RecoverableWriter;
+import org.apache.flink.runtime.fs.hdfs.AbstractHadoopRecoverableWriterITCase;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+/** Integration tests for {@link 
org.apache.flink.fs.gs.writer.GSRecoverableWriter}. */
+class HadoopGSRecoverableWriterITCase extends 
AbstractHadoopRecoverableWriterITCase {

Review Comment:
   Could we add a GCS-only test that commits an empty stream and checks that 
`getFileSystem().getFileStatus(path).getLen()` is zero? The inherited 
`testCloseWithNoData` asserts nothing after commit.
   



##########
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/HadoopGSRecoverableWriterITCase.java:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.flink.fs.gs;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.apache.flink.core.fs.RecoverableWriter;
+import org.apache.flink.runtime.fs.hdfs.AbstractHadoopRecoverableWriterITCase;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.UUID;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+/** Integration tests for {@link 
org.apache.flink.fs.gs.writer.GSRecoverableWriter}. */
+class HadoopGSRecoverableWriterITCase extends 
AbstractHadoopRecoverableWriterITCase {
+
+    @BeforeAll
+    static void setup() throws IOException {
+        GSTestCredentials.assumeCredentialsAvailable();
+        // The smallest chunk size GCS accepts, so each 7 MiB component of the 
*WithMultiPart
+        // tests is uploaded in several chunks instead of one (the default is 
16 MiB).
+        final Configuration config = new Configuration();
+        config.set(GSFileSystemOptions.WRITER_CHUNK_SIZE, 
MemorySize.parse("256kb"));
+        FileSystem.initialize(config, null);
+        basePath = new Path(GSTestCredentials.getTestBucketUri() + "tests-" + 
UUID.randomUUID());
+        assertThat(basePath.getFileSystem().exists(basePath)).isFalse();
+        bigDataChunk = createBigDataChunk(BIG_CHUNK_DATA_PATTERN, 7L << 20);
+        skipped = false;
+    }
+
+    @AfterAll
+    static void cleanUpTemporaryObjects() {
+        if (!skipped) {
+            GSTestCredentials.deleteTemporaryObjects(basePath);

Review Comment:
   Could one successful persist/recover/commit test check that its 
temporary-object prefix is empty immediately after commit? That would tell us 
whether the writer removed its staged objects before the suite cleanup gets a 
chance to remove them.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to