You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/17 12:43:43 UTC
[30/50] incubator-ignite git commit: # ignite-sprint-6 tests fixes
# ignite-sprint-6 tests fixes
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e3750b78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e3750b78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e3750b78
Branch: refs/heads/ignite-gg-10052
Commit: e3750b78c9fa6b50bee2b35506c706ac4b79126e
Parents: f2c4cc8
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 16 16:45:27 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 16 16:52:04 2015 +0300
----------------------------------------------------------------------
.../GridDiscoveryManagerAliveCacheSelfTest.java | 17 ++++++---
.../distributed/IgniteCacheManyClientsTest.java | 11 +++---
.../GridCachePartitionedTxSalvageSelfTest.java | 37 +++-----------------
3 files changed, 24 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
index ba61890..6e199b8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
@@ -195,8 +195,11 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
*/
@SuppressWarnings("SuspiciousMethodCalls")
private void validateAlives() {
- for (Ignite g : alive)
- assertEquals(PERM_NODES_CNT, g.cluster().nodes().size());
+ for (Ignite g : alive) {
+ log.info("Validate node: " + g.name());
+
+ assertEquals("Unexpected nodes number for node: " + g.name(), PERM_NODES_CNT, g.cluster().nodes().size());
+ }
for (final Ignite g : alive) {
IgniteKernal k = (IgniteKernal)g;
@@ -222,8 +225,14 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
}
});
- assertTrue(
- currTop.contains(GridCacheUtils.oldestAliveCacheServerNode(k.context().cache().context(), new AffinityTopologyVersion(currVer))));
+ GridCacheSharedContext<?, ?> ctx = k.context().cache().context();
+
+ ClusterNode oldest =
+ GridCacheUtils.oldestAliveCacheServerNode(ctx, new AffinityTopologyVersion(currVer));
+
+ assertNotNull(oldest);
+
+ assertTrue(currTop.contains(oldest));
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
index 947ded2..c3223a2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
@@ -160,10 +160,13 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
log.info("All clients started.");
- checkNodes(SRVS + CLIENTS);
-
- for (Ignite client : clients)
- client.close();
+ try {
+ checkNodes(SRVS + CLIENTS);
+ }
+ finally {
+ for (Ignite client : clients)
+ client.close();
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e3750b78/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 6192f39..c1a19a4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -21,7 +21,6 @@ import org.apache.ignite.*;
import org.apache.ignite.cache.affinity.rendezvous.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
-import org.apache.ignite.internal.processors.affinity.*;
import org.apache.ignite.internal.processors.cache.*;
import org.apache.ignite.internal.processors.cache.transactions.*;
import org.apache.ignite.internal.util.typedef.internal.*;
@@ -147,8 +146,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
* Check whether caches has no transactions after salvage timeout.
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
- * @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * @param prepare Whether to prepare transaction state (i.e. call {@link IgniteInternalTx#prepare()}).
* @throws Exception If failed.
*/
private void checkSalvageAfterTimeout(TransactionConcurrency mode, boolean prepare) throws Exception {
@@ -193,14 +191,13 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
* Start new transaction on the grid(0) and put some keys to it.
*
* @param mode Transaction mode (PESSIMISTIC, OPTIMISTIC).
- * @param prepare Whether to prepare transaction state
- * (i.e. call {@link IgniteInternalTx#prepare()}).
+ * @param prepare Whether to prepare transaction state (i.e. call {@link IgniteInternalTx#prepare()}).
* @throws Exception If failed.
*/
private void startTxAndPutKeys(final TransactionConcurrency mode, final boolean prepare) throws Exception {
Ignite ignite = grid(0);
- final Collection<Integer> keys = nearKeys(ignite);
+ final Collection<Integer> keys = nearKeys(ignite.cache(null), KEY_CNT, 0);
IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
@Override public void run() {
@@ -239,31 +236,6 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
}
/**
- * Gets keys that are not primary nor backup for node.
- *
- * @param ignite Grid.
- * @return Collection of keys.
- */
- private Collection<Integer> nearKeys(Ignite ignite) {
- final Collection<Integer> keys = new ArrayList<>(KEY_CNT);
-
- IgniteKernal kernal = (IgniteKernal) ignite;
-
- GridCacheAffinityManager affMgr = kernal.internalCache().context().affinity();
-
- for (int i = 0; i < KEY_CNT * GRID_CNT * 1.5; i++) {
- if (!affMgr.localNode((Object)i, new AffinityTopologyVersion(kernal.context().discovery().topologyVersion()))) {
- keys.add(i);
-
- if (keys.size() == KEY_CNT)
- break;
- }
- }
-
- return keys;
- }
-
- /**
* Checks that transaction manager for cache context does not have any pending transactions.
*
* @param ctx Cache context.
@@ -283,7 +255,6 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
private void checkTxsNotEmpty(GridCacheContext ctx, int exp) {
int size = ctx.tm().txs().size();
- assert size == exp : "Some transactions were salvaged unexpectedly: " + exp +
- " expected, but only " + size + " found.";
+ assertEquals("Some transactions were salvaged unexpectedly", exp, size);
}
}