Skip to content
Browse files

[#eng-2514] move fakeFsStats into unit test package

  • Loading branch information...
1 parent c2ac0a0 commit b5f446d53fb1ed88294ec75fe3b29ea545f33760 @dakrone dakrone committed
View
30 src/test/java/com/sonian/elasticsearch/equilibrium/AbstractEquilibriumTests.java
@@ -1,20 +1,10 @@
package com.sonian.elasticsearch.equilibrium;
import com.sonian.elasticsearch.tests.AbstractJettyHttpServerTests;
-import org.easymock.IAnswer;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
import org.elasticsearch.client.Client;
-import org.elasticsearch.common.collect.Iterators;
import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.unit.ByteSizeValue;
-import org.elasticsearch.monitor.fs.FsStats;
-
-import java.util.Iterator;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
/**
* @author dakrone
@@ -76,24 +66,4 @@ public void waitForYellow(String id, String idx, String timeout) {
}
}
- public FsStats makeFakeFsStats(long total, long avail) {
- FsStats fs = createMock(FsStats.class);
- final FsStats.Info[] infos = new FsStats.Info[1];
-
- FsStats.Info fsInfo1 = createMock(FsStats.Info.class);
- expect(fsInfo1.total()).andStubReturn(new ByteSizeValue(total));
- expect(fsInfo1.available()).andStubReturn(new ByteSizeValue(avail));
-
- infos[0] = fsInfo1;
- expect(fs.iterator()).andStubAnswer(new IAnswer<Iterator<FsStats.Info>>() {
- @Override
- public Iterator<FsStats.Info> answer() throws Throwable {
- return Iterators.forArray(infos);
- }
- });
-
- replay(fs, fsInfo1);
-
- return fs;
- }
}
View
28 src/test/java/com/sonian/elasticsearch/equilibrium/DiskShardsAllocatorUnitTests.java
@@ -1,5 +1,6 @@
package com.sonian.elasticsearch.equilibrium;
+import org.easymock.IAnswer;
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -9,13 +10,16 @@
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDecider;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
+import org.elasticsearch.common.collect.Iterators;
import org.elasticsearch.common.settings.ImmutableSettings;
+import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.monitor.fs.FsStats;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import static org.easymock.EasyMock.*;
@@ -24,7 +28,29 @@
/**
* @author dakrone
*/
-public class DiskShardsAllocatorUnitTests extends AbstractEquilibriumTests {
+public class DiskShardsAllocatorUnitTests {
+
+
+ public FsStats makeFakeFsStats(long total, long avail) {
+ FsStats fs = createMock(FsStats.class);
+ final FsStats.Info[] infos = new FsStats.Info[1];
+
+ FsStats.Info fsInfo1 = createMock(FsStats.Info.class);
+ expect(fsInfo1.total()).andStubReturn(new ByteSizeValue(total));
+ expect(fsInfo1.available()).andStubReturn(new ByteSizeValue(avail));
+
+ infos[0] = fsInfo1;
+ expect(fs.iterator()).andStubAnswer(new IAnswer<Iterator<FsStats.Info>>() {
+ @Override
+ public Iterator<FsStats.Info> answer() throws Throwable {
+ return Iterators.forArray(infos);
+ }
+ });
+
+ replay(fs, fsInfo1);
+
+ return fs;
+ }
@Test
public void testEnoughDiskForShard() {

0 comments on commit b5f446d

Please sign in to comment.
Something went wrong with that request. Please try again.