Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Shourya Dutta Biswas <114977491+shourya035@users.noreply.github.com>
  • Loading branch information
shourya035 committed Sep 4, 2023
1 parent a0eb936 commit b2e5dc6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ public void testSingleNodeNoFlush() throws Exception {
value2Docs = 1;
}

for (int i = 0; i < 1 + randomInt(100); i++) {
for (int id = 0; id < Math.max(value1Docs, value2Docs); id++) {
for (int i = 0; i < 1 + randomInt(10); i++) {
int toIndex = Math.max(value1Docs, value2Docs);
logger.info("About to index " + toIndex + " documents");
for (int id = 0; id < toIndex; id++) {
if (id < value1Docs) {
index(
"test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.action.index.MappingUpdatedAction;
import org.opensearch.cluster.block.ClusterBlockLevel;
import org.opensearch.cluster.coordination.ClusterBootstrapService;
import org.opensearch.cluster.coordination.NoClusterManagerBlockService;
import org.opensearch.cluster.metadata.IndexMetadata;
Expand Down Expand Up @@ -92,6 +93,7 @@
import org.opensearch.env.Environment;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.env.ShardLockObtainFailedException;
import org.opensearch.gateway.GatewayService;
import org.opensearch.http.HttpServerTransport;
import org.opensearch.index.IndexService;
import org.opensearch.index.IndexingPressure;
Expand Down Expand Up @@ -1320,7 +1322,16 @@ public synchronized void validateClusterFormed() {
}
});
states.forEach(cs -> {
if (cs.nodes().getNodes().values().stream().findFirst().get().isRemoteStoreNode()) {
/* Adding check to ensure that the repository checks are only performed when the cluster state has been recovered.
Useful for test cases which deliberately block cluster state recovery through gateway.xxxx cluster settings
*/
if (!cs.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK) && cs.nodes()
.getNodes()
.values()
.stream()
.findFirst()
.get()
.isRemoteStoreNode()) {
RepositoriesMetadata repositoriesMetadata = cs.metadata().custom(RepositoriesMetadata.TYPE);
assertTrue(repositoriesMetadata != null && !repositoriesMetadata.repositories().isEmpty());
}
Expand Down

0 comments on commit b2e5dc6

Please sign in to comment.