Skip to content

Commit 9644dcf

Browse files
committed
Removed specific tests that are duplicated by internal httpproxy testing.
1 parent 01671f7 commit 9644dcf

File tree

4 files changed

+13
-224
lines changed

4 files changed

+13
-224
lines changed

driver/src/test/java/oracle/nosql/driver/OnPremiseTest.java

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -607,74 +607,6 @@ public void testMultiRegion() {
607607
getTable("mrtable", handle);
608608
}
609609

610-
@Test
611-
public void testQueryWithSmallLimit() {
612-
final int recordKB = 2;
613-
final int minRead = 1;
614-
615-
String ddl = "create table smallLimitTest(id integer, " +
616-
"longString string, primary key(id))";
617-
tableOperation(handle, ddl, null);
618-
619-
/* Load 2 rows to table */
620-
PutRequest putReq = new PutRequest().setTableName("smallLimitTest");
621-
PutResult putRet;
622-
MapValue row;
623-
for (int i = 0; i < 2; i++) {
624-
row = new MapValue()
625-
.put("id", i)
626-
.put("longString", genString((recordKB - 1) * 1024));
627-
putReq.setValue(row);
628-
629-
putRet = handle.put(putReq);
630-
assertNotNull(putRet.getVersion());
631-
}
632-
633-
String query;
634-
QueryRequest req;
635-
QueryResult ret;
636-
637-
/* Update with number-based limit of 1 */
638-
int newRecordKB = 1;
639-
String longString = genString((newRecordKB - 1) * 1024);
640-
query = "update smallLimitTest set longString = \"" + longString +
641-
"\" where id = 0";
642-
req = new QueryRequest().setStatement(query).setLimit(1);
643-
ret = handle.query(req);
644-
assertNull(ret.getContinuationKey());
645-
646-
/* Update with maxReadKB of 1, expect an IAE */
647-
int expReadKB = minRead + recordKB;
648-
query = "update smallLimitTest set longString = \"" + longString +
649-
"\" where id = 1";
650-
for (int kb = 1; kb <= expReadKB; kb++) {
651-
req = new QueryRequest().setStatement(query).setMaxReadKB(kb);
652-
try {
653-
ret = handle.query(req);
654-
if (kb < expReadKB) {
655-
fail("Expected IAE");
656-
}
657-
} catch (IllegalArgumentException iae) {
658-
assertTrue("Unexpected IAE: " + iae.getMessage(),
659-
kb < expReadKB);
660-
}
661-
}
662-
663-
/* Query with maxReadKB of 1, expect an IAE */
664-
query = "select * from smallLimitTest";
665-
req = new QueryRequest().setStatement(query).setMaxReadKB(1);
666-
int numExec = 0;
667-
try {
668-
do {
669-
numExec++;
670-
ret = handle.query(req);
671-
} while (!req.isDone());
672-
fail("Expected IAE");
673-
} catch (IllegalArgumentException iae) {
674-
assertEquals(2, numExec);
675-
}
676-
}
677-
678610
@Test
679611
public void testSecureSysOp()
680612
throws Exception {

driver/src/test/java/oracle/nosql/driver/ProxyTestBase.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public class ProxyTestBase {
107107
@Override
108108
protected void starting(Description description) {
109109
if (trace) {
110-
System.out.println("Starting test: " +
111-
description.getMethodName() +
112-
" at time " + java.time.Instant.now());
110+
System.out.println(java.time.Instant.now() +
111+
" Starting test: " +
112+
description.getMethodName());
113113
}
114114
}
115115
};
@@ -123,6 +123,9 @@ public static void staticSetup() {
123123
endpoint = System.getProperty(ENDPOINT);
124124
serverType = System.getProperty(SERVER_TYPE);
125125
onprem = Boolean.getBoolean(ONPREM);
126+
if (serverType.equals("onprem")) {
127+
onprem = true;
128+
}
126129
secure = Boolean.getBoolean(SECURE);
127130
verbose = Boolean.getBoolean(VERBOSE);
128131
local = Boolean.getBoolean(LOCAL);
@@ -159,9 +162,6 @@ public static void staticSetup() {
159162
" system properties");
160163
}
161164

162-
if (serverType.equals("onprem")) {
163-
onprem = true;
164-
}
165165
}
166166

167167
/*

driver/src/test/java/oracle/nosql/driver/QueryTest.java

Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,78 +1127,6 @@ public void testPreparedLongRunning() {
11271127
assertTrue("Expected last request to pass, but it failed", lastPassed);
11281128
}
11291129

1130-
@Test
1131-
public void testQueryWithSmallLimit() {
1132-
final int numMajor = 1;
1133-
final int numPerMajor = 5;
1134-
final int recordKB = 2;
1135-
final int minRead = 1;
1136-
1137-
/* Load rows to table */
1138-
loadRowsToScanTable(numMajor, numPerMajor, recordKB);
1139-
1140-
String query;
1141-
QueryRequest req;
1142-
QueryResult ret;
1143-
1144-
/* Update with number-based limit of 1 */
1145-
int newRecordKB = 1;
1146-
String longString = genString((newRecordKB - 1) * 1024);
1147-
query = "update testTable set longString = \"" + longString +
1148-
"\" where sid = 0 and id = 0";
1149-
req = new QueryRequest().setStatement(query).setLimit(1);
1150-
ret = handle.query(req);
1151-
assertNull(ret.getContinuationKey());
1152-
1153-
/* Update with maxReadKB of 1, expect an IAE */
1154-
int expReadKB = minRead + recordKB;
1155-
query = "update testTable set longString = \"" + longString +
1156-
"\" where sid = 0 and id = 1";
1157-
for (int kb = 1; kb <= expReadKB; kb++) {
1158-
req = new QueryRequest().setStatement(query).setMaxReadKB(kb);
1159-
try {
1160-
ret = handle.query(req);
1161-
if (kb < expReadKB) {
1162-
fail("Expected IAE");
1163-
}
1164-
} catch (IllegalArgumentException iae) {
1165-
assertTrue("Expected success with maxReadKB of " + kb +
1166-
": " + iae.getMessage(), kb < expReadKB);
1167-
}
1168-
}
1169-
1170-
/* Update with maxReadKB of 1, 0 row updated */
1171-
query = "update testTable set longString = \"" + longString +
1172-
"\" where sid = 100 and id = 1";
1173-
req = new QueryRequest().setStatement(query).setMaxReadKB(1);
1174-
ret = handle.query(req);
1175-
assertNull(ret.getContinuationKey());
1176-
1177-
/* Query with number limit of 1 */
1178-
query = "select * from testTable where sid = 0 and id > 1";
1179-
int numRows = numMajor * (numPerMajor - 2);
1180-
expReadKB = getExpReadKB(false /* keyOnly */, recordKB,
1181-
numRows /* numReadRows */,
1182-
numRows /* numReadKeys */);
1183-
executeQuery(query, false /* keyOnly */, false/* indexScan */,
1184-
numRows, expReadKB, 1 /* limit */, 0 /* maxReadKB */,
1185-
recordKB);
1186-
1187-
/* Query with maxReadKB of 1, expect an IAE */
1188-
query = "select * from testTable";
1189-
req = new QueryRequest().setStatement(query).setMaxReadKB(1);
1190-
int numExec = 0;
1191-
try {
1192-
do {
1193-
numExec++;
1194-
ret = handle.query(req);
1195-
} while (!req.isDone());
1196-
fail("Expected IAE");
1197-
} catch (IllegalArgumentException iae) {
1198-
assertEquals(2, numExec);
1199-
}
1200-
}
1201-
12021130
/**
12031131
* Returns the estimated readKB.
12041132
*/
@@ -2025,15 +1953,6 @@ private void executeQuery(String statement,
20251953
queryReq.setConsistency(consistency);
20261954
}
20271955

2028-
int expReadUnits = expReadKB;
2029-
int expBatchReadUnits = (sizeLimit > 0) ? sizeLimit : READ_KB_LIMIT;
2030-
expBatchReadUnits += (indexScan && !keyOnly) ? recordKB : minRead;
2031-
expBatchReadUnits += (isDelete ? minRead : 0);
2032-
if (isAbsolute) {
2033-
expBatchReadUnits <<= 1;
2034-
expReadUnits <<= 1;
2035-
}
2036-
20371956
int numRows = 0;
20381957
int readKB = 0;
20391958
int writeKB = 0;
@@ -2058,21 +1977,6 @@ private void executeQuery(String statement,
20581977
int wkb = queryRes.getWriteKB();
20591978
int prepCost = (numBatches == 0 ? getMinQueryCost() : 0);
20601979

2061-
/*
2062-
* Make sure we didn't exceed the read limit. The "+ recordKB" is
2063-
* needed because at the RNs we allow the limit to be exceeded by
2064-
* 1 row, if we have already read the index entry for that row. The
2065-
* "+ 1" is needed for DELETE queries, because a row that satisfies
2066-
* the DELETE conditions, we read its primary-index once again to
2067-
* do the delete.
2068-
*/
2069-
2070-
/* on-prem the limit is not enforced -- this calc may not work */
2071-
int effectiveMaxReadKB = (queryReq.getMaxReadKB() == 0 ?
2072-
READ_KB_LIMIT : queryReq.getMaxReadKB());
2073-
assert(queryRes.getReadKB() <=
2074-
prepCost + effectiveMaxReadKB + recordKB + 1);
2075-
20761980
if (showResults) {
20771981
for (int i = 0; i < results.size(); ++i) {
20781982
System.out.println("Result " + (numRows + i) + " :");
@@ -2085,10 +1989,6 @@ private void executeQuery(String statement,
20851989
}
20861990

20871991
numRows += cnt;
2088-
2089-
assertTrue("Unexpected readUnits, expect <= " +
2090-
(expBatchReadUnits + prepCost) + ", but get " + runits,
2091-
runits <= (expBatchReadUnits + prepCost));
20921992
readKB += rkb;
20931993
readUnits += runits;
20941994
writeKB += wkb;
@@ -2103,32 +2003,9 @@ private void executeQuery(String statement,
21032003
" Total WriteKB = " + writeKB);
21042004
}
21052005

2106-
if (!onprem) {
2107-
assertTrue("Read KB and Read units should be > 0",
2108-
readKB > 0 && readUnits > 0);
2109-
}
21102006
assertEquals("Wrong number of rows returned, expect " + expNumRows +
21112007
", but get " + numRows, expNumRows, numRows);
21122008

2113-
if (expReadKB >= 0 && onprem == false) {
2114-
/*
2115-
* When read cost exceeds size limit after reading the key, the
2116-
* read cost possible has an additional MIN_READ exceeded per
2117-
* batch.
2118-
*/
2119-
int delta = (numBatches - 1) * minRead;
2120-
if (isAbsolute) {
2121-
delta <<= 1;
2122-
}
2123-
2124-
expReadUnits += totalPrepCost;
2125-
2126-
assertTrue("Unexpected read units, exp in range[" +
2127-
expReadUnits + ", " + (expReadUnits + delta) +
2128-
"] actual " + readUnits,
2129-
readUnits >= expReadUnits &&
2130-
readUnits <= expReadUnits + delta);
2131-
}
21322009
}
21332010

21342011
private void executeQuery(String query,
@@ -2160,7 +2037,6 @@ private void executeQuery(String query,
21602037

21612038
QueryResult queryRes;
21622039
int numRows = 0;
2163-
int totalReadKB = 0;
21642040

21652041
do {
21662042
queryRes = handle.query(queryReq);
@@ -2176,26 +2052,6 @@ private void executeQuery(String query,
21762052
" ReadUnits = " + queryRes.getReadUnits());
21772053
}
21782054

2179-
/*
2180-
* Note: in some rare cases we may get zero readKB with 1 result.
2181-
* From Markos:
2182-
*
2183-
* When we do index/sort based group by, if we reach the read limit
2184-
* in the middle of computing a group, we include the partially
2185-
* computed group row in the continuation key. When we send the
2186-
* continuation key back, we may discover (without reading any
2187-
* bytes) that the group was actually fully computed, and we now
2188-
* send it back as a result.
2189-
*
2190-
* So we take this rare case into account by allowing zero readKB
2191-
* if the numresults is 1 and we've already accumulated readKBs.
2192-
*/
2193-
if (!onprem &&
2194-
(queryRes.getResults().size() != 1 || totalReadKB == 0)) {
2195-
assertTrue(queryRes.getReadKB() > 0);
2196-
}
2197-
2198-
totalReadKB += queryRes.getReadKB();
21992055
} while (!queryReq.isDone());
22002056

22012057
assertTrue("Wrong number of rows returned, expect " + expNumRows +

driver/src/test/java/oracle/nosql/driver/RateLimiterTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,12 @@ private void doRateLimitedQueries(int numSeconds,
315315
prepRes.getPreparedStatement() != null);
316316
readUnitsUsed += prepRes.getReadUnits();
317317

318+
if (maxKB <= 0) {
319+
maxKB = (int)((readLimit * usePercent)/100.0);
320+
}
321+
318322
if (verbose) System.out.println("Running queries: RUs=" +
319-
readLimit + " percent=" + usePercent);
323+
readLimit + " percent=" + usePercent + " maxKB=" + maxKB);
320324

321325
do {
322326
/*
@@ -326,11 +330,8 @@ private void doRateLimitedQueries(int numSeconds,
326330
*/
327331
QueryRequest queryReq = new QueryRequest()
328332
.setPreparedStatement(prepRes)
329-
.setTimeout(20000);
330-
if (maxKB > 0) {
331-
/* Query with size limit */
332-
queryReq.setMaxReadKB(maxKB);
333-
}
333+
.setTimeout(20000)
334+
.setMaxReadKB(maxKB);
334335
queryReq.setReadRateLimiter(rlim);
335336
queryReq.setWriteRateLimiter(wlim);
336337
try {

0 commit comments

Comments
 (0)