Skip to content
Snippets Groups Projects
Commit 471b6c46 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add test for Luxi calls consistency hs/py


This tests that the same Luxi calls are defined in Python and
Haskell. It doesn't test yet that their serialisation is correct
though.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 46c1f828
No related branches found
No related tags found
No related merge requests found
......@@ -28,9 +28,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Test.Ganeti.Luxi (testLuxi) where
import Test.HUnit
import Test.QuickCheck
import Test.QuickCheck.Monadic (monadicIO, run, stop)
import Data.List
import Control.Applicative
import Control.Concurrent (forkIO)
import Control.Exception (bracket)
......@@ -134,7 +136,24 @@ prop_ClientServer dnschars = monadicIO $ do
(`luxiClientPong` msgs)
stop $ replies ==? msgs
-- | Check that Python and Haskell define the same Luxi requests list.
case_AllDefined :: Assertion
case_AllDefined = do
py_stdout <- runPython "from ganeti import luxi\n\
\print '\\n'.join(luxi.REQ_ALL)" "" >>=
checkPythonResult
let py_ops = sort $ lines py_stdout
hs_ops = Luxi.allLuxiCalls
extra_py = py_ops \\ hs_ops
extra_hs = hs_ops \\ py_ops
assertBool ("Luxi calls missing from Haskell code:\n" ++
unlines extra_py) (null extra_py)
assertBool ("Extra Luxi calls in the Haskell code code:\n" ++
unlines extra_hs) (null extra_hs)
testSuite "Luxi"
[ 'prop_CallEncoding
, 'prop_ClientServer
, 'case_AllDefined
]
......@@ -48,6 +48,7 @@ module Ganeti.Luxi
, recvMsg
, recvMsgExt
, sendMsg
, allLuxiCalls
) where
import Control.Exception (catch)
......@@ -183,6 +184,9 @@ $(genLuxiOp "LuxiOp"
$(makeJSONInstance ''LuxiReq)
-- | List of all defined Luxi calls.
$(genAllConstr (drop 3) ''LuxiReq "allLuxiCalls")
-- | The serialisation of LuxiOps into strings in messages.
$(genStrOfOp ''LuxiOp "strOfOp")
......
......@@ -33,6 +33,7 @@ module Ganeti.THH ( declareSADT
, declareIADT
, makeJSONInstance
, genOpID
, genAllConstr
, genAllOpIDs
, genOpCode
, genStrOfOp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment