smiklosovic commented on code in PR #3530: URL: https://github.com/apache/cassandra/pull/3530#discussion_r1751636779
########## test/unit/org/apache/cassandra/db/commitlog/CommitLogArchiverTest.java: ########## @@ -0,0 +1,192 @@ +/* + * 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.cassandra.db.commitlog; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.file.Path; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import org.apache.cassandra.cql3.CQLTester; +import org.apache.cassandra.db.ColumnFamilyStore; +import org.apache.cassandra.db.Keyspace; +import org.apache.cassandra.db.RowUpdateBuilder; +import org.apache.cassandra.io.util.File; +import org.apache.cassandra.io.util.PathUtils; + +import static org.apache.cassandra.io.util.PathUtils.forEach; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class CommitLogArchiverTest extends CQLTester +{ + private static Path dirName; + private static final String rpiTime = "2024:03:22 20:43:12.633222"; + private static CommitLogArchiver oldArchiver; + + @ClassRule + public static TemporaryFolder temporaryFolder = new TemporaryFolder(); + + @BeforeClass + public static void beforeClass() throws IOException + { + dirName = temporaryFolder.newFolder().toPath(); + + CommitLog commitLog = CommitLog.instance; + Properties properties = new Properties(); + oldArchiver = commitLog.archiver; + properties.putAll(Map.of("archive_command", "/bin/cp %path " + dirName, + "restore_command", "/bin/cp -f %from %to", + "restore_directories", dirName.toString(), + "restore_point_in_time", rpiTime)); + CommitLogArchiver commitLogArchiver = CommitLogArchiver.getArchiverFromProperties(properties); + // set the archiver at the very beginning + commitLog.setCommitlogArchiver(commitLogArchiver); + } + + @Test + public void testArchiver() + { + File dir = new File(dirName); Review Comment: @Maxwell-Guo you should move this logic to `@Before`, that way, each test will have that directory empty (even it is not needed for it for now). It is just better practice. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

