# This test applies a configuration that prioritizes zone constraints, favoring
# the US_East region. As a result, we expect a majority of replicas to be
# distributed across stores numbered 1-12, all within the US_East region. The
# allocation of replicas to stores outside of this region is expected to be
# zero.

load_cluster config=multi_region
----

# Create 200 ranges (RF=3) with zone preference set to US_East.
set_span_config delay=1m
[0,9999999999): num_replicas=3 constraints={'+region=US_East'}
----

assertion type=conformance under=0 violating=0
----

gen_ranges ranges=200
----

# Stores=(13-25) should have number of replicas close to zero.
assertion type=stat stat=replicas ticks=5 exact_bound=0 stores=(13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30)
----

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


topology
----
EU
  EU_1
  │ └── [25 26 27 28]
  EU_2
  │ └── [29 30 31 32]
  EU_3
  │ └── [33 34 35 36]
US_East
  US_East_1
  │ └── [1 2 3 4]
  US_East_2
  │ └── [5 6 7 8]
  US_East_3
  │ └── [9 10 11 12]
US_West
  US_West_1
    └── [13 14 15 16]
  US_West_2
    └── [17 18 19 20]
  US_West_3
    └── [21 22 23 24]

plot stat=replicas
----
----

 52.00 ┤          ╭╮╭╮   ╭╮╭───────────────────────────────────────────────────────────
 48.53 ┤          │╰╮╰╭────────────────────────────────────────────────────────────────
 45.07 ┤        ╭╮│╭╭─│╯╯
 41.60 ┤        │╰│╭──╯
 38.13 ┤        │ ││╯
 34.67 ┤        │╭╭│
 31.20 ┤        ╭╭─╯
 27.73 ┤        │││
 24.27 ┤        ╭│╯
 20.80 ┤       ╭╭╯
 17.33 ┼────────╮╮
 13.87 ┤       ╰╰╮╮
 10.40 ┤        ╰╰─╮╮
  6.93 ┤        ╰╰─╰╮╮╮
  3.47 ┤         ╰╰╰╰───────╮─╮
  0.00 ┤          ╰──╰╰──╰──╰──────────────────────────────────────────────────────────
                                            replicas
----
----
