250 likes | 370 Views
Testing Telecoms Software with QuickCheck. Thomas Arts John Hughes Chalmers/ITU. Joakim Johansson Ulf Wiger Ericsson. Session Border Gateway. Monitors signalling traffic; opens and closes pinholes. 2x1G Ethernet Linux ”blade” processor. Media Gateway Controller.
E N D
Testing Telecoms Software with QuickCheck Thomas Arts John Hughes Chalmers/ITU Joakim Johansson Ulf Wiger Ericsson
Session Border Gateway Monitors signalling traffic; opens and closes pinholes 2x1G Ethernet Linux ”blade” processor Media Gateway Controller Opens media pin-holes for calls in progress Media Proxy 2x10G Ethernet Hardware for packet forwarding
Session Border Gateway Media Gateway Controller ITU standard protocol H.248 (Megaco) Media Proxy 150KLOC Erlang 1.5MLOC C
A QuickCheck Property prop_reverse() -> ?FORALL(Xs,list(int()), lists:reverse(lists:reverse(Xs)) == Xs). 6> eqc:quickcheck(rev:prop_reverse()). .................................................................................................... OK, passed 100 tests true
A Wrong Property prop_reverse_wrong() -> ?FORALL(Xs,list(int()), lists:reverse(Xs) == Xs). 10> eqc:quickcheck(rev:prop_reverse_wrong()). .....................Failed! After 22 tests. [-2,4,0] Shrinking......(6 times) [1,0] false
Testing the Media Proxy Control Software Send random command sequences Generate random messages in a random command sequence But not completely random! QuickCheck Media Proxy Check the responses
Message Example: ASN.1 Description • A media descriptor contains a list of streams MediaDescriptor ::= SEQUENCE { termStateDescr TerminationStateDescriptor OPTIONAL, streams CHOICE { oneStream StreamParms, multiStream SEQUENCE OF StreamDescriptor } OPTIONAL, … }
…with IWD Restrictions • A media descriptor contains a list of streams MediaDescriptor ::= SEQUENCE { termStateDescr TerminationStateDescriptor OPTIONAL, streams CHOICE { oneStream StreamParms, multiStream SEQUENCE OF StreamDescriptor } OPTIONAL, … }
QuickCheck Generator for Erlang Records mediadescriptor(Streams) when Streams=/=[]-> {mediaDescriptor, #'MediaDescriptor'{ streams = case Streams of [{Id,Mode}] -> oneof([{oneStream,streamParms(Mode)}, {multiStream,[stream(Id,Mode)]}]); _ -> {multiStream, [stream(I,M) || {I,M}<-Streams]} end}}. stream(I,Mode) -> #'StreamDescriptor'{ streamID = I, streamParms = streamParms(Mode)}. Generators can be embedded in any data structure Message construction Logic from the IWD QuickCheck
Local Control Descriptors StreamParms ::= SEQUENCE { localControlDescriptor LocalControlDescriptor OPTIONAL, localDescriptor LocalRemoteDescriptor OPTIONAL, remoteDescriptor LocalRemoteDescriptor OPTIONAL, …, statisticsDescriptor StatisticsDescriptor OPTIONAL }
Two Cases: With and Without Remote Media Random boolean with high probability streamParms(Mode) -> ?LET(RemoteMediaDefined, probably(), if RemoteMediaDefined -> #'StreamParms'{ localControlDescriptor = localControl(Mode), localDescriptor = localDescriptor(RemoteMediaDefined), remoteDescriptor = remoteDescriptor(RemoteMediaDefined)}; true -> …… end).
Megaco Commands Context Context
Megaco Commands Context Context Context Termination Add Returns Context ID & Termination ID
Megaco Commands Context Context Uses context ID Add Context Termination Termination
Megaco Commands Context Context Context Termination Termination Modify Stream Stream Uses termination ID
Megaco Commands Context Context Subtract Context Termination Termination Stream Stream
Megaco Commands Context Context Context Termination Subtract Stream Stream
Megaco Commands Context Context
Symbolic Test Cases • Generated wrt an abstract state machine tracking contexts, terminations & streams [{set,1,…,send_add, [?choose_cxt_id,Streams,Req]}, {assert,…,check_add,[{var,1}], {set,2,…,send_add, [{call,…,get_reply_cxt,[{var,1}]}, Streams2,Req2]}, {assert,…,check_add,[{var,2}]}]
Encode/Decode Error • Recall the stream parameters… StreamParms ::= SEQUENCE { localControlDescriptor LocalControlDescriptor OPTIONAL, localDescriptor LocalRemoteDescriptor OPTIONAL, remoteDescriptor LocalRemoteDescriptor OPTIONAL, …, statisticsDescriptor StatisticsDescriptor OPTIONAL }
Add/Modify Error Add Modify
Add/Subtract Error • There one day, gone the next… Add Subtract
Add/Add/Modify Error • If the terminations have different numbers of streams Add Add Modify
Add/Add/Sub/Add… Error • Extracted from a test case 160 commands long Add Add Add Subtract Subtract Add Subtract