add TENANT_LIST to existing tests

This commit is contained in:
Jon Fu 2022-04-13 16:25:01 -04:00
parent c683795f6b
commit c0aa361885
4 changed files with 20 additions and 0 deletions

View File

@ -483,6 +483,14 @@ public class AsyncStackTester {
inst.push(TenantManagement.deleteTenant(inst.context.db, tenantName));
}, FDB.DEFAULT_EXECUTOR);
}
else if (op == StackOperation.TENANT_LIST) {
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));
}, FDB.DEFAULT_EXECUTOR);
}
else if (op == StackOperation.TENANT_SET_ACTIVE) {
return inst.popParam().thenAcceptAsync(param -> {
byte[] tenantName = (byte[])param;

View File

@ -76,6 +76,7 @@ enum StackOperation {
// Tenants
TENANT_CREATE,
TENANT_DELETE,
TENANT_LIST,
TENANT_SET_ACTIVE,
TENANT_CLEAR_ACTIVE,

View File

@ -429,6 +429,13 @@ public class StackTester {
byte[] tenantName = (byte[])inst.popParam().join();
inst.push(TenantManagement.deleteTenant(inst.context.db, tenantName));
}
else if (op == StackOperation.TENANT_LIST) {
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));
}
else if (op == StackOperation.TENANT_SET_ACTIVE) {
byte[] tenantName = (byte[])inst.popParam().join();
inst.context.setTenant(Optional.of(tenantName));

View File

@ -59,6 +59,10 @@ def test_tenant_operations(db):
fdb.tenant_management.create_tenant(db, b'tenant1')
fdb.tenant_management.create_tenant(db, b'tenant2')
tenant_list = fdb.tenant_management.list_tenants(db, b'a', b'z', 10).to_list()
assert tenant_list[0] == b'tenant1'
assert tenant_list[1] == b'tenant2'
tenant1 = db.open_tenant(b'tenant1')
tenant2 = db.open_tenant(b'tenant2')