Izeren commented on code in PR #28268: URL: https://github.com/apache/flink/pull/28268#discussion_r3364092833
########## flink-filesystems/flink-s3-fs-native/src/test/java/org/apache/flink/fs/s3native/writer/InMemoryNativeS3Operations.java: ########## @@ -0,0 +1,165 @@ +/* + * 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.s3native.writer; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * In-memory implementation for {@link NativeS3ObjectOperations}. + * + * <p>Backs every reachable S3 operation with hash maps so writer/committer logic can be exercised + * without an S3 endpoint (no MinIO/Testcontainers required). The parent's {@code S3Client} / {@code + * S3TransferManager} constructor arguments are passed as {@code null} because no overridden method + * dereferences them. + * + * <p><b>State exposure:</b> the storage maps are exposed as public final fields so tests can + * inspect them, corrupt them, or simulate object loss directly: + * + * <ul> + * <li>{@link #storedObjects} — keys written via {@link #putObject(String, File)} (e.g. the + * incomplete-tail side objects persisted by {@link NativeS3RecoverableFsDataOutputStream}). + * <li>{@link #committedObjects} — keys finalized via {@link #commitMultiPartUpload}. + * <li>{@link #openMultipartUploads} — uploadId → partNumber → bytes for in-flight MPUs; entries + * are removed on commit or abort. + * </ul> + * + * <p>{@link #getObject} reads from <em>both</em> {@link #storedObjects} and {@link + * #committedObjects} so tests can fetch a committed object the same way real S3 would serve it. + * + * <p><b>Thread safety:</b> not thread-safe. Use a single thread per instance, matching the + * single-thread invariant of the production {@link NativeS3RecoverableFsDataOutputStream}. + */ +public final class InMemoryNativeS3Operations extends NativeS3ObjectOperations { Review Comment: Yes, makes sense to decouple as a separate PR -- 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]
