protected void doTestPartitionsQuery(Ignite orig) {
IgniteCache<ClientKey, Client> cl = orig.cache("cl");
for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
log().info("Running test queries for region " + regionId);
List<Integer> range = REGION_TO_PART_MAP.get(regionId);
int[] parts = createRange(range.get(0), range.get(1));
int off = rnd.nextInt(parts.length);
int p1 = parts[off], p2 = parts[(off + (1 + rnd.nextInt(parts.length-1))) % parts.length];
log().info("Parts: " + p1 + " " + p2);
SqlQuery<ClientKey, Client> qry = new SqlQuery<>(Client.class, "1=1");
qry.setPartitions(p1, p2);
try {
List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry).getAll();
for (Cache.Entry<ClientKey, Client> client : clients) {
int p = orig.affinity("cl").partition(client.getKey());
assertTrue("Incorrect partition for key", p == p1 || p == p2);
}
if (regionId == UNMAPPED_REGION)
fail();
} catch (CacheException ignored) {
if (regionId != UNMAPPED_REGION)
fail();
}
}
}