Add test for tags accounting in hail
authorOleg Ponomarev <oponomarev@google.com>
Thu, 8 Oct 2015 10:43:57 +0000 (12:43 +0200)
committerKlaus Aehlig <aehlig@google.com>
Thu, 8 Oct 2015 11:16:52 +0000 (13:16 +0200)
The test allocates drbd instance on the cluster with 3 nodes. Without
location tags, instance would be allocated on more powerful nodes 1,2.

Signed-off-by: Oleg Ponomarev <oponomarev@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

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

index 5f7e765..d61df4c 100644 (file)
@@ -1664,6 +1664,7 @@ TEST_FILES = \
        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-nlocation.json \
        test/data/htools/hail-alloc-plain-tags.json \
        test/data/htools/hail-alloc-spindles.json \
        test/data/htools/hail-alloc-twodisks.json \
diff --git a/test/data/htools/hail-alloc-nlocation.json b/test/data/htools/hail-alloc-nlocation.json
new file mode 100644 (file)
index 0000000..ff566c1
--- /dev/null
@@ -0,0 +1,159 @@
+{
+  "cluster_tags": [
+    "htools:nlocation: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": 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
+    },
+    "node2": {
+      "total_disk": 307200,
+      "total_cpus": 4,
+      "group": "uuid-group-1",
+      "i_pri_up_memory": 0,
+      "tags": [
+        "power:a"
+      ],
+      "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
+    },
+    "node3": {
+      "total_disk": 107200,
+      "total_cpus": 4,
+      "group": "uuid-group-1",
+      "i_pri_up_memory": 0,
+      "tags": [
+        "power:b"
+      ],
+      "master_candidate": true,
+      "free_memory": 1024,
+      "ndparams": {
+        "spindle_count": 1,
+        "oob_program": null,
+        "exclusive_storage": false
+      },
+      "reserved_cpus": 1,
+      "master_capable": true,
+      "free_disk": 107200,
+      "drained": false,
+      "total_memory": 1024,
+      "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": "drbd",
+    "disks": [
+      {
+        "size": 1024
+      }
+    ],
+    "hypervisor": "xen-pvm",
+    "memory": 256,
+    "name": "instance-new",
+    "nics": [],
+    "os": "instance-debootstrap",
+    "required_nodes": 2,
+    "spindle_use": 1,
+    "tags": [
+    ],
+    "type": "allocate",
+    "vcpus": 1
+  }
+}
index be035c4..e0aa09c 100644 (file)
@@ -171,3 +171,8 @@ cat $TESTDATA_DIR/hail-alloc-invalid-network.json | grep -v -e '"network":"uuid-
 ./test/hs/hail --ignore-soft-errors $TESTDATA_DIR/hail-alloc-plain-tags.json
 >>> /"success":true/
 >>>= 0
+
+# Check that hail account location tags
+./test/hs/hail $TESTDATA_DIR/hail-alloc-nlocation.json
+>>> /"success":true,.*,"result":\["node3","node2"\]/
+>>>= 0