mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-14 18:02:31 +08:00
Moved up the new test cases to comply the convention there.
This commit is contained in:
parent
527686ffe0
commit
338c62b176
@ -638,6 +638,29 @@ struct GetFunc : InstructionFunc {
|
|||||||
const char* GetFunc::name = "GET";
|
const char* GetFunc::name = "GET";
|
||||||
REGISTER_INSTRUCTION_FUNC(GetFunc);
|
REGISTER_INSTRUCTION_FUNC(GetFunc);
|
||||||
|
|
||||||
|
struct GetEstimatedRangeSize : InstructionFunc {
|
||||||
|
static const char* name;
|
||||||
|
|
||||||
|
ACTOR static Future<Void> call(Reference<FlowTesterData> data, Reference<InstructionData> instruction) {
|
||||||
|
state std::vector<StackItem> items = data->stack.pop(2);
|
||||||
|
if (items.size() != 2)
|
||||||
|
return Void();
|
||||||
|
|
||||||
|
Standalone<StringRef> s1 = wait(items[0].value);
|
||||||
|
state Standalone<StringRef> beginKey = Tuple::unpack(s1).getString(0);
|
||||||
|
|
||||||
|
Standalone<StringRef> s2 = wait(items[1].value);
|
||||||
|
state Standalone<StringRef> endKey = Tuple::unpack(s2).getString(0);
|
||||||
|
Future<int64_t> fsize = instruction->tr->getEstimatedRangeSizeBytes(KeyRangeRef(beginKey, endKey));
|
||||||
|
int64_t size = wait(fsize);
|
||||||
|
data->stack.pushTuple(LiteralStringRef("GOT_ESTIMATED_RANGE_SIZE"));
|
||||||
|
|
||||||
|
return Void();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const char* GetEstimatedRangeSize::name = "GET_ESTIMATED_RANGE_SIZE";
|
||||||
|
REGISTER_INSTRUCTION_FUNC(GetEstimatedRangeSize);
|
||||||
|
|
||||||
struct GetKeyFunc : InstructionFunc {
|
struct GetKeyFunc : InstructionFunc {
|
||||||
static const char* name;
|
static const char* name;
|
||||||
|
|
||||||
@ -1614,29 +1637,6 @@ struct UnitTestsFunc : InstructionFunc {
|
|||||||
const char* UnitTestsFunc::name = "UNIT_TESTS";
|
const char* UnitTestsFunc::name = "UNIT_TESTS";
|
||||||
REGISTER_INSTRUCTION_FUNC(UnitTestsFunc);
|
REGISTER_INSTRUCTION_FUNC(UnitTestsFunc);
|
||||||
|
|
||||||
struct GetEstimatedRangeSize : InstructionFunc {
|
|
||||||
static const char* name;
|
|
||||||
|
|
||||||
ACTOR static Future<Void> call(Reference<FlowTesterData> data, Reference<InstructionData> instruction) {
|
|
||||||
state std::vector<StackItem> items = data->stack.pop(2);
|
|
||||||
if (items.size() != 2)
|
|
||||||
return Void();
|
|
||||||
|
|
||||||
Standalone<StringRef> s1 = wait(items[0].value);
|
|
||||||
state Standalone<StringRef> beginKey = Tuple::unpack(s1).getString(0);
|
|
||||||
|
|
||||||
Standalone<StringRef> s2 = wait(items[1].value);
|
|
||||||
state Standalone<StringRef> endKey = Tuple::unpack(s2).getString(0);
|
|
||||||
Future<int64_t> fsize = instruction->tr->getEstimatedRangeSizeBytes(KeyRangeRef(beginKey, endKey));
|
|
||||||
int64_t size = wait(fsize);
|
|
||||||
data->stack.pushTuple(LiteralStringRef("GOT_ESTIMATED_RANGE_SIZE"));
|
|
||||||
|
|
||||||
return Void();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const char* GetEstimatedRangeSize::name = "GET_ESTIMATED_RANGE_SIZE";
|
|
||||||
REGISTER_INSTRUCTION_FUNC(GetEstimatedRangeSize);
|
|
||||||
|
|
||||||
ACTOR static Future<Void> getInstructions(Reference<FlowTesterData> data, StringRef prefix) {
|
ACTOR static Future<Void> getInstructions(Reference<FlowTesterData> data, StringRef prefix) {
|
||||||
state Reference<Transaction> tr = data->db->createTransaction();
|
state Reference<Transaction> tr = data->db->createTransaction();
|
||||||
|
|
||||||
|
@ -569,6 +569,16 @@ func (sm *StackMachine) processInst(idx int, inst tuple.Tuple) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sm.store(idx, res.(fdb.FutureByteSlice))
|
sm.store(idx, res.(fdb.FutureByteSlice))
|
||||||
|
case op == "GET_ESTIMATED_RANGE_SIZE":
|
||||||
|
r := sm.popKeyRange()
|
||||||
|
_, e := rt.ReadTransact(func(rtr fdb.ReadTransaction) (interface{}, error) {
|
||||||
|
_ = rtr.GetEstimatedRangeSizeBytes(r).MustGet()
|
||||||
|
sm.store(idx, []byte("GOT_ESTIMATED_RANGE_SIZE"))
|
||||||
|
return nil, nil
|
||||||
|
})
|
||||||
|
if e != nil {
|
||||||
|
panic(e)
|
||||||
|
}
|
||||||
case op == "COMMIT":
|
case op == "COMMIT":
|
||||||
sm.store(idx, sm.currentTransaction().Commit())
|
sm.store(idx, sm.currentTransaction().Commit())
|
||||||
case op == "RESET":
|
case op == "RESET":
|
||||||
@ -865,16 +875,6 @@ func (sm *StackMachine) processInst(idx int, inst tuple.Tuple) {
|
|||||||
|
|
||||||
case strings.HasPrefix(op, "DIRECTORY_"):
|
case strings.HasPrefix(op, "DIRECTORY_"):
|
||||||
sm.de.processOp(sm, op[10:], isDB, idx, t, rt)
|
sm.de.processOp(sm, op[10:], isDB, idx, t, rt)
|
||||||
case strings.HasPrefix(op, "GET_ESTIMATED_RANGE_SIZE"):
|
|
||||||
r := sm.popKeyRange()
|
|
||||||
_, e := rt.ReadTransact(func(rtr fdb.ReadTransaction) (interface{}, error) {
|
|
||||||
_ = rtr.GetEstimatedRangeSizeBytes(r).MustGet()
|
|
||||||
sm.store(idx, []byte("GOT_ESTIMATED_RANGE_SIZE"))
|
|
||||||
return nil, nil
|
|
||||||
})
|
|
||||||
if e != nil {
|
|
||||||
panic(e)
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
log.Fatalf("Unhandled operation %s\n", string(inst[0].([]byte)))
|
log.Fatalf("Unhandled operation %s\n", string(inst[0].([]byte)))
|
||||||
}
|
}
|
||||||
|
@ -223,6 +223,12 @@ public class AsyncStackTester {
|
|||||||
inst.push(inst.readTcx.readAsync(readTr -> readTr.get((byte[]) param)));
|
inst.push(inst.readTcx.readAsync(readTr -> readTr.get((byte[]) param)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if (op == StackOperation.GET_ESTIMATED_RANGE_SIZE) {
|
||||||
|
List<Object> params = inst.popParams(2).join();
|
||||||
|
return inst.readTr.getEstimatedRangeSizeBytes((byte[])params.get(0), (byte[])params.get(1)).thenAcceptAsync(size -> {
|
||||||
|
inst.push("GOT_ESTIMATED_RANGE_SIZE".getBytes());
|
||||||
|
}, FDB.DEFAULT_EXECUTOR);
|
||||||
|
}
|
||||||
else if(op == StackOperation.GET_RANGE) {
|
else if(op == StackOperation.GET_RANGE) {
|
||||||
return inst.popParams(5).thenComposeAsync(params -> {
|
return inst.popParams(5).thenComposeAsync(params -> {
|
||||||
int limit = StackUtils.getInt(params.get(2));
|
int limit = StackUtils.getInt(params.get(2));
|
||||||
@ -527,11 +533,6 @@ public class AsyncStackTester {
|
|||||||
}
|
}
|
||||||
else if(op == StackOperation.LOG_STACK) {
|
else if(op == StackOperation.LOG_STACK) {
|
||||||
return inst.popParam().thenComposeAsync(prefix -> doLogStack(inst, (byte[])prefix), FDB.DEFAULT_EXECUTOR);
|
return inst.popParam().thenComposeAsync(prefix -> doLogStack(inst, (byte[])prefix), FDB.DEFAULT_EXECUTOR);
|
||||||
} else if (op == StackOperation.GET_ESTIMATED_RANGE_SIZE) {
|
|
||||||
List<Object> params = inst.popParams(2).join();
|
|
||||||
return inst.readTr.getEstimatedRangeSizeBytes((byte[])params.get(0), (byte[])params.get(1)).thenAcceptAsync(size -> {
|
|
||||||
inst.push("GOT_ESTIMATED_RANGE_SIZE".getBytes());
|
|
||||||
}, FDB.DEFAULT_EXECUTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new IllegalArgumentException("Unrecognized (or unimplemented) operation");
|
throw new IllegalArgumentException("Unrecognized (or unimplemented) operation");
|
||||||
|
@ -206,6 +206,11 @@ public class StackTester {
|
|||||||
CompletableFuture<byte[]> f = inst.readTcx.read(readTr -> readTr.get((byte[])params.get(0)));
|
CompletableFuture<byte[]> f = inst.readTcx.read(readTr -> readTr.get((byte[])params.get(0)));
|
||||||
inst.push(f);
|
inst.push(f);
|
||||||
}
|
}
|
||||||
|
else if (op == StackOperation.GET_ESTIMATED_RANGE_SIZE) {
|
||||||
|
List<Object> params = inst.popParams(2).join();
|
||||||
|
Long size = inst.readTr.getEstimatedRangeSizeBytes((byte[])params.get(0), (byte[])params.get(1)).join();
|
||||||
|
inst.push("GOT_ESTIMATED_RANGE_SIZE".getBytes());
|
||||||
|
}
|
||||||
else if(op == StackOperation.GET_RANGE) {
|
else if(op == StackOperation.GET_RANGE) {
|
||||||
List<Object> params = inst.popParams(5).join();
|
List<Object> params = inst.popParams(5).join();
|
||||||
|
|
||||||
@ -499,11 +504,6 @@ public class StackTester {
|
|||||||
|
|
||||||
logStack(inst.context.db, entries, prefix);
|
logStack(inst.context.db, entries, prefix);
|
||||||
}
|
}
|
||||||
else if (op == StackOperation.GET_ESTIMATED_RANGE_SIZE) {
|
|
||||||
List<Object> params = inst.popParams(2).join();
|
|
||||||
Long size = inst.readTr.getEstimatedRangeSizeBytes((byte[])params.get(0), (byte[])params.get(1)).join();
|
|
||||||
inst.push("GOT_ESTIMATED_RANGE_SIZE".getBytes());
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException("Unrecognized (or unimplemented) operation");
|
throw new IllegalArgumentException("Unrecognized (or unimplemented) operation");
|
||||||
}
|
}
|
||||||
|
@ -366,6 +366,10 @@ class Tester:
|
|||||||
inst.push(b'RESULT_NOT_PRESENT')
|
inst.push(b'RESULT_NOT_PRESENT')
|
||||||
else:
|
else:
|
||||||
inst.push(f)
|
inst.push(f)
|
||||||
|
elif inst.op == six.u("GET_ESTIMATED_RANGE_SIZE"):
|
||||||
|
begin, end = inst.pop(2)
|
||||||
|
estimatedSize = obj.get_estimated_range_size_bytes(begin, end).wait()
|
||||||
|
inst.push(b"GOT_ESTIMATED_RANGE_SIZE")
|
||||||
elif inst.op == six.u("GET_KEY"):
|
elif inst.op == six.u("GET_KEY"):
|
||||||
key, or_equal, offset, prefix = inst.pop(4)
|
key, or_equal, offset, prefix = inst.pop(4)
|
||||||
result = obj.get_key(fdb.KeySelector(key, or_equal, offset))
|
result = obj.get_key(fdb.KeySelector(key, or_equal, offset))
|
||||||
@ -576,10 +580,6 @@ class Tester:
|
|||||||
raise Exception("Unit tests failed: %s" % e.description)
|
raise Exception("Unit tests failed: %s" % e.description)
|
||||||
elif inst.op.startswith(six.u('DIRECTORY_')):
|
elif inst.op.startswith(six.u('DIRECTORY_')):
|
||||||
self.directory_extension.process_instruction(inst)
|
self.directory_extension.process_instruction(inst)
|
||||||
elif inst.op == six.u("GET_ESTIMATED_RANGE_SIZE"):
|
|
||||||
begin, end = inst.pop(2)
|
|
||||||
estimatedSize = obj.get_estimated_range_size_bytes(begin, end).wait()
|
|
||||||
inst.push(b"GOT_ESTIMATED_RANGE_SIZE")
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown op %s" % inst.op)
|
raise Exception("Unknown op %s" % inst.op)
|
||||||
except fdb.FDBError as e:
|
except fdb.FDBError as e:
|
||||||
|
@ -317,6 +317,9 @@ class Tester
|
|||||||
else
|
else
|
||||||
inst.push(res)
|
inst.push(res)
|
||||||
end
|
end
|
||||||
|
when "GET_ESTIMATED_RANGE_SIZE"
|
||||||
|
inst.tr.get_estimated_range_size_bytes(inst.wait_and_pop, inst.wait_and_pop).to_i
|
||||||
|
inst.push("GOT_ESTIMATED_RANGE_SIZE")
|
||||||
when "GET_KEY"
|
when "GET_KEY"
|
||||||
selector = FDB::KeySelector.new(inst.wait_and_pop, inst.wait_and_pop, inst.wait_and_pop)
|
selector = FDB::KeySelector.new(inst.wait_and_pop, inst.wait_and_pop, inst.wait_and_pop)
|
||||||
prefix = inst.wait_and_pop
|
prefix = inst.wait_and_pop
|
||||||
@ -510,9 +513,6 @@ class Tester
|
|||||||
end
|
end
|
||||||
|
|
||||||
log_stack(entries, prefix)
|
log_stack(entries, prefix)
|
||||||
when "GET_ESTIMATED_RANGE_SIZE"
|
|
||||||
inst.tr.get_estimated_range_size_bytes(inst.wait_and_pop, inst.wait_and_pop).to_i
|
|
||||||
inst.push("GOT_ESTIMATED_RANGE_SIZE")
|
|
||||||
else
|
else
|
||||||
if op.start_with?('DIRECTORY_')
|
if op.start_with?('DIRECTORY_')
|
||||||
@directory_extension.process_instruction(inst)
|
@directory_extension.process_instruction(inst)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user