Add shelltests verifying hail applies disk ipolicy per disk
authorKlaus Aehlig <aehlig@google.com>
Tue, 9 Apr 2013 09:24:09 +0000 (11:24 +0200)
committerKlaus Aehlig <aehlig@google.com>
Thu, 11 Apr 2013 14:10:09 +0000 (16:10 +0200)
We test on two minimal examples, a positive and a negative one, where
the possibility to allocate a node depends on whether the disk policy
is checked on a per-disk level or on the total amount of disk space
requested.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

Makefile.am
test/data/htools/hail-alloc-invalid-twodisks.json [new file with mode: 0644]
test/data/htools/hail-alloc-twodisks.json [new file with mode: 0644]
test/hs/shelltests/htools-hail.test

index 0059a7b..868d737 100644 (file)
@@ -959,6 +959,8 @@ 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-twodisks.json \
+       test/data/htools/hail-alloc-twodisks.json \
        test/data/htools/hail-change-group.json \
        test/data/htools/hail-invalid-reloc.json \
        test/data/htools/hail-node-evac.json \
diff --git a/test/data/htools/hail-alloc-invalid-twodisks.json b/test/data/htools/hail-alloc-invalid-twodisks.json
new file mode 100644 (file)
index 0000000..3558256
--- /dev/null
@@ -0,0 +1,86 @@
+{
+  "cluster_tags": [],
+  "instances": {},
+  "ipolicy": {
+    "max": {
+      "disk-size": 2048
+    },
+    "min": {
+      "disk-size": 1024
+    }
+  },
+  "nodegroups": {
+    "uuid-group-1": {
+      "alloc_policy": "preferred",
+      "ipolicy": {
+        "disk-templates": [
+          "file"
+        ],
+        "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": "default",
+      "tags": []
+    }
+  },
+  "nodes": {
+    "node1": {
+      "drained": false,
+      "free_disk": 1377280,
+      "free_memory": 31389,
+      "group": "uuid-group-1",
+      "ndparams": {
+        "spindle_count": 1
+      },
+      "offline": false,
+      "reserved_memory": 1017,
+      "total_cpus": 4,
+      "total_disk": 1377280,
+      "total_memory": 32763
+    }
+  },
+  "request": {
+    "disk_space_total": 1536,
+    "disk_template": "file",
+    "disks": [
+      {
+        "size": 768
+      },
+      {
+        "size": 768
+      }
+    ],
+    "memory": 1024,
+    "name": "instance1",
+    "required_nodes": 1,
+    "spindle_use": 2,
+    "tags": [],
+    "type": "allocate",
+    "vcpus": 1
+  },
+  "version": 2
+}
diff --git a/test/data/htools/hail-alloc-twodisks.json b/test/data/htools/hail-alloc-twodisks.json
new file mode 100644 (file)
index 0000000..abf7221
--- /dev/null
@@ -0,0 +1,86 @@
+{
+  "cluster_tags": [],
+  "instances": {},
+  "ipolicy": {
+    "max": {
+      "disk-size": 2048
+    },
+    "min": {
+      "disk-size": 1024
+    }
+  },
+  "nodegroups": {
+    "uuid-group-1": {
+      "alloc_policy": "preferred",
+      "ipolicy": {
+        "disk-templates": [
+          "file"
+        ],
+        "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": "default",
+      "tags": []
+    }
+  },
+  "nodes": {
+    "node1": {
+      "drained": false,
+      "free_disk": 1377280,
+      "free_memory": 31389,
+      "group": "uuid-group-1",
+      "ndparams": {
+        "spindle_count": 1
+      },
+      "offline": false,
+      "reserved_memory": 1017,
+      "total_cpus": 4,
+      "total_disk": 1377280,
+      "total_memory": 32763
+    }
+  },
+  "request": {
+    "disk_space_total": 3072,
+    "disk_template": "file",
+    "disks": [
+      {
+        "size": 1536
+      },
+      {
+        "size": 1536
+      }
+    ],
+    "memory": 1024,
+    "name": "instance1",
+    "required_nodes": 1,
+    "spindle_use": 2,
+    "tags": [],
+    "type": "allocate",
+    "vcpus": 1
+  },
+  "version": 2
+}
index 55dd3ca..4da03d8 100644 (file)
@@ -38,6 +38,15 @@ echo '{"request": 0}' | ./test/hs/hail -
 >>> /"success":true,"info":"Request successful: 0 instances failed to move and 1 were moved successfully"/
 >>>= 0
 
+# check that hail correctly applies the disk policy on a per-disk basis
+./test/hs/hail $TESTDATA_DIR/hail-alloc-twodisks.json
+>>> /"success":true,.*,"result":\["node1"\]/
+>>>= 0
+
+./test/hs/hail $TESTDATA_DIR/hail-alloc-invalid-twodisks.json
+>>> /"success":false,.*FailDisk: 1/
+>>>= 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,/