# This test simulates the behavior of the roachtest replicate/1to3. Where
# initially there is one store, two new stores are added and the the test
# asserts the replica counts between the 3 stores eventually balances.
gen_cluster nodes=1
----

# Generate 300 ranges, where each range is 100mb (logical).
gen_ranges ranges=300 range_bytes=100000000 repl_factor=1
----

# Add the two new nodes that won't be in the initial cluster, however added as
# soon as the simulation  evaluation begins i.e. with delay=0.
add_node
----

add_node
----

# Assert that the replica counts balance within 5% of each other among stores.
assertion type=balance stat=replicas ticks=6 upper_bound=1.05
----

# Update the replication factor for the keyspace to be 3, instead of the
# initial replication factor of 1 set during generation.
set_span_config
[0,10000): num_replicas=3 num_voters=3
----

eval duration=20m samples=1 seed=42
----
OK

# Plot the replica count from the evaluation. Since there are 300 replicas on
# s1 and the default RF=3, we expect the other stores to be up-replicated to
# 300 replicas as well.
plot stat=replicas sample=1
----
----

 301 ┼─────────────────────────────────────╭─╭───────────────────────────────────────
 281 ┤                                   ╭───╯
 261 ┤                                ╭╭─╯
 241 ┤                              ╭──╯
 221 ┤                           ╭──╯
 201 ┤                        ╭──╯
 181 ┤                      ╭─╯╯
 161 ┤                   ╭──╯
 140 ┤                ╭──╯╯
 120 ┤              ╭─╯╯
 100 ┤           ╭──╯
  80 ┤        ╭──╯╯
  60 ┤      ╭─╯╯
  40 ┤    ╭─╯
  20 ┤ ╭──╯
   0 ┼─╯
                                          replicas
----
----

# vim:ft=sh
