Generate clusters with unique node names in tests
authorIustin Pop <iustin@google.com>
Thu, 5 Jan 2012 13:18:46 +0000 (14:18 +0100)
committerIustin Pop <iustin@google.com>
Fri, 13 Jan 2012 13:24:03 +0000 (14:24 +0100)
Nothing breaks otherwise in the cluster routines, but serialisation
to/from text gets confused otherwise.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

htools/Ganeti/HTools/QC.hs

index c75cfa6..1134dc5 100644 (file)
@@ -154,8 +154,13 @@ createInstance mem dsk vcpus =
 -- | Create a small cluster by repeating a node spec.
 makeSmallCluster :: Node.Node -> Int -> Node.List
 makeSmallCluster node count =
-  let fn = Node.buildPeers node Container.empty
-      namelst = map (\n -> (Node.name n, n)) (replicate count fn)
+  let origname = Node.name node
+      origalias = Node.alias node
+      nodes = map (\idx -> node { Node.name = origname ++ "-" ++ show idx
+                                , Node.alias = origalias ++ "-" ++ show idx })
+              [1..count]
+      fn = flip Node.buildPeers Container.empty
+      namelst = map (\n -> (Node.name n, fn n)) nodes
       (_, nlst) = Loader.assignIndices namelst
   in nlst