Skip to content

Commit

Permalink
Add retry for index creation in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anastasiia Smirnova committed Jul 22, 2020
1 parent 80bd9f5 commit 11e88aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,14 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(namespace, set, field, type);
}

@Override
public String toString() {
return "IndexKey{" +
"namespace='" + namespace + '\'' +
", set='" + set + '\'' +
", field='" + field + '\'' +
", type=" + type +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
import com.aerospike.client.query.IndexType;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.aerospike.AwaitilityUtils;
import org.springframework.data.aerospike.BaseBlockingIntegrationTests;
import org.springframework.data.aerospike.IndexUtils;
import org.springframework.data.aerospike.query.model.Index;
import org.springframework.data.aerospike.query.model.IndexKey;

import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

public abstract class BaseQueryEngineTests extends BaseBlockingIntegrationTests {

Expand All @@ -32,8 +39,13 @@ protected void tryDropIndex(String namespace, String setName, String indexName)
}

protected void tryCreateIndex(String namespace, String setName, String indexName, String binName, IndexType indexType) {
IndexUtils.createIndex(client, namespace, setName, indexName, binName, indexType);
indexRefresher.refreshIndexes();
AwaitilityUtils.awaitTenSecondsUntil(() -> {
IndexUtils.createIndex(client, namespace, setName, indexName, binName, indexType);
indexRefresher.refreshIndexes();
IndexKey indexKey = new IndexKey(namespace, setName, binName, indexType);
Optional<Index> index = indexesCache.getIndex(indexKey);
assertThat(index).as("Index for: " + indexKey + " not created").isPresent();
});
}

protected void tryCreateIndex(String namespace, String setName, String indexName, String binName, IndexType indexType,
Expand Down

0 comments on commit 11e88aa

Please sign in to comment.