Revision 2a8b9496

View differences:

Test/test_disabledefaultroutes.py
1
from time import time
2
import os
3

  
4
from test_generic import MininetTest
5

  
6

  
7
def test_disable_default_routes():
8
    os.system("sudo rm -rf pingTestNoRoutes_toy*")
9
    os.system("sudo ./nepa_test.py -f conf/ping.ini -t pingTestNoRoutes")
10
    for f in os.listdir("."):
11
        if f.startswith("pingTestNoRoutes_toy"):
12
            for log in os.listdir(f):
13
                if log.endswith(".log") and not log.startswith("h1"):
14
                    with open(f + "/" + log, "r") as log_file:
15
                        content = log_file.read()
16
                        assert(content.find("bytes from") == -1) 
17
    os.system("sudo rm -rf pingTestNoRoutes_toy*")
18

  
19

  
20
def test_enable_default_routes():
21
    os.system("sudo rm -rf pingTest_toy*")
22
    os.system("sudo ./nepa_test.py -f conf/ping.ini -t pingTest")
23
    for f in os.listdir("."):
24
        if f.startswith("pingTest_toy"):
25
            for log in os.listdir(f):
26
                if log.endswith(".log"):
27
                    with open(f + "/" + log, "r") as log_file:
28
                        content = log_file.read()
29
                        assert(content.find("Destination Host Unreachable") == -1) 
30
    os.system("sudo rm -rf pingTest_toy*")
conf/ping.ini
11 11
duration = 10
12 12
graphDefinition = data/ninux-IPv6.json
13 13
times = 1
14

  
15
[pingTestNoRoutes]
16
testModule = ping
17
testClass = pingNode0Test
18
enableShortestRoutes = False
19
duration = 5
20
graphDefinition = data/toy.edges
21
times = 1
test_code/ping.py
34 34
        info("Data folder: "+self.prefix+"\n")
35 35

  
36 36
        for h in self.getAllHosts():
37
            self.launchPing(h)
37
            if h.defaultIntf().ip != self.destination:
38
                self.launchPing(h)
38 39

  
39 40
        info("Waiting completion...\n")
40 41
        self.wait(self.duration, log_resources={'net': 'netusage.csv'})
......
46 47

  
47 48
        duration = int(args["duration"])
48 49
        super(pingRandomTest, self).__init__(mininet, duration)
49
        h =  self.getHostSample(1)
50 50
        self.destination = self.getHostSample(1)[0].defaultIntf().ip
51 51
        self.setPrefix(name)
52 52

  
53
class pingNode0Test(pingTest):
54

  
55
    def __init__(self, mininet, name, args):
56

  
57
        duration = int(args["duration"])
58
        super(pingRandomTest, self).__init__(mininet, duration)
59
        self.destination = self.net.value()[0].defaultIntf().ip
60
        self.setPrefix(name)
53 61

  

Also available in: Unified diff