Push a string to stack for getApproximateSize in binding testers

Because different bindings may issue different limit for get_range calls, it is
impossible to return the same size value for getApproximateSize API. So we just
push a string to make sure binding test results are the same. Use another unit
test to make sure the sizes got back are monotonically increasing.
This commit is contained in:
Jingyu Zhou 2019-07-12 14:15:20 -07:00
parent 2dcc3cfd0a
commit 990c205f70
8 changed files with 14 additions and 13 deletions

View File

@ -279,7 +279,9 @@ futures must apply the following rules to the result:
#### GET_APPROXIMATE_SIZE
Calls get_approximate_size and pushes the integer size onto the stack.
Calls get_approximate_size and pushes the byte string "GOT_APPROXIMATE_SIZE"
onto the stack. Note bindings may issue GET_RANGE calls with different
limits, so these bindings can obtain different sizes back.
#### WAIT_FUTURE

View File

@ -438,7 +438,7 @@ class ApiTest(Test):
elif op == 'GET_APPROXIMATE_SIZE':
instructions.append(op)
self.add_stack_items(1)
self.add_strings(1)
elif op == 'TUPLE_PACK' or op == 'TUPLE_RANGE':
tup = self.random.random_tuple(10)

View File

@ -710,10 +710,9 @@ struct GetApproximateSizeFunc : InstructionFunc {
static const char* name;
ACTOR static Future<Void> call(Reference<FlowTesterData> data, Reference<InstructionData> instruction) {
int64_t size = wait(instruction->tr->getApproximateSize());
Tuple f;
f.append(size);
data->stack.push(f.pack());
int64_t _ = wait(instruction->tr->getApproximateSize());
(void) _; // disable unused variable warning
data->stack.pushTuple(LiteralStringRef("GOT_APPROXIMATE_SIZE"));
return Void();
}
};

View File

@ -591,9 +591,8 @@ func (sm *StackMachine) processInst(idx int, inst tuple.Tuple) {
}
sm.store(idx, []byte("GOT_COMMITTED_VERSION"))
case op == "GET_APPROXIMATE_SIZE":
approximateSize := sm.currentTransaction().GetApproximateSize().MustGet()
var x *big.Int = big.NewInt(approximateSize)
sm.store(idx, x)
_ = sm.currentTransaction().GetApproximateSize().MustGet()
sm.store(idx, []byte("GOT_APPROXIMATE_SIZE"))
case op == "GET_VERSIONSTAMP":
sm.store(idx, sm.currentTransaction().GetVersionstamp())
case op == "GET_KEY":

View File

@ -284,7 +284,7 @@ public class AsyncStackTester {
}
else if(op == StackOperation.GET_APPROXIMATE_SIZE) {
return inst.tr.getApproximateSize().thenAcceptAsync(size -> {
inst.push(BigInteger.valueOf(size));
inst.push("GOT_APPROXIMATE_SIZE".getBytes());
}, FDB.DEFAULT_EXECUTOR);
}
else if(op == StackOperation.GET_VERSIONSTAMP) {

View File

@ -263,7 +263,7 @@ public class StackTester {
}
else if(op == StackOperation.GET_APPROXIMATE_SIZE) {
Long size = inst.tr.getApproximateSize().join();
inst.push(BigInteger.valueOf(size));
inst.push("GOT_APPROXIMATE_SIZE".getBytes());
}
else if(op == StackOperation.GET_VERSIONSTAMP) {
inst.push(inst.tr.getVersionstamp());

View File

@ -477,7 +477,7 @@ class Tester:
inst.push(b"GOT_COMMITTED_VERSION")
elif inst.op == six.u("GET_APPROXIMATE_SIZE"):
approximate_size = inst.tr.get_approximate_size().wait()
inst.push(approximate_size)
inst.push(b"GOT_APPROXIMATE_SIZE")
elif inst.op == six.u("GET_VERSIONSTAMP"):
inst.push(inst.tr.get_versionstamp())
elif inst.op == six.u("TUPLE_PACK"):

View File

@ -382,7 +382,8 @@ class Tester
@last_version = inst.tr.get_committed_version
inst.push("GOT_COMMITTED_VERSION")
when "GET_APPROXIMATE_SIZE"
inst.push(inst.tr.get_approximate_size.to_i)
size = inst.tr.get_approximate_size.to_i
inst.push("GOT_APPROXIMATE_SIZE")
when "GET_VERSIONSTAMP"
inst.push(inst.tr.get_versionstamp)
when "TUPLE_PACK"