diff --git a/Ganeti/HTools/Container.hs b/Ganeti/HTools/Container.hs index 0313cb40f7946aa4af1252e54874f4457c870876..937676ca9159ee4d56c559d33289e30e95e2d27e 100644 --- a/Ganeti/HTools/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -69,7 +69,7 @@ size = IntMap.size -- | Locate a key in the map (must exist). find :: Key -> Container a -> a -find k c = c IntMap.! k +find k = (IntMap.! k) -- | Add or update one element to the map. add :: Key -> a -> Container a -> Container a diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 429edd11b7fa2db4e8aa0a5039773db3ab05c695..1d831425a0d934b5a8d01a513be7d404eb5c16f1 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -170,13 +170,13 @@ prop_Instance_runStatus_True inst = let run_st = Instance.running inst run_tx = Instance.runSt inst in - run_tx == "running" || run_tx == "ERROR_up" ==> run_st == True + run_tx == "running" || run_tx == "ERROR_up" ==> run_st prop_Instance_runStatus_False inst = let run_st = Instance.running inst run_tx = Instance.runSt inst in - run_tx /= "running" && run_tx /= "ERROR_up" ==> run_st == False + run_tx /= "running" && run_tx /= "ERROR_up" ==> not run_st testInstance = [ run prop_Instance_setIdx @@ -200,7 +200,7 @@ prop_Text_Load_Instance name mem dsk vcpus status pnode snode pdx sdx = else sdx ndx = [(pnode, pdx), (rsnode, rsdx)] inst = Text.loadInst ndx - (name:mem_s:dsk_s:vcpus_s:status:pnode:rsnode:[]):: + [name, mem_s, dsk_s, vcpus_s, status, pnode, rsnode]:: Maybe (String, Instance.Instance) _types = ( name::String, mem::Int, dsk::Int , vcpus::Int, status::String @@ -249,10 +249,10 @@ testNode = -- | Check that the cluster score is close to zero for a homogeneous cluster prop_Score_Zero node count = - ((not $ Node.offline node) && (not $ Node.failN1 node) && (count > 0) && + (not (Node.offline node) && not (Node.failN1 node) && (count > 0) && (Node.tDsk node > 0) && (Node.tMem node > 0)) ==> let fn = Node.buildPeers node Container.empty - nlst = (zip [1..] $ replicate count fn)::[(Types.Ndx, Node.Node)] + nlst = zip [1..] $ replicate count fn::[(Types.Ndx, Node.Node)] nl = Container.fromAssocList nlst score = Cluster.compCV nl -- we can't say == 0 here as the floating point errors accumulate; diff --git a/Ganeti/Luxi.hs b/Ganeti/Luxi.hs index 41d38e9df840c20eb2a8a81dec731197d3c09531..7b7265ef24c07aee2b859ac5e4e2719bfdce0862 100644 --- a/Ganeti/Luxi.hs +++ b/Ganeti/Luxi.hs @@ -114,9 +114,7 @@ sendMsg s buf = sbytes <- withTimeout queryTimeout "sending luxi message" $ S.send (socket s) obuf - (if sbytes == length obuf - then return () - else _send (drop sbytes obuf)) + unless (sbytes == length obuf) $ _send (drop sbytes obuf) in _send (buf ++ [eOM]) -- | Waits for a message over a luxi transport. diff --git a/test.hs b/test.hs index 85470e6ae21ec179e7995c04af23dde94dc4d39a..421b3005696271f796ce0c04a3cd7dfb54f1a95d 100644 --- a/test.hs +++ b/test.hs @@ -58,7 +58,7 @@ wrapTest ir t to = do main :: IO () main = do errs <- newIORef 0 - let wrap lst = map (wrapTest errs) lst + let wrap = map (wrapTest errs) runTests "PeerMap" options $ wrap testPeerMap runTests "Container" options $ wrap testContainer runTests "Instance" options $ wrap testInstance @@ -66,7 +66,7 @@ main = do runTests "Text" options $ wrap testText runTests "Cluster" options $ wrap testCluster terr <- readIORef errs - (if (terr > 0) + (if terr > 0 then do hPutStrLn stderr $ "A total of " ++ show terr ++ " tests failed." exitWith $ ExitFailure 1