Skip to content

Commit

Permalink
test generator
Browse files Browse the repository at this point in the history
  • Loading branch information
marcpucci committed Feb 26, 2016
1 parent abba705 commit d0e2b53
Show file tree
Hide file tree
Showing 28 changed files with 1,681 additions and 1,039 deletions.
181 changes: 125 additions & 56 deletions examples/test-ms/config/test.cfg
Original file line number Diff line number Diff line change
@@ -1,58 +1,127 @@
{
"hosts": {

"a1": {
"interfaces": {
}
} ,

"b1": {
"interfaces": {
"i0": { "bind": "140.0.0.1", "port": 80 },
"i1": { "bind": "140.0.0.1", "port": 4321 },
"i2": { "bind": "140.0.0.1", "port": 4322 },
"i3": { "bind": "140.0.0.1", "port": 8888 }
}
} ,

"c1": {
"interfaces": {
"i0": { "bind": "140.0.0.1", "port": 80 },
"i1": { "bind": "140.0.0.1", "port": 4321 },
"i2": { "bind": "140.0.0.1", "port": 4322 },
"i3": { "bind": "140.0.0.1", "port": 8888 }
}
} ,

"c2": {
"interfaces": {
"i0": { "bind": "140.0.0.1", "port": 80 },
"i1": { "bind": "140.0.0.1", "port": 4321 },
"i2": { "bind": "140.0.0.1", "port": 4322 },
"i3": { "bind": "140.0.0.1", "port": 8888 }
}
}
} ,

"tests": {
"t0": { "src": "a1", "baddr": "100.0.0.1", "daddr": "140.0.0.1", "dport": 80, "xdst": "b1", "xifc": "i0" },
"t1": { "src": "a1", "baddr": "100.0.0.1", "daddr": "140.0.0.1", "dport": 4321, "xdst": "c1", "xifc": "i1" },
"t2": { "src": "a1", "baddr": "100.0.0.1", "daddr": "140.0.0.1", "dport": 4322, "xdst": "c2", "xifc": "i2" },
"t3": { "src": "a1", "baddr": "100.0.0.1", "daddr": "140.0.0.1", "dport": 8888, "xdst": "c1", "xifc": "i3" }
} ,

"commands": {
"x0": "route -n",
"x1": "ps a",
"x2": "sudo ovs-ofctl dump-flows s1",
"x3": "sudo ovs-ofctl dump-flows s2",
"x4": "sudo ovs-ofctl dump-flows s3",
"x5": "sudo ovs-ofctl dump-flows s4"
} ,

"regressions": {
"verbose": "l 'r x0 a1 b1 c1 c2' 'e x1 x2 x3 x4 x5' t",
"terse": "l t"
}

"commands": {
"x0": "route -n",
"x1": "ps ax",
"x2": "sudo ovs-ofctl dump-flows s1",
"x3": "sudo ovs-ofctl dump-flows s2",
"x4": "sudo ovs-ofctl dump-flows s3",
"x5": "sudo ovs-ofctl dump-flows s4",
"x6": "sudo ovs-ofctl show s1"
},
"hosts": {
"h1_a1": {
"bind": "100.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h1_b1": {
"bind": "140.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h1_c1": {
"bind": "140.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h1_c2": {
"bind": "140.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h2_a1": {
"bind": "110.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h2_b1": {
"bind": "150.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h2_c1": {
"bind": "150.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
},
"h2_c2": {
"bind": "150.0.0.1",
"ports": [
"80",
"4321",
"4322",
"8888"
]
}
},
"regressions": {
"terse": "l t",
"terse-retry": "t",
"verbose": "l 'r x0 a1 b1 c1 c2' 'e x1 x2 x3 x4 x5 x6' t",
"verbose-retry": "'r x0 a1 b1 c1 c2' 'e x1 x2 x3 x4 x5 x6' t"
},
"rhosts": [
"a1",
"b1",
"c1",
"c2"
],
"tests": {
"t00": {
"baddr": "100.0.0.1",
"daddr": "140.0.0.1",
"dport": "80",
"src": "h1_a1",
"xdst": "h1_b1"
},
"t01": {
"baddr": "100.0.0.1",
"daddr": "140.0.0.1",
"dport": "4321",
"src": "h1_a1",
"xdst": "h1_c1"
},
"t02": {
"baddr": "100.0.0.1",
"daddr": "140.0.0.1",
"dport": "4322",
"src": "h1_a1",
"xdst": "h1_c2"
},
"t03": {
"baddr": "100.0.0.1",
"daddr": "140.0.0.1",
"dport": "8888",
"src": "h1_a1",
"xdst": "h1_c1"
}
}
}
58 changes: 58 additions & 0 deletions examples/test-ms/mininet/mininet.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"a1": {
"asn": 100,
"ip": "172.0.0.1/16",
"mac": "08:00:27:89:3b:9f",
"netnames": [
"h1_a1",
"h2_a1"
],
"networks": [
"100.0.0.0/24",
"110.0.0.0/24"
],
"port": 5
},
"b1": {
"asn": 200,
"ip": "172.0.0.11/16",
"mac": "08:00:27:92:18:1f",
"netnames": [
"h1_b1",
"h2_b1"
],
"networks": [
"140.0.0.0/24",
"150.0.0.0/24"
],
"port": 6
},
"c1": {
"asn": 300,
"ip": "172.0.0.21/16",
"mac": "08:00:27:54:56:ea",
"netnames": [
"h1_c1",
"h2_c1"
],
"networks": [
"140.0.0.0/24",
"150.0.0.0/24"
],
"port": 7
},
"c2": {
"asn": 300,
"ip": "172.0.0.22/16",
"mac": "08:00:27:bd:f8:b2",
"netnames": [
"h1_c2",
"h2_c2"
],
"networks": [
"140.0.0.0/24",
"150.0.0.0/24"
],
"port": 8
}
}
17 changes: 11 additions & 6 deletions examples/test-ms/mininet/sdnip.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,19 @@ def writeLine(indent, line):
configFile.write('%s%s\n' % (intentStr, line))

def getRouterId(interfaces):
intfAttributes = interfaces.itervalues().next()
print intfAttributes
if isinstance(intfAttributes, list):
for intfAttributesList in interfaces.itervalues():
if not isinstance(intfAttributesList, list):
continue
# Try use the first set of attributes, but if using vlans they might not have addresses
intfAttributes = intfAttributes[1] if not intfAttributes[0]['ipAddrs'] else intfAttributes[0]
return intfAttributes['ipAddrs'][0].split('/')[0]

intfAttributes = intfAttributesList[1] if not intfAttributesList[0]['ipAddrs'] else intfAttributesList[0]
return intfAttributes['ipAddrs'][0].split('/')[0]

print("FDP %s" % getRouterId(self.intfDict))
print(" FDP %s" % str(self.intfDict))
writeLine(0, 'hostname %s' % self.name);
writeLine(0, 'password %s' % 'sdnip')
writeLine(0, 'log file /var/run/quagga/q_%s' % self.asNum)
writeLine(0, 'debug bgp')
writeLine(0, '!')
writeLine(0, 'router bgp %s' % self.asNum)
writeLine(1, 'bgp router-id %s' % getRouterId(self.intfDict))
Expand All @@ -171,6 +175,7 @@ def generateZebra(self):
configFile = open(self.zebraConfFile, 'w+')
configFile.write('hostname %s\n' % self.name)
configFile.write('password %s\n' % 'sdnip')
configFile.write('log file /var/run/quagga/z_%s debugging\n' % self.asNum)
configFile.close()

def terminate(self):
Expand Down
Loading

0 comments on commit d0e2b53

Please sign in to comment.