diff options
Diffstat (limited to 'tests/accel-pppd/ipoe')
-rw-r--r-- | tests/accel-pppd/ipoe/conftest.py | 46 | ||||
-rw-r--r-- | tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py | 70 | ||||
-rw-r--r-- | tests/accel-pppd/ipoe/test_ipoe_driver.py | 8 |
3 files changed, 124 insertions, 0 deletions
diff --git a/tests/accel-pppd/ipoe/conftest.py b/tests/accel-pppd/ipoe/conftest.py new file mode 100644 index 00000000..3db8dd60 --- /dev/null +++ b/tests/accel-pppd/ipoe/conftest.py @@ -0,0 +1,46 @@ +import pytest +from common import dhclient_process +import tempfile, os + +# dhclient executable file name +@pytest.fixture() +def dhclient(pytestconfig): + return pytestconfig.getoption("dhclient") + + +# pppd configuration as command line args (might be redefined by specific test) +# "-d" (do not daemonize) must be a part of the args +@pytest.fixture() +def dhclient_args(): + # test setup: + #lease_file = tempfile.NamedTemporaryFile(delete=True) + #lease_file_name = lease_file.name + #lease_file.close() # just create, close and delete + + # test execution: + yield ["-d", "-4", "--no-pid", "-lf", "/dev/null"] + + # test teardown: + #os.unlink(lease_file_name) + + +# setup and teardown for tests that required running dhclient (after accel-pppd) +@pytest.fixture() +def dhclient_instance(accel_pppd_instance, veth_pair_netns, dhclient, dhclient_args): + # test setup: + print("dhclient_instance: accel_pppd_instance = " + str(accel_pppd_instance)) + is_started, dhclient_thread, dhclient_control = dhclient_process.start( + veth_pair_netns["netns"], + dhclient, + dhclient_args, + ) + + # test execution: + yield { + "is_started": is_started, + "dhclient_thread": dhclient_thread, + "dhclient_control": dhclient_control, + } + + # test teardown: + dhclient_process.end(dhclient_thread, dhclient_control) diff --git a/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py b/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py new file mode 100644 index 00000000..104e4e9b --- /dev/null +++ b/tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py @@ -0,0 +1,70 @@ +import pytest +from common import process +import time + + +@pytest.fixture() +def accel_pppd_config(veth_pair_netns): + print("accel_pppd_config veth_pair_netns: " + str(veth_pair_netns)) + return ( + """ + [modules] + pppoe + ipoe + ippool + + [ip-pool] + gw-ip-address=192.0.2.1 + 192.0.2.2-255 + + [cli] + tcp=127.0.0.1:2001 + + [log] + log-debug=/dev/stdout + level=5 + + [ipoe] + noauth=1 + shared=1 + gw-ip-address=192.0.2.1/24 + interface=""" + + veth_pair_netns["veth_a"] + ) + + +# test dhcpv4 shared session without auth check +@pytest.mark.dependency(depends=["ipoe_driver_loaded"], scope = 'session') +@pytest.mark.ipoe_driver +def test_ipoe_shared_session_wo_auth(dhclient_instance, accel_cmd, veth_pair_netns): + + # test that dhclient (with accel-pppd) started successfully + assert dhclient_instance["is_started"] + + # wait until session is started + max_wait_time = 10.0 + sleep_time = 0.0 + is_started = False # is session started + while sleep_time < max_wait_time: + (exit, out, err) = process.run( + [ + accel_cmd, + "show sessions called-sid,ip,state", + ] + ) + assert exit == 0 # accel-cmd fails + # print(out) + if veth_pair_netns["veth_a"] in out and "192.0.2." in out and "active" in out: + # session is found + print( + "test_pppoe_session_wo_auth: session found in (sec): " + str(sleep_time) + ) + is_started = True + break + time.sleep(0.1) + sleep_time += 0.1 + + print("test_ipoe_shared_session_wo_auth: last accel-cmd out: " + out) + + # test that session is started + assert is_started == True diff --git a/tests/accel-pppd/ipoe/test_ipoe_driver.py b/tests/accel-pppd/ipoe/test_ipoe_driver.py new file mode 100644 index 00000000..d21e9ba7 --- /dev/null +++ b/tests/accel-pppd/ipoe/test_ipoe_driver.py @@ -0,0 +1,8 @@ +import pytest +import os + +# test that ipoe kernel module is loaded +@pytest.mark.dependency(name = 'ipoe_driver_loaded', scope = 'session') +@pytest.mark.ipoe_driver +def test_ipoe_kernel_module_loaded(): + assert os.path.isdir("/sys/module/ipoe")
\ No newline at end of file |