Skip to content

Commit

Permalink
ignite-257: fixed most of the test. Only collocated and near tests ar…
Browse files Browse the repository at this point in the history
…e keep failing.
  • Loading branch information
Denis Magda committed Sep 11, 2015
1 parent e1707b6 commit b5d8545
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
Expand Up @@ -26,7 +26,9 @@
import javax.cache.CacheException;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
Expand Down Expand Up @@ -64,7 +66,7 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
private static final int NOT_PRIMARY_AND_BACKUP = 2;

/** */
private static Integer lastKey;
private static volatile Integer lastKey;

/** {@inheritDoc} */
@Override protected int gridCount() {
Expand All @@ -91,6 +93,8 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
ccfg.setWriteThrough(false);
ccfg.setLoadPreviousValue(true);

ccfg.setIndexedTypes(Integer.class, Integer.class);

return ccfg;
}

Expand All @@ -105,8 +109,18 @@ public abstract class IgniteTxExceptionAbstractSelfTest extends GridCacheAbstrac
@Override protected void afterTest() throws Exception {
idxSpi.forceFail(false);

for (int key = 0; key < lastKey; key++)
Transaction tx = jcache().unwrap(Ignite.class).transactions().tx();

if (tx != null) {
tx.close();

fail("Cache transaction remained after test completion: " + tx);
}

for (int key = 0; key <= lastKey; key++)
grid(0).cache(null).remove(key);

assertEquals(0, jcache(0).size(CachePeekMode.ALL));
}

/** {@inheritDoc} */
Expand Down Expand Up @@ -367,7 +381,7 @@ private void checkUnlocked(final Integer key) throws Exception {
info("Check key: " + key);

for (int i = 0; i < gridCount(); i++) {
IgniteKernal grid = (IgniteKernal) grid(i);
IgniteKernal grid = (IgniteKernal)grid(i);

GridCacheAdapter cache = grid.internalCache(null);

Expand All @@ -383,9 +397,8 @@ private void checkUnlocked(final Integer key) throws Exception {

log.info("Dht entry: " + entry);

if (entry != null) {
if (entry != null)
assertFalse("Unexpected entry for grid [i=" + i + ", entry=" + entry + ']', entry.lockedByAny());
}
}
}
}
Expand Down Expand Up @@ -459,7 +472,7 @@ private void checkTransform(boolean putBefore, final Integer key) throws Excepti
}
}, CacheException.class, null);

assertTrue("Unexpected cause: " +e, e.getCause() instanceof TransactionHeuristicException);
assertTrue("Unexpected cause: " + e, e.getCause() instanceof TransactionHeuristicException);

checkUnlocked(key);
}
Expand All @@ -469,7 +482,7 @@ private void checkTransform(boolean putBefore, final Integer key) throws Excepti
* @param keys Keys.
* @throws Exception If failed.
*/
private void checkPutAll(boolean putBefore, Integer ... keys) throws Exception {
private void checkPutAll(boolean putBefore, Integer... keys) throws Exception {
assert keys.length > 1;

if (putBefore) {
Expand Down Expand Up @@ -616,7 +629,7 @@ public void forceFail(boolean fail) {
}

/** {@inheritDoc} */
@Override public Iterator<Cache.Entry<?,?>> query(@Nullable String spaceName, Collection<Object> params,
@Override public Iterator<Cache.Entry<?, ?>> query(@Nullable String spaceName, Collection<Object> params,
@Nullable IndexingQueryFilter filters) throws IgniteSpiException {
throw new UnsupportedOperationException();
}
Expand Down
Expand Up @@ -27,11 +27,6 @@
* Tests colocated cache.
*/
public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return PARTITIONED;
Expand All @@ -41,4 +36,19 @@ public class GridCacheColocatedTxExceptionSelfTest extends IgniteTxExceptionAbst
@Override protected NearCacheConfiguration nearConfiguration() {
return null;
}

/** {@inheritDoc} */
@Override public void testRemovePrimary() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

/** {@inheritDoc} */
@Override public void testPutPrimary() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

/** {@inheritDoc} */
@Override public void testTransformPrimary() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}
}
Expand Up @@ -27,7 +27,7 @@
*/
public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
@Override protected void beforeTestsStarted() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

Expand Down
Expand Up @@ -27,11 +27,6 @@
* Tests replicated cache.
*/
public class GridCacheReplicatedTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

/** {@inheritDoc} */
@Override protected CacheMode cacheMode() {
return REPLICATED;
Expand Down
Expand Up @@ -26,11 +26,6 @@
* Tests local cache.
*/
public class GridCacheLocalTxExceptionSelfTest extends IgniteTxExceptionAbstractSelfTest {
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-257");
}

/** {@inheritDoc} */
@Override protected int gridCount() {
return 1;
Expand Down

0 comments on commit b5d8545

Please sign in to comment.