1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| | #! /usr/bin/python3
# SPDX-License-Identifier: GPL-2.0-or-later
#
# tasst - Test A Simple Socket Transport
# library of test helpers for passt & pasta
#
# tasst/metatest/veth - Test the veth creation helper
#
# These test code from tasst.site, but require additional support from
# tasst.nstool.
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>
import avocado
from tasst import Tasst
from tasst.site import REAL_HOST
from tasst.nstool import UnshareSite
class VethTasst(Tasst):
"""
Test helpers for creating veths between namespaces
:avocado: tags=meta
"""
def setUp(self):
super().setUp()
self.ns1 = UnshareSite(type(self).__name__ + '.1', '-Un')
self.ns2 = UnshareSite(type(self).__name__ + '.2', '-n',
parent=self.ns1, sudo=True)
self.ns1.veth('veth1', 'veth2', self.ns2)
def tearDown(self):
self.ns2.close()
self.ns1.close()
super().tearDown()
def test_ifs(self):
self.assertCountEqual(self.ns1.ifs(), ['lo', 'veth1'])
self.assertCountEqual(self.ns2.ifs(), ['lo', 'veth2'])
def test_mtu(self):
self.assertEquals(self.ns1.mtu('veth1'), 1500)
self.assertEquals(self.ns2.mtu('veth2'), 1500)
|