Skip to content

Commit

Permalink
ZOOKEEPER-4232: Run InvalidSnapshotTest on a copy of test data
Browse files Browse the repository at this point in the history
Without this, the ZooKeeperServer "fixes" the 'snapshot.83f' reference
file, which:

 1. Makes the test ineffective after the first run;
 2. Causes the file to show as modified in version control tools;
 3. Can end up committed by accident.

This patch creates a temporary copy of the data directory.
  • Loading branch information
ztzg committed Mar 9, 2021
1 parent 4b8d10e commit 42a5a0b
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static org.apache.zookeeper.test.ClientBase.CONNECTION_TIMEOUT;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.zookeeper.PortAssignment;
import org.apache.zookeeper.ZKTestCase;
import org.apache.zookeeper.ZooKeeper;
Expand Down Expand Up @@ -67,7 +68,12 @@ public void testSnapshotFormatterWithNull() throws Exception {
*/
@Test
public void testSnapshot() throws Exception {
File snapDir = new File(testData, "invalidsnap");
File origSnapDir = new File(testData, "invalidsnap");

// This test otherwise updates the resources directory.
File snapDir = ClientBase.createTmpDir();
FileUtils.copyDirectory(origSnapDir, snapDir);

ZooKeeperServer zks = new ZooKeeperServer(snapDir, snapDir, 3000);
SyncRequestProcessor.setSnapCount(1000);
final int PORT = Integer.parseInt(HOSTPORT.split(":")[1]);
Expand Down

0 comments on commit 42a5a0b

Please sign in to comment.