The test demonstates simple allocation request in which desired location affect the instance placement.
Signed-off-by: Oleg Ponomarev <[email protected]> --- Makefile.am | 1 + test/data/htools/hail-alloc-desired-location.json | 134 ++++++++++++++++++++++ test/hs/shelltests/htools-hail.test | 5 + 3 files changed, 140 insertions(+) create mode 100644 test/data/htools/hail-alloc-desired-location.json diff --git a/Makefile.am b/Makefile.am index c31e611..bae63f9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1697,6 +1697,7 @@ TEST_FILES = \ test/data/htools/common-suffix.data \ test/data/htools/empty-cluster.data \ test/data/htools/hail-alloc-dedicated-1.json \ + test/data/htools/hail-alloc-desired-location.json \ test/data/htools/hail-alloc-drbd.json \ test/data/htools/hail-alloc-drbd-restricted.json \ test/data/htools/hail-alloc-ext.json \ diff --git a/test/data/htools/hail-alloc-desired-location.json b/test/data/htools/hail-alloc-desired-location.json new file mode 100644 index 0000000..8ee9740 --- /dev/null +++ b/test/data/htools/hail-alloc-desired-location.json @@ -0,0 +1,134 @@ +{ + "cluster_tags": [ + "htools:nlocation:power", + "htools:desiredlocation:power" + ], + "nodegroups": { + "uuid-group-1": { + "ipolicy": { + "std": { + "nic-count": 1, + "disk-size": 1024, + "disk-count": 1, + "memory-size": 128, + "cpu-count": 1, + "spindle-use": 1 + }, + "minmax": [ + { + "min": { + "nic-count": 1, + "disk-size": 128, + "disk-count": 1, + "memory-size": 128, + "cpu-count": 1, + "spindle-use": 1 + }, + "max": { + "nic-count": 8, + "disk-size": 1048576, + "disk-count": 16, + "memory-size": 32768, + "cpu-count": 8, + "spindle-use": 8 + } + } + ], + "vcpu-ratio": 4.0, + "disk-templates": [ + "sharedfile", + "diskless", + "plain", + "blockdev", + "drbd", + "file", + "rbd" + ], + "spindle-ratio": 32.0 + }, + "networks": [], + "alloc_policy": "preferred", + "tags": [], + "name": "default" + } + }, + "cluster_name": "cluster", + "instances": {}, + "nodes": { + "node1": { + "total_disk": 307200, + "total_cpus": 4, + "group": "uuid-group-1", + "i_pri_up_memory": 0, + "tags": [ + "power:a" + ], + "master_candidate": true, + "free_memory": 3072, + "ndparams": { + "spindle_count": 1, + "oob_program": null, + "exclusive_storage": false + }, + "reserved_cpus": 1, + "master_capable": true, + "free_disk": 307200, + "drained": false, + "total_memory": 3072, + "i_pri_memory": 0, + "reserved_memory": 0, + "free_spindles": 12, + "total_spindles": 12, + "vm_capable": true, + "offline": false + }, + "node2": { + "total_disk": 307200, + "total_cpus": 4, + "group": "uuid-group-1", + "i_pri_up_memory": 0, + "tags": [ + "power:b" + ], + "master_candidate": true, + "free_memory": 4096, + "ndparams": { + "spindle_count": 1, + "oob_program": null, + "exclusive_storage": false + }, + "reserved_cpus": 1, + "master_capable": true, + "free_disk": 307200, + "drained": false, + "total_memory": 4096, + "i_pri_memory": 0, + "reserved_memory": 0, + "free_spindles": 12, + "total_spindles": 12, + "vm_capable": true, + "offline": false + } + }, + "request": { + "disk_space_total": 0, + "disk_template": "plain", + "disks": [ + { + "size": 1024 + } + ], + "hypervisor": "xen-pvm", + "memory": 256, + "name": "instance-new", + "nics": [], + "os": "instance-debootstrap", + "required_nodes": 1, + "spindle_use": 1, + "tags": [ + "power:a" + ], + "type": "allocate", + "vcpus": 1 + } +} diff --git a/test/hs/shelltests/htools-hail.test b/test/hs/shelltests/htools-hail.test index 46bfa20..4725f84 100644 --- a/test/hs/shelltests/htools-hail.test +++ b/test/hs/shelltests/htools-hail.test @@ -234,3 +234,8 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid- ./test/hs/hail $TESTDATA_DIR/hail-alloc-nlocation.json >>> /"success":true,.*,"result":\["node3","node2"\]/ >>>= 0 + +# Desired location test +./test/hs/hail $TESTDATA_DIR/hail-alloc-desired-location.json +>>> /"success":true,.*,"result":\["node1"\]/ +>>>= 0 -- 2.6.0.rc2.230.g3dd15c0
