]>
Commit | Line | Data |
---|---|---|
598d8457 | 1 | # FRRouting Topology Tests with Mininet |
59d80fff MW |
2 | |
3 | ## Installation of Mininet for running tests | |
024fc0b8 | 4 | Only tested with Ubuntu 16.04 (which uses Mininet 2.2.0) |
59d80fff | 5 | |
8ab9a376 MW |
6 | Instructions are the same for all setups (ie ExaBGP is only used for BGP |
7 | tests) | |
59d80fff MW |
8 | |
9 | ### Installing Mininet Infrastructure: | |
10 | ||
11 | 1. apt-get install mininet | |
12 | 2. apt-get install python-pip | |
13 | 3. apt-get install iproute | |
14 | 4. pip install ipaddr | |
6b1be61a | 15 | 5. pip install pytest |
cc230e73 MW |
16 | 6. pip install exabgp==3.4.17 |
17 | (Newer 4.0 version of exabgp is not yet supported) | |
6b1be61a MW |
18 | 7. useradd -d /var/run/exabgp/ -s /bin/false exabgp |
19 | ||
20 | ### Enable Coredumps | |
21 | Optional, will give better output | |
22 | ||
23 | 1. apt-get install gdb | |
24 | 2. disable apport (which move core files) | |
25 | ||
26 | Set `enabled=0` in `/etc/default/apport` | |
27 | ||
28 | 3. Update security limits | |
29 | ||
30 | Add/change `/etc/security/limits.conf` to | |
31 | ||
32 | #<domain> <type> <item> <value> | |
33 | * soft core unlimited | |
34 | root soft core unlimited | |
35 | * hard core unlimited | |
36 | root hard core unlimited | |
37 | ||
38 | 4. reboot (for options to take effect) | |
59d80fff | 39 | |
598d8457 | 40 | ## FRRouting (FRR) Installation |
1c909f42 | 41 | FRR needs to be installed separatly. It is assume to be configured |
8ab9a376 | 42 | like the standard Ubuntu Packages: |
59d80fff | 43 | |
33ae1f75 MW |
44 | - Binaries in /usr/lib/frr |
45 | - State Directory /var/run/frr | |
46 | - Running under user frr, group frr | |
47 | - vtygroup: frrvty | |
48 | - config directory: /etc/frr | |
49 | - For FRR Packages, install the dbg package as well for coredump decoding | |
59d80fff | 50 | |
33ae1f75 | 51 | No FRR config needs to be done and no FRR daemons should be run ahead |
59d80fff MW |
52 | of the test. They are all started as part of the test |
53 | ||
598d8457 | 54 | #### Manual FRRouting (FRR) build |
024fc0b8 | 55 | |
33ae1f75 | 56 | If you prefer to manually build FRR, then use the following suggested config: |
024fc0b8 MW |
57 | |
58 | ./configure \ | |
59 | --prefix=/usr \ | |
33ae1f75 MW |
60 | --localstatedir=/var/run/frr \ |
61 | --sbindir=/usr/lib/frr \ | |
62 | --sysconfdir=/etc/frr \ | |
024fc0b8 MW |
63 | --enable-vtysh \ |
64 | --enable-pimd \ | |
65 | --enable-multipath=64 \ | |
33ae1f75 MW |
66 | --enable-user=frr \ |
67 | --enable-group=frr \ | |
68 | --enable-vty-group=frrvty \ | |
024fc0b8 MW |
69 | --with-pkg-extra-version=-my-manual-build |
70 | ||
33ae1f75 | 71 | And create frr User and frrvty group as follows: |
024fc0b8 | 72 | |
33ae1f75 MW |
73 | addgroup --system --gid 92 frr |
74 | addgroup --system --gid 85 frrvty | |
33ae1f75 | 75 | adduser --system --ingroup frr --home /var/run/frr/ \ |
598d8457 | 76 | --gecos "FRRouting suite" --shell /bin/false frr |
3a4f98d5 | 77 | usermod -G frrvty frr |
024fc0b8 | 78 | |
59d80fff MW |
79 | ## Executing Tests |
80 | ||
6b1be61a MW |
81 | #### Execute all tests with output to console |
82 | ||
83 | py.test -s -v --tb=no | |
84 | ||
50c40bde MW |
85 | All test_* scripts in subdirectories are detected and executed (unless |
86 | disabled in `pytest.ini` file) | |
6b1be61a MW |
87 | |
88 | `--tb=no` disables the python traceback which might be irrelevant unless the | |
89 | test script itself is debugged | |
90 | ||
91 | #### Execute single test | |
09bd98fb | 92 | |
6b1be61a MW |
93 | cd test_to_be_run |
94 | ./test_to_be_run.py | |
09bd98fb | 95 | |
6b1be61a MW |
96 | For further options, refer to pytest documentation |
97 | ||
98 | Test will set exit code which can be used with `git bisect` | |
59d80fff MW |
99 | |
100 | For the simulated topology, see the description in the python file | |
8ab9a376 MW |
101 | |
102 | If you need to clear the mininet setup between tests (if it isn't cleanly | |
103 | shutdown), then use the `mn -c` command to clean up the environment | |
104 | ||
50c40bde MW |
105 | #### (Optional) StdErr log from daemos after exit |
106 | ||
107 | To enable the reporting of any messages seen on StdErr after the | |
108 | daemons exit, the following env variable can be set. | |
109 | ||
110 | export TOPOTESTS_CHECK_STDERR=Yes | |
111 | ||
112 | (The value doesn't matter at this time. The check is if the env variable | |
113 | exists or not) | |
114 | There is no pass/fail on this reporting. The Output will be reported to | |
115 | the console | |
116 | ||
117 | export TOPOTESTS_CHECK_MEMLEAK="/home/mydir/memleak_" | |
118 | ||
119 | This will enable the check and output to console and the writing of | |
120 | the information to files with the given prefix (followed by testname), | |
121 | ie `/home/mydir/memcheck_test_bgp_multiview_topo1.txt` in case of a | |
122 | memory leak. | |
123 | ||
124 | #### (Optional) Collect Memory Leak Information | |
125 | ||
126 | FreeRangeRouting processes have the capabilities to report remaining memory | |
127 | allocations upon exit. To enable the reporting of the memory, define an | |
128 | enviroment variable `TOPOTESTS_CHECK_MEMLEAK` with the file prefix, ie | |
129 | ||
130 | export TOPOTESTS_CHECK_MEMLEAK="/home/mydir/memleak_" | |
131 | ||
132 | This will enable the check and output to console and the writing of | |
133 | the information to files with the given prefix (followed by testname), | |
134 | ie `/home/mydir/memcheck_test_bgp_multiview_topo1.txt` in case of a | |
135 | memory leak. | |
136 | ||
3a1f8275 MW |
137 | #### (Optional) Run topotests with GCC AddressSanitizer enabled |
138 | ||
139 | Topotests can be run with the GCC AddressSanitizer. It requires GCC 4.8 or | |
140 | newer. (Ubuntu 16.04 as suggested here is fine with GCC 5 as default) | |
141 | For more information on AddressSanitizer, see | |
142 | https://github.com/google/sanitizers/wiki/AddressSanitizer | |
143 | ||
144 | The checks are done automatically in the library call of `checkRouterRunning` | |
145 | (ie at beginning of tests when there is a check for all daemons running). | |
146 | No changes or extra configuration for topotests is required beside compiling | |
147 | the suite with AddressSanitizer enabled. | |
148 | ||
149 | If a daemon crashed, then the errorlog is checked for AddressSanitizer | |
150 | output. If found, then this is added with context (calling test) to | |
151 | `/tmp/AddressSanitizer.txt` in markdown compatible format. | |
152 | ||
153 | Compiling for GCC AddressSanitizer requires to use gcc as a linker as well | |
154 | (instead of ld). Here is a suggest way to compile frr with AddressSanitizer | |
155 | for `stable/3.0` branch: | |
156 | ||
157 | git clone https://github.com/FRRouting/frr.git | |
158 | cd frr | |
159 | git checkout stable/3.0 | |
160 | ./bootstrap.sh | |
161 | export CC=gcc | |
162 | export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer" | |
163 | export LD=gcc | |
164 | export LDFLAGS="-g -fsanitize=address -ldl" | |
165 | ./configure --enable-shared=no \ | |
166 | --prefix=/usr/lib/frr --sysconfdir=/etc/frr \ | |
167 | --localstatedir=/var/run/frr \ | |
168 | --sbindir=/usr/lib/frr --bindir=/usr/lib/frr \ | |
169 | --enable-exampledir=/usr/lib/frr/examples \ | |
170 | --with-moduledir=/usr/lib/frr/modules \ | |
171 | --enable-multipath=0 --enable-rtadv \ | |
172 | --enable-tcp-zebra --enable-fpm --enable-pimd | |
173 | make | |
174 | sudo make install | |
09bd98fb MW |
175 | # Create symlink for vtysh, so topotest finds it in /usr/lib/frr |
176 | sudo ln -s /usr/lib/frr/vtysh /usr/bin/ | |
177 | ||
178 | and create `frr` user and `frrvty` group as shown above | |
3a1f8275 | 179 | |
8ab9a376 MW |
180 | ## License |
181 | ||
182 | All the configs and scripts are licensed under a ISC-style license. See | |
183 | Python scripts for details. |