Apache Lucene open-source search software
SOLR-6775: Do not attempt cleanup of temp directory because it is handled by test framework
Shalin Shekhar Mangarf2a0440c2534
diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.javaindex 22a96c24f98..45c33542c0f 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandler.java@@ -134,8 +134,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {super.tearDown();masterJetty.stop();slaveJetty.stop();- master.tearDown();- slave.tearDown();masterJetty = slaveJetty = null;master = slave = null;masterClient.close();@@ -344,9 +342,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {try {if (repeaterJetty != null) repeaterJetty.stop();} catch (Exception e) { /* :NOOP: */ }- try {- if (repeater != null) repeater.tearDown();- } catch (Exception e) { /* :NOOP: */ }if (repeaterClient != null) repeaterClient.close();}}@@ -909,7 +904,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {} finally {if (repeater != null) {repeaterJetty.stop();- repeater.tearDown();repeaterJetty = null;}if (repeaterClient != null) {@@ -1505,10 +1499,6 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {"solrconfig.snippet.randomindexconfig.xml");}- public void tearDown() throws Exception {- IOUtils.rm(homeDir.toPath());- }-public void copyConfigFile(String srcFile, String destFile)throws IOException {copyFile(getFile(srcFile),diff --git a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.javaindex 91393f54d56..f4c1f8e0769 100644--- a/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java+++ b/solr/core/src/test/org/apache/solr/handler/TestReplicationHandlerBackup.java@@ -112,7 +112,6 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {masterClient.close();masterClient = null;masterJetty.stop();- master.tearDown();masterJetty = null;master = null;}@@ -167,60 +166,51 @@ public class TestReplicationHandlerBackup extends SolrJettyTestBase {Path[] snapDir = new Path[2];boolean namedBackup = random().nextBoolean();- try {- String firstBackupTimestamp = null;+ String firstBackupTimestamp = null;- String[] backupNames = null;- if (namedBackup) {- backupNames = new String[2];+ String[] backupNames = null;+ if (namedBackup) {+ backupNames = new String[2];+ }+ for (int i = 0; i < 2; i++) {+ BackupCommand backupCommand;+ final String backupName = TestUtil.randomSimpleString(random(), 1, 20);+ if (!namedBackup) {+ backupCommand = new BackupCommand(addNumberToKeepInRequest, backupKeepParamName, ReplicationHandler.CMD_BACKUP);+ } else {+ backupCommand = new BackupCommand(backupName, ReplicationHandler.CMD_BACKUP);+ backupNames[i] = backupName;}- for (int i = 0; i < 2; i++) {- BackupCommand backupCommand;- final String backupName = TestUtil.randomSimpleString(random(), 1, 20);- if (!namedBackup) {- backupCommand = new BackupCommand(addNumberToKeepInRequest, backupKeepParamName, ReplicationHandler.CMD_BACKUP);- } else {- backupCommand = new BackupCommand(backupName, ReplicationHandler.CMD_BACKUP);- backupNames[i] = backupName;- }- backupCommand.runCommand();- if (backupCommand.fail != null) {- fail(backupCommand.fail);- }-- CheckBackupStatus checkBackupStatus = new CheckBackupStatus((HttpSolrClient) masterClient, firstBackupTimestamp);- while (!checkBackupStatus.success) {- checkBackupStatus.fetchStatus();- Thread.sleep(1000);- }- if (i == 0) {- firstBackupTimestamp = checkBackupStatus.backupTimestamp;- }-- if (!namedBackup) {- snapDir[i] = Files.newDirectoryStream(Paths.get(master.getDataDir()), "snapshot*").iterator().next();- } else {- snapDir[i] = Files.newDirectoryStream(Paths.get(master.getDataDir()), "snapshot." + backupName).iterator().next();- }- verify(snapDir[i], nDocs);-+ backupCommand.runCommand();+ if (backupCommand.fail != null) {+ fail(backupCommand.fail);}- if (!namedBackup && Files.exists(snapDir[0])) {- fail("The first backup should have been cleaned up because " + backupKeepParamName + " was set to 1.");+ CheckBackupStatus checkBackupStatus = new CheckBackupStatus((HttpSolrClient) masterClient, firstBackupTimestamp);+ while (!checkBackupStatus.success) {+ checkBackupStatus.fetchStatus();+ Thread.sleep(1000);}-- //Test Deletion of named backup- if(namedBackup) {- testDeleteNamedBackup(backupNames);+ if (i == 0) {+ firstBackupTimestamp = checkBackupStatus.backupTimestamp;}- } finally {- if(!namedBackup) {- for (int i = 0; i < snapDir.length; i++) {- org.apache.lucene.util.IOUtils.rm(snapDir[i]);- }+ if (!namedBackup) {+ snapDir[i] = Files.newDirectoryStream(Paths.get(master.getDataDir()), "snapshot*").iterator().next();+ } else {+ snapDir[i] = Files.newDirectoryStream(Paths.get(master.getDataDir()), "snapshot." + backupName).iterator().next();}+ verify(snapDir[i], nDocs);++ }++ if (!namedBackup && Files.exists(snapDir[0])) {+ fail("The first backup should have been cleaned up because " + backupKeepParamName + " was set to 1.");+ }++ //Test Deletion of named backup+ if(namedBackup) {+ testDeleteNamedBackup(backupNames);}}