Project

General

Profile

Actions

Feature #2796

closed

Tests for Ping and PingServer

Added by Junxiao Shi almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
Due date:
% Done:

0%

Estimated time:
6.00 h

Description

Create unit tests for:

  • Ping
  • StatisticsCollector
  • PingServer

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.


Related issues 3 (0 open3 closed)

Blocked by ndn-tools - Task #2795: Introduce unit testingClosedJunxiao Shi

Actions
Blocked by ndn-tools - Task #2793: pingserver: refactor for separate responsibilityClosedEric Newberry

Actions
Blocked by ndn-tools - Task #2702: ping: refactor for separate responsibilityClosedEric Newberry

Actions
Actions #1

Updated by Junxiao Shi almost 9 years ago

  • Blocked by Task #2795: Introduce unit testing added
Actions #2

Updated by Junxiao Shi almost 9 years ago

  • Blocked by Task #2793: pingserver: refactor for separate responsibility added
Actions #3

Updated by Junxiao Shi almost 9 years ago

  • Blocked by Task #2702: ping: refactor for separate responsibility added
Actions #4

Updated by Junxiao Shi almost 9 years ago

  • Assignee set to Eric Newberry
Actions #5

Updated by Eric Newberry over 8 years ago

  • Status changed from New to In Progress
Actions #6

Updated by Eric Newberry over 8 years ago

The only public function in Ping is void run()? What can really be tested?

Actions #7

Updated by Junxiao Shi over 8 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.

Actions #8

Updated by Eric Newberry over 8 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.

Actions #9

Updated by Eric Newberry over 8 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?

Actions #10

Updated by Junxiao Shi over 8 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):

  • Ping and PingServer hook work (eg. express Interest on Face, register prefix on Face, schedule events with Scheduler) onto the io_service of the supplied Face in a start method.
  • Ping::run() and PingServer::run() call this->start() and then io.run().
  • The test case can invoke .start() on both Ping and PingServer, followed by io.run() or io.poll(), to execute both Ping and PingServer on the same thread.
Actions #11

Updated by Eric Newberry over 8 years ago

Junxiao Shi wrote:

It seems that a bit of additional refactoring is necessary to support unit testing (and also ndnSIM integration):

  • Ping and PingServer hook work (eg. express Interest on Face, register prefix on Face, schedule events with Scheduler) onto the io_service of the supplied Face in a start method.
  • Ping::run() and PingServer::run() call this->start() and then io.run().
  • The test case can invoke .start() on both Ping and PingServer, followed by io.run() or io.poll(), to execute both Ping and PingServer on the same thread.

I'll work on the refactoring. Another redmine issue will probably be necessary for it.

Actions #12

Updated by Junxiao Shi over 8 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.

Actions #13

Updated by Eric Newberry over 8 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?

Actions #14

Updated by Junxiao Shi over 8 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.

Actions #15

Updated by Eric Newberry over 8 years ago

  • Status changed from In Progress to Code review
Actions #16

Updated by Junxiao Shi over 8 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF