Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion bddTests.feature
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,19 @@
# And we connect host h2 to switch s5
# And we start a webserver on host h2
# When we send a http request from host h1 to host h2
# Then the http traffic from host h1 to host h2 takes the route across switch s4
# Then the http traffic from host h1 to host h2 takes the route across switch s4


# IPv6 Tests
#
# Scenario: Directed IPv6 Ping
# Given four hosts connected to one switch
# And we enable IPv6 addressing
# When host h1 pings host h2 2 times via IPv6
# Then the ping succeeds
#
# Scenario: IPv6 Pingall with less than 20% packetloss
# Given a tree topo with depth one and fanout two
# And we enable IPv6 addressing
# When we ping all hosts via IPv6
# Then the packetloss is below 20 percent
66 changes: 66 additions & 0 deletions steps/stepImpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from mininet.link import *
from helper import NumberConverter, MininetHelper, TerraformHelper
from environment import *
import itertools



Expand Down Expand Up @@ -51,6 +52,14 @@ def step_startWebserver(context, hst):
cmdString = "python -m SimpleHTTPServer 80 &"
serverNode.cmd(cmdString)

@given('we enable IPv6 addressing')
def step_addIPv6Address(context):
hosts = context.mini.hosts
cnt = 1
for host in hosts:
host.cmd('ifconfig h{0}-eth0 inet6 add fc00:0000:0000:0000::{0}/16 '.format(str(cnt)))
cnt += 1

#########################################################
# WHEN Part

Expand Down Expand Up @@ -91,6 +100,54 @@ def step_ping(context, hst1, hst2):
pingCounter += 1
context.pingResult = packetLoss

# According to the error message, the same description is already used above
# @when('host {hst1} pings host {hst2} {x} times')
# def step_pingTimes(context, hst1, hst2, x):
# h1 = MininetHelper.getNodeFromName(context.mini, hst1)
# h2 = MininetHelper.getNodeFromName(context.mini, hst2)
# timeout = "5"
# packetloss = 0
# times = int(x)
# for _ in itertools.repeat(None, times):
# packetloss += context.mini.ping((h1, h2), timeout)
# sleep(0.50)
# context.pingResult = (packetloss / times)

when('host {hst1} pings host {hst2} {x} times via IPv6')
def step_pingTimesIPv6(context, hst1, hst2, x):
h1 = MininetHelper.getNodeFromName(context.mini, hst1)
h2 = MininetHelper.getNodeFromName(context.mini, hst2)
h2_address = h2.cmd("/sbin/ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -E -v '^fe80*|^::1*'")
times = int(x)
packetloss = h1.cmd("ping6 -c {0} {1} | grep -oP '\d+(?=% packet loss)'".format(times, h2_address.rstrip()))
try:
context.pingResult = int(packetloss) / times
except(ValueError):
context.pingResult = 100

@when('we ping all hosts via IPv6')
def step_pingAllHostsIPv6(context):
hosts = context.mini.hosts
if (hosts): # A trial with no hosts would result in dividing by zero
addresses = []
packetloss = 0
for host in hosts:
# gets the ipv6 address. Excludes linklocal and host address
addresses.append(host.cmd("/sbin/ip -6 addr | grep inet6 | awk -F '[ \t]+|/' '{print $3}' | grep -E -v '^fe80*|^::1*'"))
for host in hosts:
for address in addresses:
result = host.cmd("ping6 -c 1 {0} | grep -oP '\d+(?=% packet loss)'".format(address.rstrip()))
try:
packetloss += int(result)
except(ValueError): # result was string => 'ping failed'
packetloss += 100
break
context.pingResult = int(packetloss / len(hosts))
else:
context.pingResult = 100 # error case => no host was found



@when('the link between {nd1} and {nd2} is going down')
def step_linkDown(context, nd1, nd2):
node1 = MininetHelper.getNodeFromName(context.mini, nd1)
Expand Down Expand Up @@ -154,6 +211,15 @@ def step_pingSucceed(context):
ping = False
assert_that(ping, equal_to(True), "Ping succeeds")

@then('the packetloss is below {ptls} percent')
def step_comparePacketloss(context, ptls):
result = False
ptls = int(ptls)
if 0 <= ptls <= 100:
if context.pingResult < ptls:
result = True
assert_that(result, equal_to(True), ("Packetloss was below %s" % str(ptls)))

@then('the ping fails')
def step_pingFailure(context):
if context.pingResult > 0.0 :
Expand Down