use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiSelfTest method testSingleNodeDifferentSession.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "ObjectEquality" })
public void testSingleNodeDifferentSession() throws Exception {
GridTestNode node = (GridTestNode) getSpiContext().nodes().iterator().next();
node.addAttribute("load", 2d);
List<ClusterNode> nodes = Collections.singletonList((ClusterNode) node);
GridTestNode pick1 = (GridTestNode) getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
pick1.setAttribute("used", true);
assert nodes.contains(pick1);
// Verify that same instance is returned every time.
ClusterNode pick2 = getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
assert pick1 == pick2;
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridAdaptiveLoadBalancingSpiSelfTest method initSpiContext.
/**
* {@inheritDoc}
*/
@Override
protected GridSpiTestContext initSpiContext() throws Exception {
GridSpiTestContext ctx = super.initSpiContext();
ctx.setLocalNode(new GridTestNode(UUID.randomUUID()));
return ctx;
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest method testNodeNotInTopology.
/**
*/
public void testNodeNotInTopology() throws Exception {
ComputeTaskSession ses = new GridTestTaskSession();
ClusterNode node = new GridTestNode(UUID.randomUUID());
List<ClusterNode> notInTop = Arrays.asList(node);
try {
getSpi().getBalancedNode(ses, notInTop, new GridTestJob());
} catch (IgniteException e) {
assertTrue(e.getMessage().contains("Task topology does not have alive nodes"));
}
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest method testTopologyChange.
/**
* @throws Exception If failed.
*/
public void testTopologyChange() throws Exception {
ComputeTaskSession ses = new GridTestTaskSession(IgniteUuid.randomUuid());
// Warm up.
List<ClusterNode> allNodes = (List<ClusterNode>) getSpiContext().nodes();
List<UUID> orderedNodes = getSpi().getNodeIds(ses);
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
// Remove node.
UUID doomed = orderedNodes.get(0);
if (getSpiContext().localNode().id().equals(doomed))
doomed = orderedNodes.get(1);
getSpiContext().removeNode(doomed);
assertTrue(allNodes.remove(new GridTestNode(doomed)));
orderedNodes = getSpi().getNodeIds(ses);
assertFalse("Balancer uses removed node", orderedNodes.contains(doomed));
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
// Add node.
ClusterNode newNode = new GridTestNode(UUID.randomUUID());
getSpiContext().addNode(newNode);
assertTrue(allNodes.add(newNode));
// Check that new node was added to balancing.
boolean foundNewNode = false;
for (int i = 0; i < allNodes.size(); i++) {
ClusterNode node = getSpi().getBalancedNode(ses, allNodes, new GridTestJob());
if (newNode.id().equals(node.id())) {
foundNewNode = true;
break;
}
}
assertTrue("Balancer doesn't use added node", foundNewNode);
orderedNodes = getSpi().getNodeIds(ses);
checkCyclicBalancing(getSpi(), allNodes, orderedNodes, ses);
}
use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.
the class GridWeightedRandomLoadBalancingSpiSelfTest method testMultipleNodes.
/**
* @throws Exception If failed.
*/
public void testMultipleNodes() throws Exception {
List<ClusterNode> nodes = new ArrayList<>();
for (int i = 0; i < 10; i++) nodes.add(new GridTestNode(UUID.randomUUID()));
// Seal it.
nodes = Collections.unmodifiableList(nodes);
ClusterNode node = getSpi().getBalancedNode(new GridTestTaskSession(), nodes, new GridTestJob());
assert node != null;
assert nodes.contains(node);
}
Aggregations