Project

General

Profile

Feature #4024

NetworkMonitor: stub implementation

Added by Junxiao Shi over 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Utils
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
5.00 h

Description

In NetworkMonitor, allow getNetworkInterface and listNetworkInterfaces return value to be mocked in a test case.


Related issues

Related to ndn-cxx - Feature #4025: NetworkMonitor: empty impl on unsupported platformClosedJunxiao Shi

Actions
Blocks NFD - Feature #4021: FaceSystem: use NetworkMonitor::listNetworkInterfaces()ClosedJunxiao Shi

Actions
Blocked by ndn-cxx - Feature #3353: NetworkMonitor: emit fine-grained signals when the state of a network interface changesClosedDavide Pesavento

Actions
#1

Updated by Junxiao Shi over 3 years ago

  • Blocks Feature #4021: FaceSystem: use NetworkMonitor::listNetworkInterfaces() added
#2

Updated by Junxiao Shi over 3 years ago

  • Blocked by Feature #3353: NetworkMonitor: emit fine-grained signals when the state of a network interface changes added
#3

Updated by Junxiao Shi over 3 years ago

  • Related to Feature #4025: NetworkMonitor: empty impl on unsupported platform added
#4

Updated by Junxiao Shi over 3 years ago

  • Status changed from New to In Progress
  • Assignee set to Junxiao Shi

Design:

  • Pure virtual base class NetworkMonitor::ImplBase is introduced. It is a friend of NetworkMonitor, and offers protected methods to modify NetworkMonitor data structures or emit signals on it. ImplBase type is public API.
  • Existing Impl class inherit from ImplBase. It is not a friend of NetworkMonitor, but accesses NetworkMonitor data structures and signals via ImplBase protected methods. Impl type is not public API.
  • NetworkMonitor constructor takes unique_ptr<NetworkMonitor::ImplBase>, which defaults to nullptr. Passing nullptr causes the constructor to internally make an Impl instance.
  • NetworkInterface type setters are made public. NetworkMonitor APIs that return NetworkInterface are changed to return const NetworkInterface instead so that setters cannot be invoked by outsider.
  • MockImpl class inherits from ImplBase and exposes its protected methods as public. To make a mock NetworkMonitor, pass a MockImpl instance to NetworkMonitor constructor.
#5

Updated by Davide Pesavento over 3 years ago

Junxiao Shi wrote:

  • NetworkInterface type setters are made public.

I'd rather keep them private.

#6

Updated by Junxiao Shi over 3 years ago

Reply to note-5:

How would you propose to let a test case create and update a NetworkInterface?
What's the harm of making the setters public? If someone uses const_cast, it's their problem. Testability is more important than absolute protection.

#7

Updated by Davide Pesavento over 3 years ago

@Junxiao, are you still working on this?

#8

Updated by Junxiao Shi over 3 years ago

I'm waiting for the design discussion to be resolved.

For coding, I'm waiting for #3817 to close in order to avoid conflicts.

#9

Updated by Davide Pesavento over 3 years ago

  • Blocked by Feature #3817: NetworkMonitor fine-grained signals for macOS added
#10

Updated by Davide Pesavento over 3 years ago

  • Blocked by deleted (Feature #3817: NetworkMonitor fine-grained signals for macOS)
#11

Updated by Davide Pesavento over 3 years ago

The main change of #3817 has been merged. Remaining changes under that task will be minor and localized, thus this task is no longer blocked by #3817.

#12

Updated by Junxiao Shi about 3 years ago

  • % Done changed from 0 to 20
  • Estimated time set to 5.00 h

https://gerrit.named-data.net/3978 patchset1 illustrates some of the API changes. I've skipped macOS variant for now. It also does not include MockImpl yet.

#13

Updated by Junxiao Shi about 3 years ago

  • % Done changed from 20 to 40

https://gerrit.named-data.net/3978 patchset2 brings the public API design of MockNetworkMonitor. It's structured as a subclass of NetworkMonitor rather than an Impl, because the Impl is passed by unique_ptr to NetworkMonitor and thus is solely owned by NetworkMonitor, so it's unsafe for the caller to keep a reference to an Impl. Instead, MockNetworkMonitor can internally manage an Impl and forward calls to it.

#14

Updated by Junxiao Shi about 3 years ago

  • Status changed from In Progress to Code review
  • % Done changed from 40 to 100
#15

Updated by Alex Afanasyev about 3 years ago

  • Status changed from Code review to Closed
#16

Updated by Davide Pesavento about 3 years ago

  • Subject changed from NetworkMonitor: mock impl to NetworkMonitor: stub implementation

Also available in: Atom PDF