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



##########
File path: 
flink-filesystems/flink-gs-fs-hadoop/src/test/java/org/apache/flink/fs/gs/storage/MockBlobStorage.java
##########
@@ -0,0 +1,205 @@
+/*
+ * 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.storage;
+
+import org.apache.flink.configuration.MemorySize;
+import org.apache.flink.fs.gs.utils.BlobUtils;
+import org.apache.flink.fs.gs.utils.ChecksumUtils;
+
+import com.google.cloud.storage.StorageException;
+
+import javax.annotation.Nullable;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+/** Mock blob storage implementation, using in-memory structures. */
+public class MockBlobStorage implements GSBlobStorage {
+
+    /** Mock blob value with metadata. */
+    public static class BlobValue {
+
+        public final byte[] content;
+
+        public BlobValue(byte[] content) {
+            this.content = content;
+        }
+    }
+
+    /** The mock blob metadata. */
+    static class BlobMetadata implements GSBlobStorage.BlobMetadata {
+
+        private final BlobValue blobValue;
+
+        private final String forcedChecksum;
+
+        BlobMetadata(BlobValue blobValue, String forcedChecksum) {
+            this.blobValue = blobValue;
+            this.forcedChecksum = forcedChecksum;
+        }
+
+        @Override
+        public String getChecksum() {
+            if (forcedChecksum != null) {
+                return forcedChecksum;
+            } else {
+                int checksum = 
ChecksumUtils.CRC_HASH_FUNCTION.hashBytes(blobValue.content).asInt();
+                return ChecksumUtils.convertChecksumToString(checksum);
+            }
+        }
+    }
+
+    /** The mock write channel, which writes to the memory-based storage. */
+    public class WriteChannel implements GSBlobStorage.WriteChannel {
+
+        private final GSBlobIdentifier blobIdentifier;
+
+        @Nullable public final MemorySize chunkSize;

Review comment:
       This is from an old test that confirmed that, when the 
"gs.writer.chunk.size" Flink config option is set, the chunk size gets properly 
set on the write channel. I actually did intend to leave that test in ... my 
mistake.
   
   ~~In looking at it now, I'm not sure how I can set a Flink config option of 
type `MemorySize` without using the associated `ConfigOption`, and it seems we 
want to keep that private.~~
   
   ~~In other words, there doesn't seem to be a `setMemorySize` method on the 
Flink `Configuration` class, even though `memoryType` is a method on 
`ConfigOptions`.~~ 
   
   ~~Options:~~
   ~~* Add 'setMemorySize' to the Flink `Configuration` class and use it for 
the test~~
   ~~* Make the "gs.writer.chunk.size" option a String and parse it~~
   ~~* Expose the `ConfigOption` to allow setting the property (which it seems 
we don't want to do, but including for completeness)~~
   ~~* Skip the test entirely (though I'm not sure how a real caller would set 
the "gs.writer.chunk.size" memory size, either ...)~~
   
   ~~I may be missing something obvious here; if so, my apologies.~~
   
   ~~Any thoughts?~~
   
   Sorry, I misread your other comment, I take it that exposing the 
`ConfigOption` instances publicly is ok. I'll reintroduce the test I mentioned 
above and will take a look at the visibility of this property at the same time.
   




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to