Skip to content

Commit

Permalink
ISPN-12666 ReplicationIndexTest random failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fernandes authored and karesti committed Jan 29, 2021
1 parent 03569b0 commit 2b1bf61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX;
import static org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME;
import static org.infinispan.test.TestingUtil.blockUntilCacheStatusAchieved;
import static org.infinispan.test.TestingUtil.blockUntilViewReceived;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;

import java.io.IOException;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.infinispan.Cache;
import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.Search;
Expand All @@ -24,14 +19,12 @@
import org.infinispan.client.hotrod.test.InternalRemoteCacheManager;
import org.infinispan.client.hotrod.test.MultiHotRodServersTest;
import org.infinispan.commons.marshall.ProtoStreamMarshaller;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.protostream.SerializationContext;
import org.infinispan.protostream.annotations.ProtoDoc;
import org.infinispan.protostream.annotations.ProtoField;
import org.infinispan.protostream.annotations.ProtoSchemaBuilder;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.test.TestingUtil;
import org.testng.annotations.Test;

/**
Expand Down Expand Up @@ -72,13 +65,6 @@ protected void addNode() throws IOException {
.storage(LOCAL_HEAP)
.addIndexedEntity("Entity");
cacheManager.defineConfiguration(CACHE_NAME, builder.build());

// Wait for state transfer on the test caches
Cache<?, ?> cache = cacheManager.getCache(CACHE_NAME);
blockUntilViewReceived(cache, index);
blockUntilCacheStatusAchieved(cache, ComponentStatus.RUNNING, 10000);
Collection<Cache<?, ?>> caches = cacheManagers.stream().map(cm -> cm.getCache(CACHE_NAME)).collect(Collectors.toList());
TestingUtil.waitForNoRebalance(caches);
}

protected boolean isTransactional() {
Expand Down Expand Up @@ -141,6 +127,8 @@ public void testIndexingDuringStateTransfer() throws IOException {

addNode();

waitForClusterToForm(CACHE_NAME);

RemoteCache<Object, Object> secondRemoteCache = clients.get(1).getCache(CACHE_NAME);
assertIndexed(secondRemoteCache);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheN
// a remote query manager must be added for each non-internal cache
SerializationContext serCtx = protobufMetadataManager.getSerializationContext();

// RemoteQueryManager can manipulate the registry, so create it before rewiring the cache below
// to avoid triggering a state transfer
RemoteQueryManager remoteQueryManager = buildQueryManager(cfg, serCtx, cr);
cr.registerComponent(remoteQueryManager, RemoteQueryManager.class);

SearchMappingCommonBuilding commonBuilding = cr.getComponent(SearchMappingCommonBuilding.class);
SearchMapping searchMapping = cr.getComponent(SearchMapping.class);
if (commonBuilding != null && searchMapping == null) {
Expand All @@ -168,9 +173,6 @@ public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheN
}
}

RemoteQueryManager remoteQueryManager = buildQueryManager(cfg, serCtx, cr);
cr.registerComponent(remoteQueryManager, RemoteQueryManager.class);

if (cfg.indexing().enabled()) {
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
if (cache.getValueDataConversion().getStorageMediaType().match(MediaType.APPLICATION_PROTOSTREAM)) {
Expand Down

0 comments on commit 2b1bf61

Please sign in to comment.