Feature #2796
closedTests for Ping and PingServer
0%
Description
Create unit tests for:
PingStatisticsCollectorPingServer
Those components should be tested individually.
There should also be an integrated scenario that tests Ping and PingServer together.
Minor refactoring of Ping and PingServer may be necessary to support unit testing, and they can be completed as part of this issue.
Updated by Junxiao Shi over 10 years ago
- Blocked by Task #2795: Introduce unit testing added
Updated by Junxiao Shi over 10 years ago
- Blocked by Task #2793: pingserver: refactor for separate responsibility added
Updated by Junxiao Shi over 10 years ago
- Blocked by Task #2702: ping: refactor for separate responsibility added
Updated by Eric Newberry over 10 years ago
- Status changed from New to In Progress
Updated by Eric Newberry over 10 years ago
The only public function in Ping is void run()? What can really be tested?
Updated by Junxiao Shi over 10 years ago
Reply to note-6:
PingServer can be individually tested by feeding Interests into it through a DummyClientFace.
Ping and PingServer can be tested together by attaching them onto two paired DummyClientFaces.
The pairing mechanism can be used to simulate packet losses between Ping and PingServer.
Updated by Eric Newberry over 10 years ago
Is there a way to pause the thread in the unit tests for ndntools? I need to do this to wait for timeouts and the like. I see something similar in the ndn-cxx tests (UnitTestTimeFixture), but not in ndntools.
Updated by Eric Newberry over 10 years ago
Also, wouldn't the server and client have to be run in separate threads for the integrated tests, as their run() functions are blocking?
Updated by Junxiao Shi over 10 years ago
Reply to note-7:
UnitTestTimeFixture can copied to ndn-tools if necessary.
Reply to note-8:
No, I didn't expect this test suite to require multi-threading.
It seems that a bit of additional refactoring is necessary to support unit testing (and also ndnSIM integration):
PingandPingServerhook work (eg. express Interest on Face, register prefix on Face, schedule events with Scheduler) onto theio_serviceof the suppliedFacein astartmethod.Ping::run()andPingServer::run()callthis->start()and thenio.run().- The test case can invoke
.start()on bothPingandPingServer, followed byio.run()orio.poll(), to execute bothPingandPingServeron the same thread.
Updated by Eric Newberry over 10 years ago
Junxiao Shi wrote:
It seems that a bit of additional refactoring is necessary to support unit testing (and also ndnSIM integration):
PingandPingServerhook work (eg. express Interest on Face, register prefix on Face, schedule events with Scheduler) onto theio_serviceof the suppliedFacein astartmethod.Ping::run()andPingServer::run()callthis->start()and thenio.run().- The test case can invoke
.start()on bothPingandPingServer, followed byio.run()orio.poll(), to execute bothPingandPingServeron the same thread.
I'll work on the refactoring. Another redmine issue will probably be necessary for it.
Updated by Junxiao Shi over 10 years ago
- Description updated (diff)
Another redmine issue will probably be necessary for it.
It's unnecessary to create another issue or use a separate commit.
Just say "This commit includes minor refactoring in Ping and PingServer classes in order to support unit testing" in commit message.
When this refactoring is separated from the unit testing, it's hard to tell whether the refactoring fulfills the goal of support unit testing.
Updated by Eric Newberry over 10 years ago
I refactored Ping and PingServer. Ping and PingServer are on different DummyClientFaces that are on the same io_service. However, PingServer is not receiving Interests from Ping. Is there a special method that has to be used to work with DummyClientFace?
Updated by Junxiao Shi over 10 years ago
Answer to note-13:
Two DummyClientFaces attached to the same io_service won't magically communicate with each other.
They need to be glued together. See ndn::ndns::tests::QueryControllerFixture for an example.
Updated by Eric Newberry over 10 years ago
- Status changed from In Progress to Code review
Updated by Junxiao Shi about 10 years ago
- Status changed from Code review to Closed