Improve the `CanTieredAlloc' test
authorIustin Pop <iustin@google.com>
Thu, 6 Sep 2012 17:19:46 +0000 (02:19 +0900)
committerIustin Pop <iustin@google.com>
Fri, 7 Sep 2012 21:20:51 +0000 (06:20 +0900)
commitfb24310595b42ac0c69d58cd3b94a1872f9d574e
tree9d728a593c9e0734a04d6ff06c8d6d6c1c049e63
parentd83903ee572cffe8ea286ed92ae7a19827ada7b2
Improve the `CanTieredAlloc' test

Currently, this test is very slow. Upon investigation, this is due to
how `tieredAlloc' works:

- tries to allocate one instance
- if failed, shrink the instance by the "most failed" resource
- restart

In this algorithm, if the "most failed" resource is e.g. memory, and
the maximum available memory is much smaller than the current
template, it means we will have to shrink and try to allocate many
many times until we finally get with the to-be-allocated instance
memory size to a reasonable value. In the real world, this is not the
case, but when testing with arbitrary memory/node values, it can be
that we execute the shrink hundreds of thousands of times per test.

So we "improve" the test by directly generating an instance just
slightly bigger than the node, so that we don't have to shrink too
many times. This requires a new export from test/…/Instance.hs.

Additionally, we allow up to 5 instances to be tiered-allocated, and
we cleanup the test checks, making the conditions much, much more
readable (IMHO).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
htest/Test/Ganeti/HTools/Cluster.hs
htest/Test/Ganeti/HTools/Instance.hs