From f9649b3db56b4738047ae98c66d6fa0ff7ea60f4 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Tue, 9 Jul 2013 17:05:48 +0200 Subject: [PATCH] Only generate node lists with nodes having different names 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 Reviewed-by: Iustin Pop Reviewed-by: Guido Trotter --- test/hs/Test/Ganeti/HTools/Node.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/hs/Test/Ganeti/HTools/Node.hs b/test/hs/Test/Ganeti/HTools/Node.hs index 4b36db4..fd28962 100644 --- a/test/hs/Test/Ganeti/HTools/Node.hs +++ b/test/hs/Test/Ganeti/HTools/Node.hs @@ -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. -- 1.7.10.4