Only generate node lists with nodes having different names
authorKlaus Aehlig <aehlig@google.com>
Tue, 9 Jul 2013 15:05:48 +0000 (17:05 +0200)
committerKlaus Aehlig <aehlig@google.com>
Wed, 10 Jul 2013 09:41:33 +0000 (11:41 +0200)
genNodeList is used in testing to generate list of nodes
that could come up in cluster configurations. Since names
are used to assign indices to nodes, they have to be unique;
this is also the case in all real clusters.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Iustin Pop <iusty@k1024.org>
Reviewed-by: Guido Trotter <ultrotter@google.com>

test/hs/Test/Ganeti/HTools/Node.hs

index 4b36db4..fd28962 100644 (file)
@@ -112,7 +112,9 @@ instance Arbitrary Node.Node where
 -- lists here.
 genNodeList :: Gen Node.Node -> Gen Node.List
 genNodeList ngen = fmap (snd . Loader.assignIndices) names_nodes
-    where names_nodes = (fmap . map) (\n -> (Node.name n, n)) $ listOf1 ngen
+    where names_nodes = (fmap . map) (\n -> (Node.name n, n)) nodes
+          nodes = listOf1 ngen `suchThat`
+                  ((\ns -> ns == nub ns) . map Node.name)
 
 -- | Generate a node list, an instance list, and a node graph.
 -- We choose instances with nodes contained in the node list.