SOLR-7629: Have RulesTest consider disk space limitations of where the test is being run

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1686077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ramkumar Aiyengar 2015-06-17 17:08:10 +00:00
parent a9d669cf86
commit c33623f316
3 changed files with 21 additions and 7 deletions

View File

@ -207,6 +207,9 @@ Other Changes
* SOLR-7665: deprecate the class TransformerWithContext (noble)
* SOLR-7629: Have RulesTest consider disk space limitations of where the test is
being run (Christine Poerschke via Ramkumar Aiyengar)
================== 5.2.1 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

View File

@ -71,6 +71,12 @@ public class ImplicitSnitch extends Snitch implements CoreAdminHandler.Invocable
if (params.size() > 0) ctx.invokeRemote(solrNode, params, ImplicitSnitch.class.getName(), null);
}
static long getUsableSpaceInGB() throws IOException {
long space = Files.getFileStore(Paths.get("/")).getUsableSpace();
long spaceInGB = space / 1024 / 1024 / 1024;
return spaceInGB;
}
public Map<String, Object> invoke(SolrQueryRequest req) {
Map<String, Object> result = new HashMap<>();
if (req.getParams().getInt(CORES, -1) == 1) {
@ -79,8 +85,7 @@ public class ImplicitSnitch extends Snitch implements CoreAdminHandler.Invocable
}
if (req.getParams().getInt(DISK, -1) == 1) {
try {
long space = Files.getFileStore(Paths.get("/")).getUsableSpace();
long spaceInGB = space / 1024 / 1024 / 1024;
final long spaceInGB = getUsableSpaceInGB();
result.put(DISK, spaceInGB);
} catch (IOException e) {

View File

@ -45,6 +45,8 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
@Test
@ShardsFixed(num = 5)
public void doIntegrationTest() throws Exception {
final long minGB = (random().nextBoolean() ? 1 : 0);
assumeTrue("doIntegrationTest needs minGB="+minGB+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB);
String rulesColl = "rulesColl";
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse rsp;
@ -53,7 +55,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
.setShards("shard1")
.setRouterName(ImplicitDocRouter.NAME)
.setReplicationFactor(2)
.setRule("cores:<4", "node:*,replica:<2", "freedisk:>1")
.setRule("cores:<4", "node:*,replica:<2", "freedisk:>"+minGB)
.setSnitch("class:ImplicitSnitch");
rsp = create.process(client);
assertEquals(0, rsp.getStatus());
@ -66,7 +68,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
assertEquals(3, list.size());
assertEquals ( "<4", ((Map)list.get(0)).get("cores"));
assertEquals("<2", ((Map) list.get(1)).get("replica"));
assertEquals(">1", ((Map) list.get(2)).get("freedisk"));
assertEquals(">"+minGB, ((Map) list.get(2)).get("freedisk"));
list = (List) rulesCollection.get("snitch");
assertEquals(1, list.size());
assertEquals ( "ImplicitSnitch", ((Map)list.get(0)).get("class"));
@ -126,6 +128,10 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
@Test
public void testModifyColl() throws Exception {
final long minGB1 = (random().nextBoolean() ? 1 : 0);
final long minGB2 = 5;
assumeTrue("testModifyColl needs minGB1="+minGB1+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB1);
assumeTrue("testModifyColl needs minGB2="+minGB2+" usable disk space", ImplicitSnitch.getUsableSpaceInGB() > minGB2);
String rulesColl = "modifyColl";
try (SolrClient client = createNewSolrClient("", getBaseUrl((HttpSolrClient) clients.get(0)))) {
CollectionAdminResponse rsp;
@ -133,7 +139,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
.setCollectionName(rulesColl)
.setNumShards(1)
.setReplicationFactor(2)
.setRule("cores:<4", "node:*,replica:1", "freedisk:>1")
.setRule("cores:<4", "node:*,replica:1", "freedisk:>"+minGB1)
.setSnitch("class:ImplicitSnitch");
rsp = create.process(client);
assertEquals(0, rsp.getStatus());
@ -143,7 +149,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
p.add("action", "MODIFYCOLLECTION");
p.add("rule", "cores:<5");
p.add("rule", "node:*,replica:1");
p.add("rule", "freedisk:>5");
p.add("rule", "freedisk:>"+minGB2);
p.add("autoAddReplicas", "true");
client.request(new GenericSolrRequest(POST, COLLECTIONS_HANDLER_PATH, p));
}
@ -163,7 +169,7 @@ public class RulesTest extends AbstractFullDistribZkTestBase {
}
assertEquals("<5", ((Map) list.get(0)).get("cores"));
assertEquals("1", ((Map) list.get(1)).get("replica"));
assertEquals(">5", ((Map) list.get(2)).get("freedisk"));
assertEquals(">"+minGB2, ((Map) list.get(2)).get("freedisk"));
assertEquals("true", String.valueOf(rulesCollection.getProperties().get("autoAddReplicas")));
list = (List) rulesCollection.get("snitch");
assertEquals(1, list.size());