-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testing remote capabilities using virtual networks #149
base: master
Are you sure you want to change the base?
Conversation
Oh we need to figure out how to run docker inside the travis vms |
Yah, I've done it before in that other project I pointed to prior. |
Also class SingleSwitchTopo( Topo ):
"Single switch connected to n hosts."
def build( self, n=2, lossy=True ):
switch = self.addSwitch('s1')
for h in range(n):
# Each host gets 50%/n of system CPU
host = self.addHost('h%s' % (h + 1),
cpu=.5 / n)
if lossy:
# 10 Mbps, 5ms delay, 10% packet loss
self.addLink(host, switch,
bw=10, delay='5ms', loss=10, use_htb=True)
else:
# 10 Mbps, 5ms delay, no packet loss
self.addLink(host, switch,
bw=10, delay='5ms', loss=0, use_htb=True) All the examples here are very useful. |
@@ -4,46 +4,6 @@ sudo: required | |||
|
|||
matrix: | |||
include: | |||
- name: "Windows, Python Latest: multiprocessing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should look into if anyone has had this problem before we drop all this.
… test multi host.
@guilledk We dropped travisCI once the debugger stuff landed. |
@goodboy So whats the plan here, wanna give this another shot? I recently learned how to run docker containers inside github's CI |
@guilledk I think if we're gonna do it let's use a real use case:
|
Another tool that might be handy if/when we get back to this: |
This starts to address #124
pytest-vnet does most of the heavy work, creates a docker container from this docker image based on debian, it installs the latest mininet release from its github and sets up python build essentials, on the first run it will install python inside the container and save a snapshot for each python version it installs, to avoid repeating the process.
From mininet.org: "Mininet creates a realistic virtual network, running real kernel, switch and application code, on a single machine (VM, cloud or native)"
To use this virutal net,
pytest-vnet
allows us to mark our regular test functions with the decorator@run_in_netvm
, here is a full example:Test functions marked with
@run_in_netvm
will be loaded as a script inside the running docker container, and the following code will be injected on them:As you can see by default a bunch of packages are imported and an empty virtual net is created:
vnet
, this network gets automatically stopped at the end of the script. That try catch is to properly relay exceptions to pytest in the future, for now, the traceback format exec gets thrown intostderr
Then each function marked with
@as_host
gets loaded to the netvm as a separate script but also it will create a newmininet
host and link to the network, here is the decorator code:To actually start the process one must call
as_host_wrapped_func.start_host()
.disclaimer:
pytest-vnet
is in very early development