SOLR-13988: Harden CreateCollectionCleanupTest

This commit is contained in:
Erick Erickson 2019-12-06 11:59:53 -05:00
parent 9ec8a86d69
commit 106b9d6866
1 changed files with 10 additions and 6 deletions

View File

@ -21,11 +21,11 @@ import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import java.nio.file.Path;
import java.util.Properties;
import org.apache.solr.client.solrj.impl.BaseHttpSolrClient;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.client.solrj.response.RequestStatusState;
import org.apache.solr.common.params.CoreAdminParams;
import org.junit.BeforeClass;
@ -77,10 +77,12 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase {
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1);
Properties properties = new Properties();
properties.put(CoreAdminParams.DATA_DIR, "/some_invalid_dir/foo");
Path tmpDir = createTempDir();
tmpDir.toFile().setWritable(false);
properties.put(CoreAdminParams.DATA_DIR, tmpDir.toString());
create.setProperties(properties);
expectThrows(HttpSolrClient.RemoteSolrException.class, () -> {
CollectionAdminResponse rsp = create.process(cloudClient);
expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> {
create.process(cloudClient);
});
// Confirm using LIST that the collection does not exist
@ -99,7 +101,9 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase {
CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1);
Properties properties = new Properties();
properties.put(CoreAdminParams.DATA_DIR, "/some_invalid_dir/foo2");
Path tmpDir = createTempDir();
tmpDir.toFile().setWritable(false);
properties.put(CoreAdminParams.DATA_DIR, tmpDir.toString());
create.setProperties(properties);
create.setAsyncId("testAsyncCreateCollectionCleanup");
create.process(cloudClient);