fixed some binding tests and split stack operation between key and value of tenant list
This commit is contained in:
parent
a5e52c9450
commit
2afaf55a48
|
@ -165,7 +165,7 @@ class ApiTest(Test):
|
|||
write_conflicts = ['WRITE_CONFLICT_RANGE', 'WRITE_CONFLICT_KEY', 'DISABLE_WRITE_CONFLICT']
|
||||
txn_sizes = ['GET_APPROXIMATE_SIZE']
|
||||
storage_metrics = ['GET_ESTIMATED_RANGE_SIZE', 'GET_RANGE_SPLIT_POINTS']
|
||||
tenants = ['TENANT_CREATE', 'TENANT_DELETE', 'TENANT_SET_ACTIVE', 'TENANT_CLEAR_ACTIVE']
|
||||
tenants = ['TENANT_CREATE', 'TENANT_DELETE', 'TENANT_SET_ACTIVE', 'TENANT_CLEAR_ACTIVE', 'TENANT_LIST_NAMES']
|
||||
|
||||
op_choices += reads
|
||||
op_choices += mutations
|
||||
|
@ -600,8 +600,8 @@ class ApiTest(Test):
|
|||
instructions.append(op)
|
||||
elif op == 'TENANT_CLEAR_ACTIVE':
|
||||
instructions.append(op)
|
||||
elif op == 'TENANT_LIST':
|
||||
instructions.push_args(b'', b'\xff', 10)
|
||||
elif op == 'TENANT_LIST_NAMES':
|
||||
instructions.push_args(b'', b'\xff', 10000)
|
||||
instructions.append(op)
|
||||
self.add_strings(1)
|
||||
else:
|
||||
|
|
|
@ -33,6 +33,8 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.apple.foundationdb.Database;
|
||||
import com.apple.foundationdb.FDB;
|
||||
|
@ -48,6 +50,7 @@ import com.apple.foundationdb.Transaction;
|
|||
import com.apple.foundationdb.async.AsyncUtil;
|
||||
import com.apple.foundationdb.tuple.ByteArrayUtil;
|
||||
import com.apple.foundationdb.tuple.Tuple;
|
||||
import com.apple.foundationdb.async.CloseableAsyncIterator;
|
||||
|
||||
public class AsyncStackTester {
|
||||
static final String DIRECTORY_PREFIX = "DIRECTORY_";
|
||||
|
@ -483,12 +486,27 @@ public class AsyncStackTester {
|
|||
inst.push(TenantManagement.deleteTenant(inst.context.db, tenantName));
|
||||
}, FDB.DEFAULT_EXECUTOR);
|
||||
}
|
||||
else if (op == StackOperation.TENANT_LIST) {
|
||||
else if (op == StackOperation.TENANT_LIST_NAMES) {
|
||||
return inst.popParams(3).thenAcceptAsync(params -> {
|
||||
byte[] begin = (byte[])params.get(0);
|
||||
byte[] end = (byte[])params.get(1);
|
||||
int limit = StackUtils.getInt(params.get(2));
|
||||
inst.push(TenantManagement.listTenants(inst.context.db, begin, end, limit));
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenants(inst.context.db, begin, end, limit);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
while (tenantIter.hasNext()) {
|
||||
try {
|
||||
KeyValue next = tenantIter.next();
|
||||
outputStream.write(next.getKey());
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
tenantIter.close();
|
||||
}
|
||||
byte[] output = outputStream.toByteArray();
|
||||
inst.push(output);
|
||||
}, FDB.DEFAULT_EXECUTOR);
|
||||
}
|
||||
else if (op == StackOperation.TENANT_SET_ACTIVE) {
|
||||
|
|
|
@ -76,7 +76,7 @@ enum StackOperation {
|
|||
// Tenants
|
||||
TENANT_CREATE,
|
||||
TENANT_DELETE,
|
||||
TENANT_LIST,
|
||||
TENANT_LIST_NAMES,
|
||||
TENANT_SET_ACTIVE,
|
||||
TENANT_CLEAR_ACTIVE,
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package com.apple.foundationdb.test;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
@ -429,12 +431,27 @@ public class StackTester {
|
|||
byte[] tenantName = (byte[])inst.popParam().join();
|
||||
inst.push(TenantManagement.deleteTenant(inst.context.db, tenantName));
|
||||
}
|
||||
else if (op == StackOperation.TENANT_LIST) {
|
||||
else if (op == StackOperation.TENANT_LIST_NAMES) {
|
||||
List<Object> params = inst.popParams(3).join();
|
||||
byte[] begin = (byte[])params.get(0);
|
||||
byte[] end = (byte[])params.get(1);
|
||||
int limit = StackUtils.getInt(params.get(2));
|
||||
inst.push(TenantManagement.listTenants(inst.context.db, begin, end, limit));
|
||||
CloseableAsyncIterator<KeyValue> tenantIter = TenantManagement.listTenants(inst.context.db, begin, end, limit);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try {
|
||||
while (tenantIter.hasNext()) {
|
||||
try {
|
||||
KeyValue next = tenantIter.next();
|
||||
outputStream.write(next.getKey());
|
||||
} catch (IOException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
tenantIter.close();
|
||||
}
|
||||
byte[] output = outputStream.toByteArray();
|
||||
inst.push(output);
|
||||
}
|
||||
else if (op == StackOperation.TENANT_SET_ACTIVE) {
|
||||
byte[] tenantName = (byte[])inst.popParam().join();
|
||||
|
|
|
@ -92,11 +92,9 @@ class FDBTenantList(object):
|
|||
return list(self.__iter__())
|
||||
|
||||
def __iter__(self):
|
||||
while True:
|
||||
result = self._iter.__next__()
|
||||
|
||||
tenant_name = _impl.remove_prefix(result.key, _tenant_map_prefix)
|
||||
yield _impl.KeyValue(tenant_name, result.value)
|
||||
for next_item in self._iter:
|
||||
tenant_name = _impl.remove_prefix(next_item.key, _tenant_map_prefix)
|
||||
yield _impl.KeyValue(tenant_name, next_item.value)
|
||||
|
||||
# Lists the tenants created in the cluster, specified by the begin and end range.
|
||||
# Also limited in number of results by the limit parameter.
|
||||
|
|
|
@ -604,12 +604,14 @@ class Tester:
|
|||
self.tenant = self.db.open_tenant(name)
|
||||
elif inst.op == six.u("TENANT_CLEAR_ACTIVE"):
|
||||
self.tenant = None
|
||||
elif inst.op == six.u("TENANT_LIST"):
|
||||
begin = inst.pop()
|
||||
end = inst.pop()
|
||||
limit = inst.pop()
|
||||
elif inst.op == six.u("TENANT_LIST_NAMES"):
|
||||
begin, end, limit = inst.pop(3)
|
||||
tenant_list = fdb.tenant_management.list_tenants(self.db, begin, end, limit)
|
||||
inst.push(tenant_list)
|
||||
result = bytearray()
|
||||
for tenant in tenant_list:
|
||||
result += tenant.key
|
||||
result_bytes = bytes(result)
|
||||
inst.push(result_bytes)
|
||||
elif inst.op == six.u("UNIT_TESTS"):
|
||||
try:
|
||||
test_db_options(db)
|
||||
|
|
Loading…
Reference in New Issue