Skip to content

Commit

Permalink
nuke comment
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Khludnev <mkhl@apache.org>
  • Loading branch information
mkhludnev committed Nov 20, 2024
1 parent a502056 commit 7e1f8b4
Showing 1 changed file with 0 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,97 +150,6 @@ private static String dumpException(OpenSearchException ose) {
return out.toString();
}

// public void testMassive() throws Exception {
// XContentBuilder xcb = createMapping();
// client().admin().indices().prepareCreate(defaultIndexName).setMapping(xcb).get();
// ensureGreen();
//
// BulkRequestBuilder bulkRequestBuilder = client().prepareBulk();
//
// Set<String> dedupeCidrs = new HashSet<>();
// int cidrs = 0;
// int ips = 0;
// List<String> toQuery = new ArrayList<>();
// for (int i = 0; ips <= 10240 && cidrs <= IndexSearcher.getMaxClauseCount()+10 && i < 1000000; i++) {
// String ip;
// int prefix;
// boolean mask;
// do{
// mask = random().nextBoolean();
// ip = generateRandomIPv4();
// prefix = 24 + random().nextInt(8); // CIDR prefix for IPv4
// }while(mask && !dedupeCidrs.add(getFirstThreeOctets(ip)));
//
// bulkRequestBuilder.add(client().prepareIndex(defaultIndexName).
// setSource(Map.of("addr", ip, "dummy_filter", randomSubsetOf(1,"1","2","3"))));
//
// final String termToQuery;
// if (random().nextBoolean()) {
// termToQuery = ip + "/" + prefix;
// cidrs++;
// } else {
// termToQuery = ip;
// ips++;
// }
// toQuery.add(termToQuery);
//
// if (cidrs == IndexSearcher.getMaxClauseCount()-1) {
// bulkRequestBuilder.setRefreshPolicy(IMMEDIATE).get();
// bulkRequestBuilder = client().prepareBulk();
// long expectedMatches = (long) cidrs + ips ;
// assertTermsHitCount("addr.dv", toQuery, expectedMatches);
// // after this passed add dummy filter
// assertTermsHitCount("addr.dv", toQuery, expectedMatches, (boolBuilder)->{
// boolBuilder.filter(QueryBuilders.termsQuery("dummy_filter","1","2","3"))
// .filter(QueryBuilders.termsQuery("dummy_filter","1","2","3","4"))
// .filter(QueryBuilders.termsQuery("dummy_filter","1","2","3","4","5"));
// });
// }
// if (cidrs == IndexSearcher.getMaxClauseCount()) {// this exceeds clauses precondition
// bulkRequestBuilder.setRefreshPolicy(IMMEDIATE).get();
// bulkRequestBuilder = client().prepareBulk();
// long expectedMatches = (long) cidrs + ips ;
// assertTermsHitCount("addr.dv", toQuery, expectedMatches);
// }
// }
// int addMatches = 0;
// for (int i = 0; i < atLeast(100); i++) {
// final String ip;
// ip = generateRandomIPv4();
// bulkRequestBuilder.add(client().prepareIndex(defaultIndexName).setSource(Map.of("addr", ip,
// "dummy_filter", randomSubsetOf(1,"1","2","3"))));
// boolean match = false;
// for (String termQ : toQuery) {
// boolean isCidr = termQ.contains("/");
// if ((isCidr && isIPInCIDR(ip, termQ)) || (!isCidr && termQ.equals(ip))) {
// match = true;
// break;
// }
// }
// if (match) {
// addMatches++;
// } else {
// break; // single mismatch is enough.
// }
// }
//
// bulkRequestBuilder.setRefreshPolicy(IMMEDIATE).get();
// long expectedMatches = (long) cidrs + ips + addMatches;
// for (String field : List.of("addr", "addr.idx" /*"addr.dv"*/)) {
// assertTermsHitCount(field, toQuery, expectedMatches);
// }
//
// try {
// assertTermsHitCount("addr.dv", toQuery, expectedMatches);
// fail();
// }catch (SearchPhaseExecutionException tmc) {
// Throwable cause = tmc.shardFailures()[0].getCause().getCause();
// assertTrue (cause instanceof IndexSearcher.TooManyClauses);
// assertTrue(cause.getMessage().contains("IP"));
// assertTrue(cause.getMessage().contains("masks"));
// }
// }

public static String getFirstThreeOctets(String ipAddress) {
// Split the IP address by the dot delimiter
String[] octets = ipAddress.split("\\.");
Expand Down

0 comments on commit 7e1f8b4

Please sign in to comment.