Commit 38bc5244 authored by Klaus Aehlig's avatar Klaus Aehlig

Add a test for restricted allocation

In this example, there are 5 nodes. The nodes 1 to 3 each
host one instance as primary and one as secondary node, whereas
the nodes 4 and 5 are completely unused. Therefore, the best
allocation is on nodes 4 and 5. We check that restricted
allocation overrides the natural choice.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent ffbad97f
...@@ -1677,6 +1677,7 @@ TEST_FILES = \ ...@@ -1677,6 +1677,7 @@ TEST_FILES = \
test/data/htools/empty-cluster.data \ test/data/htools/empty-cluster.data \
test/data/htools/hail-alloc-dedicated-1.json \ test/data/htools/hail-alloc-dedicated-1.json \
test/data/htools/hail-alloc-drbd.json \ test/data/htools/hail-alloc-drbd.json \
test/data/htools/hail-alloc-drbd-restricted.json \
test/data/htools/hail-alloc-ext.json \ test/data/htools/hail-alloc-ext.json \
test/data/htools/hail-alloc-invalid-network.json \ test/data/htools/hail-alloc-invalid-network.json \
test/data/htools/hail-alloc-invalid-twodisks.json \ test/data/htools/hail-alloc-invalid-twodisks.json \
...@@ -1716,6 +1717,7 @@ TEST_FILES = \ ...@@ -1716,6 +1717,7 @@ TEST_FILES = \
test/data/htools/multiple-master.data \ test/data/htools/multiple-master.data \
test/data/htools/multiple-tags.data \ test/data/htools/multiple-tags.data \
test/data/htools/n1-failure.data \ test/data/htools/n1-failure.data \
test/data/htools/partly-used.data \
test/data/htools/rapi/groups.json \ test/data/htools/rapi/groups.json \
test/data/htools/rapi/info.json \ test/data/htools/rapi/info.json \
test/data/htools/rapi/instances.json \ test/data/htools/rapi/instances.json \
......
{
"cluster_tags": [],
"instances": {},
"nodegroups": {},
"nodes": {},
"request": {
"disk_space_total": 1024,
"disk_template": "drbd",
"disks": [
{
"mode": "rw",
"size": 1024,
"spindles": 1
}
],
"hypervisor": "xen-pvm",
"memory": 1024,
"name": "instance1",
"nics": [
{
"bridge": null,
"ip": null,
"mac": "00:11:22:33:44:55"
}
],
"os": "instance-debootstrap",
"required_nodes": 2,
"restrict-to-nodes": [
"node-01",
"node-02",
"node-03"
],
"spindle_use": 1,
"tags": [],
"type": "allocate",
"vcpus": 1
}
}
group-01|fake-uuid-01|preferred||
node-01|16384|0|15360|409600|204200|16|N|fake-uuid-01|1|
node-02|16384|0|15360|409600|204200|16|N|fake-uuid-01|1|
node-03|16384|0|15360|409600|204200|16|N|fake-uuid-01|1|
node-04|16384|0|16384|409600|306600|16|N|fake-uuid-01|1|
node-05|16384|0|16384|409600|306600|16|N|fake-uuid-01|1|
inst12|1024|51200|1|running|Y|node-01|node-02|drbd||1
inst23|1024|51200|1|running|Y|node-02|node-03|drbd||1
inst31|1024|51200|1|running|Y|node-03|node-01|drbd||1
...@@ -190,3 +190,24 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid- ...@@ -190,3 +190,24 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid-
./test/hs/hail -t $TESTDATA_DIR/shared-n1-restriction.data $TESTDATA_DIR/hail-alloc-ext.json --no-capacity-checks ./test/hs/hail -t $TESTDATA_DIR/shared-n1-restriction.data $TESTDATA_DIR/hail-alloc-ext.json --no-capacity-checks
>>> /"success":true.*"result":\["nodeA"\]/ >>> /"success":true.*"result":\["nodeA"\]/
>>>= 0 >>>= 0
# Verify that allocation restrications are honored
./test/hs/hail -t $TESTDATA_DIR/partly-used.data $TESTDATA_DIR/hail-alloc-drbd.json
>>> /successes 20,.*"result":\["node-0[45]","node-0[45]"\]/
>>>= 0
./test/hs/hail -t $TESTDATA_DIR/partly-used.data --restrict-allocation-to node-01,node-02,node-03 $TESTDATA_DIR/hail-alloc-drbd.json
>>> /successes 6,.*"result":\["node-0[123]","node-0[123]"\]/
>>>= 0
./test/hs/hail -t $TESTDATA_DIR/partly-used.data $TESTDATA_DIR/hail-alloc-drbd-restricted.json
>>> /successes 6,.*"result":\["node-0[123]","node-0[123]"\]/
>>>= 0
./test/hs/hail -t $TESTDATA_DIR/partly-used.data --restrict-allocation-to node-01,node-02 $TESTDATA_DIR/hail-alloc-drbd-restricted.json
>>> /successes 2,.*"result":\["node-0[12]","node-0[12]"\]/
>>>= 0
./test/hs/hail -t $TESTDATA_DIR/partly-used.data --restrict-allocation-to node-03,node-04 $TESTDATA_DIR/hail-alloc-drbd-restricted.json
>>> /successes 2,.*"result":\["node-0[34]","node-0[34]"\]/
>>>= 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment