mock adapter: Group all replies for one request under one call to MockReply 44/13244/4
authorMilan Lenco <milan.lenco@pantheon.tech>
Wed, 27 Jun 2018 13:55:43 +0000 (15:55 +0200)
committerMilan Lenco <milan.lenco@pantheon.tech>
Wed, 27 Jun 2018 14:20:55 +0000 (16:20 +0200)
commit5276b9439d0f902e125a5113bfa4f1b6622aea18
tree012189945f413ce7f78528ea348edc41f6a11326
parent8adb6cdcb496f05169263d32a857791faf8baee1
mock adapter: Group all replies for one request under one call to MockReply

Sequence numbers are now used to match requests with replies.
Mock adapter thus has to be able to tell how many messages
from the head of the queue with mock replies belong to the currently
processed request. Then they can be given the right context and
the rest of the queued replies are postponed to be delivered later
(when context of their request is known).

All replies for one request are now therefore queued together.
This affects just multipart requests for which replies have to
be pushed all at once. The trailling control ping reply is still
queued separately, however, because that is actualy another request,
e.g.:

    mockVpp.MockReply(  // push multipart messages all at once
                      &interfaces.SwInterfaceDetails{SwIfIndex:1},
                      &interfaces.SwInterfaceDetails{SwIfIndex:2},
                      &interfaces.SwInterfaceDetails{SwIfIndex:3},
    )
    mockVpp.MockReply(&vpe.ControlPingReply{})

Even if the multipart request has no replies, MockReply has to be
called exactly twice:

    mockVpp.MockReply()  // zero multipart messages
    mockVpp.MockReply(&vpe.ControlPingReply{})

Change-Id: I28c15d2f52d14dca0b7fb06033d7270a7da2bde6
Signed-off-by: Milan Lenco <milan.lenco@pantheon.tech>
adapter/mock/mock_adapter.go
api/api.go
api/api_test.go
core/core_test.go