# Verify that we can maintain dispatches for:
# - multiple nodes (n1 and n2 below, reading from one doesn't affect the
#   other);
# - multiple stores (s2 and s3 from n2 below, where dispatches are not
#   coalesced);
# - multiple priorities (high-pri and normal-pri for <n2,s3,r3> below, where
#   dispatches are not coalesced);
init
----

dispatch
node=n1 range=r1 pri=normal-pri store=s1 up-to-log-position=4/20
node=n2 range=r2 pri=normal-pri store=s2 up-to-log-position=5/20
node=n2 range=r3 pri=normal-pri store=s3 up-to-log-position=5/21
node=n2 range=r3 pri=high-pri   store=s3 up-to-log-position=5/22
----

# Verify that the metrics show 2 pending nodes with 4 pending flow tokens
# dispatches (nothing gets coalesced).
metrics
----
pending-nodes=2
[regular] pending=4 coalesced=0 dispatch{local=0 remote=4}
[elastic] pending=0 coalesced=0 dispatch{local=0 remote=0}

pending-dispatch
----
node=n1
node=n2

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

# Verify that there's only 1 pending node left (n1 was cleared) and pending flow
# tokens dispatch count was reduced by 1.
metrics
----
pending-nodes=1
[regular] pending=3 coalesced=0 dispatch{local=0 remote=4}
[elastic] pending=0 coalesced=0 dispatch{local=0 remote=0}

pending-dispatch
----
node=n2

pending-dispatch-for node=n2
----
range=r2 pri=normal-pri store=s2 up-to-log-position=log-position=5/20
range=r3 pri=normal-pri store=s3 up-to-log-position=log-position=5/21
range=r3 pri=high-pri store=s3 up-to-log-position=log-position=5/22

pending-dispatch
----

# Verify no pending nodes or flow tokens dispatches.
metrics
----
pending-nodes=0
[regular] pending=0 coalesced=0 dispatch{local=0 remote=4}
[elastic] pending=0 coalesced=0 dispatch{local=0 remote=0}

# vim:ft=sh
