rkhachatryan commented on code in PR #20093: URL: https://github.com/apache/flink/pull/20093#discussion_r914214042
########## flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/StateChangeFsUploaderTest.java: ########## @@ -0,0 +1,58 @@ +/* + * 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.changelog.fs; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.core.fs.Path; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups.createUnregisteredTaskManagerJobMetricGroup; +import static org.assertj.core.api.Assertions.assertThat; + +/** {@link StateChangeFsUploader} test. */ +class StateChangeFsUploaderTest { + + @Test + void testBasePath() throws IOException { + JobID jobID = JobID.generate(); + Path oriBasePath = new Path("file:///dstl-base-path"); + + ChangelogStorageMetricGroup metrics = + new ChangelogStorageMetricGroup(createUnregisteredTaskManagerJobMetricGroup()); + + StateChangeFsUploader uploader = + new StateChangeFsUploader( + jobID, + oriBasePath, + oriBasePath.getFileSystem(), + false, + 4096, + metrics, + TaskChangelogRegistry.NO_OP); + + Path basePath = uploader.getBasePath(); + + assertThat(basePath.getName()).isEqualTo("dstl"); + assertThat(basePath.getParent().getName()).isEqualTo(jobID.toHexString()); + assertThat(basePath.getParent().getParent()).isEqualTo(oriBasePath); Review Comment: NIT: I'm wondering if something like ``` assertEquals( uploader.getBasePath().getPath(), String.format( "/%s/%s/%s", rootPath, jobID.toHexString(), StateChangeFsUploader.PATH_SUFFIX)); ``` will be more readable, WDYT? ########## flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/StateChangeFsUploaderTest.java: ########## @@ -0,0 +1,58 @@ +/* + * 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.changelog.fs; + +import org.apache.flink.api.common.JobID; +import org.apache.flink.core.fs.Path; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups.createUnregisteredTaskManagerJobMetricGroup; +import static org.assertj.core.api.Assertions.assertThat; + +/** {@link StateChangeFsUploader} test. */ +class StateChangeFsUploaderTest { + + @Test + void testBasePath() throws IOException { + JobID jobID = JobID.generate(); + Path oriBasePath = new Path("file:///dstl-base-path"); + + ChangelogStorageMetricGroup metrics = + new ChangelogStorageMetricGroup(createUnregisteredTaskManagerJobMetricGroup()); + + StateChangeFsUploader uploader = + new StateChangeFsUploader( + jobID, + oriBasePath, + oriBasePath.getFileSystem(), + false, + 4096, + metrics, + TaskChangelogRegistry.NO_OP); + + Path basePath = uploader.getBasePath(); + + assertThat(basePath.getName()).isEqualTo("dstl"); Review Comment: I'd extract `"dstl"` constant in `StateChangeFsUploader` and use it here, so that changes are reflected in test. -- 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]
