galenwarren commented on a change in pull request #15599:
URL: https://github.com/apache/flink/pull/15599#discussion_r783116717



##########
File path: 
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/writer/GSCommitRecoverableTest.java
##########
@@ -0,0 +1,136 @@
+/*
+ * 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.writer;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.fs.gs.GSFileSystemOptions;
+import org.apache.flink.fs.gs.storage.GSBlobIdentifier;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+/** Test {@link GSResumeRecoverable}. */
+@RunWith(Parameterized.class)
+public class GSCommitRecoverableTest {
+
+    @Parameterized.Parameter(value = 0)
+    public List<UUID> componentObjectIds;
+
+    @Parameterized.Parameter(value = 1)
+    public String temporaryBucketName;
+
+    @Parameterized.Parameters(name = "componentObjectIds={0}, 
temporaryBucketName={1}")
+    public static Collection<Object[]> data() {
+
+        ArrayList<UUID> emptyComponentObjectIds = new ArrayList<>();
+        ArrayList<UUID> populatedComponentObjectIds = new ArrayList<>();
+        for (int i = 0; i < 2; i++) {
+            populatedComponentObjectIds.add(UUID.randomUUID());
+        }
+        GSBlobIdentifier blobIdentifier = new GSBlobIdentifier("foo", "bar");
+
+        return Arrays.asList(
+                new Object[][] {
+                    // no component ids with no temporary bucket specified
+                    {emptyComponentObjectIds, null},
+                    // no component ids with a temporary bucket specified
+                    {emptyComponentObjectIds, "temporary-bucket"},
+                    // populated component ids with no temporary bucket 
specified
+                    {populatedComponentObjectIds, null},
+                    //  populated component ids with temporary bucket specified
+                    {populatedComponentObjectIds, "temporary-bucket"},
+                });
+    }
+
+    private GSBlobIdentifier blobIdentifier;
+
+    @Before
+    public void before() {
+        blobIdentifier = new GSBlobIdentifier("foo", "bar");
+    }
+
+    @Test
+    public void shouldConstructProperly() {
+        GSCommitRecoverable commitRecoverable =
+                new GSCommitRecoverable(blobIdentifier, componentObjectIds);
+        assertEquals(blobIdentifier, commitRecoverable.finalBlobIdentifier);
+        assertEquals(componentObjectIds, commitRecoverable.componentObjectIds);
+    }
+
+    /** Ensure that the list of component object ids cannot be added to. */
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldNotAddComponentId() {
+        GSCommitRecoverable commitRecoverable =
+                new GSCommitRecoverable(blobIdentifier, componentObjectIds);
+        commitRecoverable.componentObjectIds.add(UUID.randomUUID());
+    }
+
+    /** Ensure that component object ids can't be updated. */
+    @Test(expected = UnsupportedOperationException.class)
+    public void shouldNotModifyComponentId() {
+        GSCommitRecoverable commitRecoverable =
+                new GSCommitRecoverable(blobIdentifier, componentObjectIds);
+        commitRecoverable.componentObjectIds.set(0, UUID.randomUUID());
+    }
+
+    @Test
+    public void shouldGetComponentBlobIds() {
+
+        // configure options, if this test configuration has a temporary 
bucket name, set it
+        Configuration flinkConfig = new Configuration();
+        if (temporaryBucketName != null) {
+            flinkConfig.setString("gs.writer.temporary.bucket.name", 
temporaryBucketName);

Review comment:
       Done in 
[5821321](https://github.com/apache/flink/pull/15599/commits/5821321ce92a5d827b53ef882d6214dd6ed9bad5).




-- 
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