Skip to content

Commit

Permalink
Disabled load-dependent test in ModularLoadManagerImplTest (apache#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
merlimat authored Jun 20, 2017
1 parent f4969b4 commit e87d5f8
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -196,7 +199,8 @@ private String mockBundleName(final int i) {
return String.format("%d/%d/%d/0x00000000_0xffffffff", i, i, i);
}

@Test
// Test disabled since it's depending on CPU usage in the machine
@Test(enabled = false)
public void testCandidateConsistency() throws Exception {
boolean foundFirst = false;
boolean foundSecond = false;
Expand All @@ -210,7 +214,9 @@ public void testCandidateConsistency() throws Exception {
foundSecond = true;
}
}
assert (foundFirst && foundSecond);

assertTrue(foundFirst);
assertTrue(foundSecond);

// Now disable the secondary broker.
secondaryLoadManager.disableBroker();
Expand All @@ -221,17 +227,19 @@ public void testCandidateConsistency() throws Exception {
Thread.sleep(500);

// Make sure the second broker is not in the internal map.
assert (!loadData.getBrokerData().containsKey(secondaryHost));
assertFalse(loadData.getBrokerData().containsKey(secondaryHost));

// Try 5 more selections, ensure they all go to the first broker.
for (int i = 2; i < 7; ++i) {
final ServiceUnitId serviceUnit = makeBundle(Integer.toString(i));
assert (primaryLoadManager.selectBrokerForAssignment(serviceUnit).equals(primaryHost));
assertEquals(primaryLoadManager.selectBrokerForAssignment(serviceUnit), primaryHost);
}
}

// Test that bundles belonging to the same namespace are distributed evenly among brokers.
@Test

// Test disabled since it's depending on CPU usage in the machine
@Test(enabled = false)
public void testEvenBundleDistribution() throws Exception {
final NamespaceBundle[] bundles = LoadBalancerTestingUtils.makeBundles(nsFactory, "test", "test", "test", 16);
int numAssignedToPrimary = 0;
Expand All @@ -255,7 +263,7 @@ public void testEvenBundleDistribution() throws Exception {
if ((numAssignedToPrimary + numAssignedToSecondary) % 2 == 0) {
// On even number of assignments, assert that an equal number of bundles have been assigned between
// them.
assert (numAssignedToPrimary == numAssignedToSecondary);
assertEquals(numAssignedToPrimary, numAssignedToSecondary);
}
}
}
Expand Down Expand Up @@ -298,13 +306,13 @@ public void testLoadShedding() throws Exception {
primaryLoadManager.doLoadShedding();
// Most expensive bundle will be unloaded.
verify(namespacesSpy1, Mockito.times(1)).unloadNamespaceBundle(Mockito.anyString(), Mockito.anyString());
assert (bundleReference.get().equals(mockBundleName(2)));
assertEquals(bundleReference.get(), mockBundleName(2));

primaryLoadManager.doLoadShedding();
// Now less expensive bundle will be unloaded (normally other bundle would move off and nothing would be
// unloaded, but this is not the case due to the spy's behavior).
verify(namespacesSpy1, Mockito.times(2)).unloadNamespaceBundle(Mockito.anyString(), Mockito.anyString());
assert (bundleReference.get().equals(mockBundleName(1)));
assertEquals(bundleReference.get(), mockBundleName(1));

primaryLoadManager.doLoadShedding();
// Now both are in grace period: neither should be unloaded.
Expand Down

0 comments on commit e87d5f8

Please sign in to comment.