# Verify that dispatches get coalesced correctly. All things equal, if
# dispatching with a higher up-to-log-position, we'll ignore the lower entries.

init
----

dispatch
node=n1 range=r1 pri=normal-pri store=s1 up-to-log-position=4/20
node=n1 range=r1 pri=normal-pri store=s1 up-to-log-position=5/20
----

# Verify that the metrics indicate one pending and one coalesced flow tokens
# dispatch for 4/20.
metrics
----
pending-nodes=1
[regular] pending=1 coalesced=1 dispatch{local=0 remote=2}
[elastic] pending=0 coalesced=0 dispatch{local=0 remote=0}

# Read off pending dispatchs, observing only the one with the higher log
# position.
pending-dispatch-for node=n1
----
range=r1 pri=normal-pri store=s1 up-to-log-position=log-position=5/20

# Do the same as above, but dispatching them out of order. The higher position
# still takes precedence.
dispatch
node=n1 range=r1 pri=normal-pri store=s1 up-to-log-position=6/20
node=n1 range=r1 pri=normal-pri store=s1 up-to-log-position=6/19
----

# Verify that the metrics increment the coalesced count for 6/19.
metrics
----
pending-nodes=1
[regular] pending=1 coalesced=2 dispatch{local=0 remote=4}
[elastic] pending=0 coalesced=0 dispatch{local=0 remote=0}

pending-dispatch-for node=n1
----
range=r1 pri=normal-pri store=s1 up-to-log-position=log-position=6/20

# vim:ft=sh
