Commit e82df53d authored by Klaus Aehlig's avatar Klaus Aehlig

Add a test for allocate-secondary requests

Add a simple test case for the allocate-secondary request.
In this example, hail has to avoid the node of the other
group and should prefer the free node as secondary over
the one that already hosts an instance.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 72d09f71
...@@ -1689,6 +1689,7 @@ TEST_FILES = \ ...@@ -1689,6 +1689,7 @@ TEST_FILES = \
test/data/htools/hail-alloc-invalid-twodisks.json \ test/data/htools/hail-alloc-invalid-twodisks.json \
test/data/htools/hail-alloc-restricted-network.json \ test/data/htools/hail-alloc-restricted-network.json \
test/data/htools/hail-alloc-plain-tags.json \ test/data/htools/hail-alloc-plain-tags.json \
test/data/htools/hail-alloc-secondary.json \
test/data/htools/hail-alloc-spindles.json \ test/data/htools/hail-alloc-spindles.json \
test/data/htools/hail-alloc-twodisks.json \ test/data/htools/hail-alloc-twodisks.json \
test/data/htools/hail-change-group.json \ test/data/htools/hail-change-group.json \
......
{
"cluster_tags": [],
"instances": {
"instance-2-3":{
"disks": [
{
"spindles": 1,
"mode": "rw",
"size": 512
}
],
"disk_space_total": 1024,
"hypervisor": "xen-pvm",
"tags": [],
"nics": [
{
"ip": null,
"mac": "aa:00:00:7f:8c:9c",
"link": "xen-br1",
"mode": "bridged",
"bridge": "xen-br1"
}
],
"vcpus": 1,
"spindle_use": 1,
"admin_state": "up",
"admin_state_source": "admin",
"disk_template": "plain",
"memory": 128,
"nodes": [
"node-2-3"
],
"os": "instance-debootstrap"
},
"instance-to-be-converted-to-drbd":{
"disks": [
{
"spindles": 1,
"mode": "rw",
"size": 512
}
],
"disk_space_total": 1024,
"hypervisor": "xen-pvm",
"tags": [],
"nics": [
{
"ip": null,
"mac": "aa:00:00:7f:8c:9c",
"link": "xen-br1",
"mode": "bridged",
"bridge": "xen-br1"
}
],
"vcpus": 1,
"spindle_use": 1,
"admin_state": "down",
"admin_state_source": "admin",
"disk_template": "plain",
"memory": 128,
"nodes": [
"node-2-1"
],
"os": "instance-debootstrap"
}
},
"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"
},
"uuid-group-2":
{
"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"
}
},
"nodes": {
"node-1-1" :
{
"total_disk": 91552,
"total_cpus": 16,
"group": "uuid-group-1",
"secondary_ip": "192.168.2.1",
"i_pri_up_memory": 0,
"tags": [],
"master_candidate": true,
"free_memory": 3100,
"ndparams": {
"spindle_count": 1,
"oob_program": null,
"exclusive_storage": false
},
"reserved_memory": 0,
"reserved_cpus": 1,
"master_capable": true,
"free_disk": 91552,
"drained": false,
"total_memory": 3100,
"primary_ip": "192.168.1.1",
"i_pri_memory": 0,
"free_spindles": 12,
"total_spindles": 12,
"vm_capable": true,
"offline": false
},
"node-2-1" :
{
"total_disk": 91552,
"total_cpus": 16,
"group": "uuid-group-2",
"secondary_ip": "192.168.2.101",
"i_pri_up_memory": 0,
"tags": [],
"master_candidate": true,
"free_memory": 3100,
"ndparams": {
"spindle_count": 1,
"oob_program": null,
"exclusive_storage": false
},
"reserved_memory": 0,
"reserved_cpus": 1,
"master_capable": true,
"free_disk": 91552,
"drained": false,
"total_memory": 3100,
"primary_ip": "192.168.1.101",
"i_pri_memory": 0,
"free_spindles": 12,
"total_spindles": 12,
"vm_capable": true,
"offline": false
},
"node-2-2" :
{
"total_disk": 91552,
"total_cpus": 16,
"group": "uuid-group-2",
"secondary_ip": "192.168.2.102",
"i_pri_up_memory": 0,
"tags": [],
"master_candidate": true,
"free_memory": 3100,
"ndparams": {
"spindle_count": 1,
"oob_program": null,
"exclusive_storage": false
},
"reserved_memory": 0,
"reserved_cpus": 1,
"master_capable": true,
"free_disk": 91552,
"drained": false,
"total_memory": 3100,
"primary_ip": "192.168.1.102",
"i_pri_memory": 0,
"free_spindles": 12,
"total_spindles": 12,
"vm_capable": true,
"offline": false
},
"node-2-3" :
{
"total_disk": 91552,
"total_cpus": 16,
"group": "uuid-group-2",
"secondary_ip": "192.168.2.103",
"i_pri_up_memory": 0,
"tags": [],
"master_candidate": true,
"free_memory": 3100,
"ndparams": {
"spindle_count": 1,
"oob_program": null,
"exclusive_storage": false
},
"reserved_memory": 0,
"reserved_cpus": 1,
"master_capable": true,
"free_disk": 91552,
"drained": false,
"total_memory": 3100,
"primary_ip": "192.168.1.103",
"i_pri_memory": 0,
"free_spindles": 12,
"total_spindles": 12,
"vm_capable": true,
"offline": false
}
},
"request": {
"name": "instance-to-be-converted-to-drbd",
"type": "allocate-secondary"
}
}
...@@ -211,3 +211,8 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid- ...@@ -211,3 +211,8 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid-
./test/hs/hail -t $TESTDATA_DIR/partly-used.data --restrict-allocation-to node-03,node-04 $TESTDATA_DIR/hail-alloc-drbd-restricted.json ./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]"\]/ >>> /successes 2,.*"result":\["node-0[34]","node-0[34]"\]/
>>>= 0 >>>= 0
# Verify allocate-secondary
./test/hs/hail $TESTDATA_DIR/hail-alloc-secondary.json
>>> /successes 2, failures 0.*"result":"node-2-2"/
>>>= 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