Commit 017160ed authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

Add tests for network-aware allocation



hail-alloc-invalid-network defines a cluster with two nodegroups and an
allocation request which does not fit on any of the groups. Group 1 has
invalid disk-templates while Group 2 is not connected to the right
networks.

hail-alloc-restricted-network defines a cluster wih two nodegroups.
Nodegroup Group 1 is only used as last_resort group, but is chosen by
hail as only this group is connected to the right networks.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent b1142361
......@@ -1024,7 +1024,9 @@ TEST_FILES = \
test/data/htools/common-suffix.data \
test/data/htools/empty-cluster.data \
test/data/htools/hail-alloc-drbd.json \
test/data/htools/hail-alloc-invalid-network.json \
test/data/htools/hail-alloc-invalid-twodisks.json \
test/data/htools/hail-alloc-restricted-network.json \
test/data/htools/hail-alloc-twodisks.json \
test/data/htools/hail-change-group.json \
test/data/htools/hail-invalid-reloc.json \
......
......@@ -847,7 +847,7 @@ findBestAllocGroup mggl mgnl mgil allowed_gdxs inst cnt =
(gr, genAllocNodes mggl nl cnt False >>=
tryAlloc nl il inst))
groups''::[(Group.Group, Result AllocSolution)]
all_msgs = filter_group_msgs ++ (concatMap solutionDescription sols)
all_msgs = filter_group_msgs ++ concatMap solutionDescription sols
goodSols = filterMGResults sols
sortedSols = sortMGResults goodSols
in case sortedSols of
......
{
"cluster_tags": [],
"instances": {},
"ipolicy": {
"max": {
"disk-size": 2048
},
"min": {
"disk-size": 1024
}
},
"nodegroups": {
"uuid-group-1": {
"alloc_policy": "preferred",
"ipolicy": {
"disk-templates": [
"drbd"
],
"minmax": [
{
"max": {
"cpu-count": 2,
"disk-count": 8,
"disk-size": 2048,
"memory-size": 12800,
"nic-count": 8,
"spindle-use": 8
},
"min": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
}
}
],
"spindle-ratio": 32.0,
"std": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
},
"vcpu-ratio": 4.0
},
"name": "Group 1",
"networks": ["uuid-net-1-1", "uuid-net-1-2"],
"tags": []
},
"uuid-group-2": {
"alloc_policy": "preferred",
"ipolicy": {
"disk-templates": [
"file"
],
"minmax": [
{
"max": {
"cpu-count": 2,
"disk-count": 8,
"disk-size": 2048,
"memory-size": 12800,
"nic-count": 8,
"spindle-use": 8
},
"min": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
}
}
],
"spindle-ratio": 32.0,
"std": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
},
"vcpu-ratio": 4.0
},
"name": "Group 2",
"networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"],
"tags": []
}
},
"nodes": {
"node1_1": {
"drained": false,
"free_disk": 7168,
"free_memory": 4096,
"group": "uuid-group-1",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 4096
},
"node2_1": {
"drained": false,
"free_disk": 7168,
"free_memory": 4096,
"group": "uuid-group-2",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 4096
}
},
"request": {
"disk_space_total": 1536,
"disk_template": "file",
"disks": [
{
"size": 1536
}
],
"memory": 1024,
"name": "instance1",
"required_nodes": 1,
"spindle_use": 2,
"nics":[
{
"mac":"aa:00:00:85:f3:a7",
"network":"uuid-net-1-1",
"nicparams":{}
},
{
"mac":"aa:00:00:85:f3:a8",
"network":"uuid-net-1-2",
"nicparams":{}
}
],
"tags": [],
"type": "allocate",
"vcpus": 1
},
"version": 2
}
{
"cluster_tags": [],
"instances": {
"instance1": {
"disks": [
{
"mode": "rw",
"size": 1024
}
],
"disk_space_total": 1024,
"hypervisor": "xen-pvm",
"tags": [],
"nics": [
{
"ip": null,
"mac": "aa:00:00:eb:0b:a5",
"link": "xen-br0",
"mode": "bridged",
"bridge": "xen-br0"
}
],
"vcpus": 1,
"spindle_use": 1,
"admin_state": "down",
"disk_template": "drbd",
"memory": 128,
"nodes": [
"node1_1",
"node1_2"
],
"os": "debian-image"
},
"instance2": {
"disks": [
{
"mode": "rw",
"size": 1024
}
],
"disk_space_total": 1024,
"hypervisor": "xen-pvm",
"tags": [],
"nics": [
{
"ip": null,
"mac": "aa:00:00:eb:0b:a5",
"link": "xen-br0",
"mode": "bridged",
"bridge": "xen-br0"
}
],
"vcpus": 1,
"spindle_use": 1,
"admin_state": "down",
"disk_template": "drbd",
"memory": 128,
"nodes": [
"node1_2",
"node1_1"
],
"os": "debian-image"
},
"instance2": {
"disks": [
{
"mode": "rw",
"size": 1024
}
],
"disk_space_total": 1024,
"hypervisor": "xen-pvm",
"tags": [],
"nics": [
{
"ip": null,
"mac": "aa:00:00:eb:0b:a5",
"link": "xen-br0",
"mode": "bridged",
"bridge": "xen-br0"
}
],
"vcpus": 1,
"spindle_use": 1,
"admin_state": "down",
"disk_template": "drbd",
"memory": 128,
"nodes": [
"node1_1",
"node1_2"
],
"os": "debian-image"
}
},
"ipolicy": {
"max": {
"disk-size": 2048
},
"min": {
"disk-size": 1024
}
},
"nodegroups": {
"uuid-group-1": {
"alloc_policy": "last_resort",
"ipolicy": {
"disk-templates": [
"drbd"
],
"minmax": [
{
"max": {
"cpu-count": 2,
"disk-count": 8,
"disk-size": 2048,
"memory-size": 12800,
"nic-count": 8,
"spindle-use": 8
},
"min": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
}
}
],
"spindle-ratio": 32.0,
"std": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
},
"vcpu-ratio": 4.0
},
"name": "Group 1",
"networks": ["uuid-net-1-1", "uuid-net-1-2"],
"tags": []
},
"uuid-group-2": {
"alloc_policy": "preferred",
"ipolicy": {
"disk-templates": [
"drbd"
],
"minmax": [
{
"max": {
"cpu-count": 2,
"disk-count": 8,
"disk-size": 2048,
"memory-size": 12800,
"nic-count": 8,
"spindle-use": 8
},
"min": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
}
}
],
"spindle-ratio": 32.0,
"std": {
"cpu-count": 1,
"disk-count": 1,
"disk-size": 1024,
"memory-size": 128,
"nic-count": 1,
"spindle-use": 1
},
"vcpu-ratio": 4.0
},
"name": "Group 2",
"networks": ["uuid-net-2-1", "uuid-net-2-2", "uuid-net-2-3"],
"tags": []
}
},
"nodes": {
"node1_1": {
"drained": false,
"free_disk": 4096,
"free_memory": 3840,
"group": "uuid-group-1",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 4096
},
"node1_2": {
"drained": false,
"free_disk": 4096,
"free_memory": 3968,
"group": "uuid-group-1",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 32763
},
"node2_1": {
"drained": false,
"free_disk": 7168,
"free_memory": 4096,
"group": "uuid-group-2",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 4096
},
"node2_2": {
"drained": false,
"free_disk": 7168,
"free_memory": 4096,
"group": "uuid-group-2",
"ndparams": {
"spindle_count": 1
},
"offline": false,
"reserved_memory": 1017,
"total_cpus": 4,
"total_disk": 7168,
"total_memory": 4096
}
},
"request": {
"disk_space_total": 3072,
"disk_template": "drbd",
"disks": [
{
"size": 1536
},
{
"size": 1536
}
],
"memory": 1024,
"name": "instance1",
"required_nodes": 2,
"spindle_use": 2,
"nics":[
{
"mac":"aa:00:00:85:f3:a7",
"network":"uuid-net-1-1",
"nicparams":{}
},
{
"mac":"aa:00:00:85:f3:a8",
"network":"uuid-net-1-2",
"nicparams":{}
}
],
"tags": [],
"type": "allocate",
"vcpus": 1
},
"version": 2
}
......@@ -47,6 +47,21 @@ echo '{"request": 0}' | ./test/hs/hail -
>>> /"success":false,.*FailDisk: 1/
>>>= 0
# check that hail honors network requirements
./test/hs/hail $TESTDATA_DIR/hail-alloc-restricted-network.json
>>> /"success":true,"info":"Request successful: Selected group: Group 1.*/
>>>= 0
# check that hail fails if no nodegroup can meet network and disk template requirements
./test/hs/hail $TESTDATA_DIR/hail-alloc-invalid-network.json
>>> /"success":false,/
>>>= 0
# check that hail succeeds with the same test data, but with the network restrictions removed
cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid-net-1-."' | ./test/hs/hail -
>>> /"success":true,"info":"Request successful: Selected group: Group 2.*/
>>>= 0
# check that hail can use the simu backend
./test/hs/hail --simu p,8,8T,16g,16 $TESTDATA_DIR/hail-alloc-drbd.json
>>> /"success":true,/
......
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