# This example sets n7 to dead initially and n5 to decommissioning after 2
# minutes. The output of replicas per store is then plotted.
#
# Create 7 stores, with 700 ranges (RF=3). Each store should have approx 300
# replicas and 100 leases.
gen_cluster nodes=7
----

gen_ranges ranges=700
----

# n7 is dead and remains dead forever. It will still have its initial (3000)
# replicas.
set_liveness node=7 liveness=dead
----

# n6 becomes decommissioning after 3 minutes and remains decommissioning
# thereafter.
set_liveness node=6 liveness=decommissioning delay=3m
----

# The number of replicas on the dead and decommissioning stores should be 0,
# assert this.
assertion type=stat stat=replicas ticks=6 exact_bound=0 stores=(6,7)
----

eval duration=12m seed=42
----
OK

# We expect one node(store) (n7) to immediately start losing replicas, whilst
# other stores gain replicas evenly. After 3 minutes, we expect another
# node(store) (n6) to begin losing replicas in a similar manner.
plot stat=replicas
----
----

 430 ┤                                                   ╭───────╭────╭──────────────
 401 ┤                                  ╭──────╭─╭─╭──────────────────╯──────────────
 373 ┤                        ╭──╭──╭──────────────╯╯
 344 ┤                ╭╭╭─╮─────────╯
 315 ┤╭╭────────────────╯─╰───╮
 287 ┼──╮                     ╰───╮
 258 ┤  ╰──╮                      ╰────╮
 229 ┤     ╰─╮                         ╰──╮
 201 ┤       ╰──╮                         ╰───╮
 172 ┤          ╰───╮                         ╰───╮
 143 ┤              ╰──╮                          ╰──╮
 115 ┤                 ╰─╮                           ╰──╮
  86 ┤                   ╰───╮                          ╰──╮
  57 ┤                       ╰──╮                          ╰────╮
  29 ┤                          ╰───╮                           ╰───────╮
   0 ┤                              ╰────────────────────────────────────────────────
                                          replicas
----
----

# Both nodes should begin losing leases immediately after their liveness status
# is changed to dead or decommissioning (5 minutes later).
plot stat=leases
----
----

 149 ┤                                                        ╭──────────────────────
 139 ┤                                              ╭────╭───────────────────────────
 129 ┤                                      ╭────╭╭──────╯╯───╯╯
 119 ┤                 ╭───────────────╮──────────╯────╯
 109 ┤     ╭───────────╯───────────────╰──╮
  99 ┼─╮───╯─────────╯                    ╰─╮
  89 ┤ ╰────╮                               ╰──╮
  79 ┤      ╰─╮                                ╰─╮
  70 ┤        ╰──╮                               ╰─╮
  60 ┤           ╰───╮                             ╰╮
  50 ┤               ╰─╮                            ╰──╮
  40 ┤                 ╰───╮                           ╰─╮
  30 ┤                     ╰──╮                          ╰─╮
  20 ┤                        ╰───╮                        ╰──╮
  10 ┤                            ╰──╮                        ╰──╮
   0 ┤                               ╰───────────────────────────────────────────────
                                           leases
----
----

# vim:ft=sh
