Skip to content

Refactor ipaddress module - #536

Merged
grafnu merged 4 commits into
faucetsdn:masterfrom
grafnu:iprefactor
Jul 15, 2020
Merged

grafnu merged 4 commits into
faucetsdn:masterfrom
grafnu:iprefactor

Conversation

@grafnu

@grafnu grafnu commented Jul 15, 2020

Copy link
Copy Markdown
Collaborator

Not done yet (still need to get all the tests to pass... aka make it actually work), but this is the base of the refactoring.

@grafnu
grafnu requested a review from henry54809 July 15, 2020 00:50
@codecov

codecov Bot commented Jul 15, 2020 •

Copy link
Copy Markdown

Codecov Report

Merging #536 into master will increase coverage by 0.14%.
The diff coverage is 96.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
+ Coverage   80.21%   80.35%   +0.14%     
==========================================
  Files          21       22       +1     
  Lines        3699     3727      +28     
==========================================
+ Hits         2967     2995      +28     
  Misses        732      732              
Flag Coverage Δ
#aux 75.35% <90.36%> (+0.99%) ⬆️
#base 76.95% <95.18%> (+1.12%) ⬆️
#dhcp 72.06% <89.15%> (+1.24%) ⬆️
#many 71.84% <90.36%> (+0.19%) ⬆️
#modules 23.63% <26.50%> (+0.22%) ⬆️
#topo 72.39% <49.39%> (-0.46%) ⬇️
Impacted Files Coverage Δ
daq/ipaddr_test.py 95.74% <95.74%> (ø)
daq/host.py 90.90% <96.77%> (+0.04%) ⬆️
daq/docker_test.py 97.56% <100.00%> (ø)
daq/gcp.py 31.01% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe0bf8b...a44b491. Read the comment docs.

@henry54809

Copy link
Copy Markdown
Collaborator

I thought the Abstraction is for any test under a module rather than specifically for ip addr test.

@grafnu

grafnu commented Jul 15, 2020 via email

Copy link
Copy Markdown
Collaborator Author

@henry54809

Copy link
Copy Markdown
Collaborator

So a test class just like the existing docker test class rather than the current ipaddr test class just for IP addr test. Do you plan on having a different class for each existing test module, ping, switch nmap, etc?

I'm not sure what you mean. There's two things going on -- the abstraction itself which is only loosely applied (since e.g. there is no actual base class) and then the singular instantiation of it for ipaddr tests.
…

@grafnu

grafnu commented Jul 15, 2020 via email

Copy link
Copy Markdown
Collaborator Author

@henry54809 henry54809 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, we should clearly differentiate module vs test everywhere in DAQ. 1 module can have multi tests, but all tests should be contained in some module, so the relationship between module and test is 1 to many. I envision the hierarchy can be something like this

  • (Module)
    • Docker
    • (Native/ Inline)
      • (Test 1 extends Test)
      • (Test 2 extends Test)
        ...
  • (Test)
    ...
    That difference aside, in this PR, ipaddr and docker test are on the same level as indicated in the new_test function, even though docker test is a module and ip addr test is a test in the ipaddr module. I think there can be more time invested in thinking / experimenting with the level of abstractions needed for the hybrid of docker + native tests before we do commit.

I would imaging the (virtual) module class hierarchy something like: - (TestModule) - Docker - (Native) - (Inline) - ipaddr The things in () don't currently exist as actual code -- either because of a collapsed abstraction (joys of ducktyping) or because they haven't been written yet (Native). So, something like ping would not have a specific class as long as it's instantiated as a docker container (how it currently is) or a native module. Right now, I'm not aware of anything else that would be an "inline" module. A native module would be very similar to a docker module, in that the actual DAQ code for it would be only a wrapper around an externally executed script.
…
On Tue, Jul 14, 2020 at 7:27 PM henry54809 @.***> wrote: So a test class just like the existing docker test class rather than the current ipaddr test class just for IP addr test. Do you plan on having a different class for each existing test module, ping, switch nmap, etc? I'm not sure what you mean. There's two things going on -- the abstraction itself which is only loosely applied (since e.g. there is no actual base class) and then the singular instantiation of it for ipaddr tests. … <#m_3978690006750142282_> — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <#536 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIEPD47RXTG4HXP2SLK55LR3UHX5ANCNFSM4O2A77OQ .

Comment thread usi/src/main/proto/usi.proto Outdated
ALLIED_TELESIS_X230 = 0;
CISCO_9300 = 1;
OVS_SWITCH = 2;
FAUX_SWITCH = 3;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a setup where there is no switch that can be controlled (it's OVS but not reachable)... and that's what this field indicated. but, this is not the right place to handle that, so I put a check in at a different layer to detect that connection and not allow the connect RPC call at all.

@grafnu grafnu changed the title WIP: Refactor ipaddress module Refactor ipaddress module Jul 15, 2020
Comment thread daq/host.py
self.devdir, test_name)
self.logger.debug('test_host start %s/%s', test_name, self._host_name())
def _new_test(self, test_name):
clazz = ipaddr_test.IpAddrTest if test_name == 'ipaddr' else docker_test.DockerTest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So IpAddrTest is a single port toggle test inside the ipaddr module whereas the DockerTest is a module, since Host class should be host of modules, something is not aligned. I think there should also be the test abstraction and module abstraction(other than dockertest) in place first before the current port_toggle test class.
Ip addr test and DockerTest are also both named test which is why we should also spend some time clearly distinguish test and module in code when we have time for more refactoring.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IpAddrTest and DockerTest are both "modules" in the sense they are a high-level entity that's managed by ConnectedHost. Both IpAddrTest and DockerTest, in turn, encapsulate individual line-item tests. There is an abstraction in place, but maybe you mean that it should be an explicit abstraction (e.g. with a named base-class or similar?)

@grafnu

grafnu commented Jul 15, 2020 via email

Copy link
Copy Markdown
Collaborator Author

@grafnu
grafnu merged commit 9f6add8 into faucetsdn:master Jul 15, 2020
@grafnu
grafnu deleted the iprefactor branch July 15, 2020 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants