diff options
author | Sergey V. Lobanov <sergey@lobanov.in> | 2022-09-04 18:49:42 +0300 |
---|---|---|
committer | Sergey V. Lobanov <sergey@lobanov.in> | 2022-09-04 19:06:49 +0300 |
commit | c92ff6266b18a9655edef231391739f0479dfb3a (patch) | |
tree | 0196077cbd54c9607ba918a42cac567411197663 /tests/accel-pppd/test_basic.py | |
parent | 38d96b8e20608fb743d543fe3f08ad4b9d1dcd66 (diff) | |
download | accel-ppp-c92ff6266b18a9655edef231391739f0479dfb3a.tar.gz accel-ppp-c92ff6266b18a9655edef231391739f0479dfb3a.zip |
add tests and ci workflow for running tests
This commit adds tests (using python3 pytest framework):
1. Test basic accel-cmd commands (show version, show stat, etc)
2. Test ipoe shared session up (dhcpv4) without radius
3. Test pppoe discovery (without PADO delay)
4. Test pppoe discovery (without PADO delay)
5. Test pppoe session up (ipv4) without radius
6. Test vlan creation using vlan-mon (pppoe)
These tests require external utils. Please read tests/README.md how to setup
environment, how to run the tests and how to generate coverage report
Also, run-tests.yml contains step-by-step instruction how to run the tests
Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
Diffstat (limited to 'tests/accel-pppd/test_basic.py')
-rw-r--r-- | tests/accel-pppd/test_basic.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/accel-pppd/test_basic.py b/tests/accel-pppd/test_basic.py new file mode 100644 index 00000000..2b2c6f71 --- /dev/null +++ b/tests/accel-pppd/test_basic.py @@ -0,0 +1,83 @@ +import pytest +from common import process + + +def test_accel_pppd_version(accel_pppd): + (exit, out, err) = process.run([accel_pppd, "--version"]) + + # test that accel-pppd --version exits with code 0, prints + # nothing to stdout and prints to stdout + assert exit == 0 and err == "" and "accel-ppp " in out and len(out.split(" ")) == 2 + + +@pytest.fixture() +def accel_pppd_config(): + return """ + [modules] + log_file + log_syslog + log_tcp + #log_pgsql + + pptp + l2tp + sstp + pppoe + ipoe + + auth_mschap_v2 + auth_mschap_v1 + auth_chap_md5 + auth_pap + + radius + chap-secrets + + ippool + + pppd_compat + shaper + #net-snmp + logwtmp + connlimit + + ipv6_nd + ipv6_dhcp + ipv6pool + + [core] + log-error=/dev/stderr + + [log] + log-debug=/dev/stdout + log-file=/dev/stdout + log-emerg=/dev/stderr + level=5 + + [cli] + tcp=127.0.0.1:2001 + + [pppoe] + + [client-ip-range] + 10.0.0.0/8 + + [radius] + """ + + +# load all modules and check that accel-pppd replies to 'show stat' command +def test_load_all_modules(accel_pppd_instance, accel_cmd): + + # test that accel-pppd started successfully + assert accel_pppd_instance + + (exit_sh_stat, out_sh_stat, err_sh_stat) = process.run([accel_cmd, "show stat"]) + + # test that 'show stat' has no errors and contains 'uptime' + assert ( + exit_sh_stat == 0 + and len(out_sh_stat) > 1 + and err_sh_stat == "" + and "uptime" in out_sh_stat + ) |