Search in sources :

Example 31 with GridTestNode

use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.

the class GridJobStealingFailoverSpiSelfTest method testThiefNotInTopology.

/**
 * @throws Exception If test failed.
 */
public void testThiefNotInTopology() throws Exception {
    ClusterNode rmt = new GridTestNode(UUID.randomUUID());
    GridTestJobResult failed = new GridTestJobResult(rmt);
    failed.getJobContext().setAttribute(THIEF_NODE_ATTR, rmt.id());
    ClusterNode other = getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), failed), new ArrayList<>(getSpiContext().nodes()));
    assert other != null;
    assert other != rmt;
    assert getSpiContext().nodes().contains(other);
    checkAttributes(failed.getJobContext(), rmt, 1);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridTestNode(org.apache.ignite.testframework.GridTestNode) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext)

Example 32 with GridTestNode

use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.

the class GridJobStealingFailoverSpiStartStopSelfTest method initSpiContext.

/**
 * {@inheritDoc}
 */
@Override
protected GridSpiTestContext initSpiContext() throws Exception {
    GridSpiTestContext ctx = super.initSpiContext();
    GridTestNode locNode = new GridTestNode(UUID.randomUUID());
    addSpiDependency(locNode);
    ctx.setLocalNode(locNode);
    return ctx;
}
Also used : GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Example 33 with GridTestNode

use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.

the class GridNeverFailoverSpiSelfTest method testAlwaysNull.

/**
 * @throws Exception If failed.
 */
public void testAlwaysNull() throws Exception {
    List<ClusterNode> nodes = new ArrayList<>();
    ClusterNode node = new GridTestNode(UUID.randomUUID());
    nodes.add(node);
    assert getSpi().failover(new GridFailoverTestContext(new GridTestTaskSession(), new GridTestJobResult(node)), nodes) == null;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) GridTestJobResult(org.apache.ignite.GridTestJobResult) GridTestNode(org.apache.ignite.testframework.GridTestNode) GridFailoverTestContext(org.apache.ignite.spi.failover.GridFailoverTestContext)

Example 34 with GridTestNode

use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.

the class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest method initSpiContext.

/**
 * {@inheritDoc}
 */
@Override
protected GridSpiTestContext initSpiContext() throws Exception {
    GridSpiTestContext ctx = super.initSpiContext();
    for (int i = 0; i < RMT_NODE_CNT; i++) {
        GridTestNode node = new GridTestNode(UUID.randomUUID());
        node.setAttribute("load", (double) (i + 1));
        ctx.addNode(node);
    }
    return ctx;
}
Also used : GridSpiTestContext(org.apache.ignite.testframework.GridSpiTestContext) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Example 35 with GridTestNode

use of org.apache.ignite.testframework.GridTestNode in project ignite by apache.

the class GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest method testWeights.

/**
 * @throws Exception If failed.
 */
public void testWeights() throws Exception {
    // Seal it.
    List<ClusterNode> nodes = new ArrayList<>(getSpiContext().remoteNodes());
    int[] cnts = new int[RMT_NODE_CNT];
    // Invoke load balancer a large number of times, so statistics won't lie.
    for (int i = 0; i < 50000; i++) {
        GridTestNode node = (GridTestNode) getSpi().getBalancedNode(new GridTestTaskSession(IgniteUuid.randomUuid()), nodes, new GridTestJob());
        int idx = ((Double) node.attribute("load")).intValue() - 1;
        if (cnts[idx] == 0)
            node.setAttribute("used", true);
        // Increment number of times a node was picked.
        cnts[idx]++;
    }
    info("Node counts: " + Arrays.toString(cnts));
    for (int i = 0; i < cnts.length - 1; i++) {
        assert cnts[i] > cnts[i + 1] : "Invalid node counts for index [idx=" + i + ", cnts[i]=" + cnts[i] + ", cnts[i+1]=" + cnts[i + 1] + ']';
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridTestTaskSession(org.apache.ignite.GridTestTaskSession) ArrayList(java.util.ArrayList) GridTestJob(org.apache.ignite.GridTestJob) GridTestNode(org.apache.ignite.testframework.GridTestNode)

Aggregations

GridTestNode (org.apache.ignite.testframework.GridTestNode)43 ClusterNode (org.apache.ignite.cluster.ClusterNode)27 GridSpiTestContext (org.apache.ignite.testframework.GridSpiTestContext)17 GridTestTaskSession (org.apache.ignite.GridTestTaskSession)14 ArrayList (java.util.ArrayList)11 GridTestJob (org.apache.ignite.GridTestJob)9 HashMap (java.util.HashMap)7 IgniteTestResources (org.apache.ignite.testframework.junits.IgniteTestResources)7 GridTimeoutProcessor (org.apache.ignite.internal.processors.timeout.GridTimeoutProcessor)6 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)6 Map (java.util.Map)5 GridTestJobResult (org.apache.ignite.GridTestJobResult)5 GridFailoverTestContext (org.apache.ignite.spi.failover.GridFailoverTestContext)5 Serializable (java.io.Serializable)4 List (java.util.List)4 ComputeTaskSession (org.apache.ignite.compute.ComputeTaskSession)4 ClusterMetricsSnapshot (org.apache.ignite.internal.ClusterMetricsSnapshot)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 DiscoveryEvent (org.apache.ignite.events.DiscoveryEvent)3 GridAffinityFunctionContextImpl (org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl)3