summaryrefslogtreecommitdiff
path: root/tests/accel-pppd/ipoe
diff options
context:
space:
mode:
authorSergey V. Lobanov <sergey@lobanov.in>2022-09-04 18:49:42 +0300
committerSergey V. Lobanov <sergey@lobanov.in>2022-09-04 19:06:49 +0300
commitc92ff6266b18a9655edef231391739f0479dfb3a (patch)
tree0196077cbd54c9607ba918a42cac567411197663 /tests/accel-pppd/ipoe
parent38d96b8e20608fb743d543fe3f08ad4b9d1dcd66 (diff)
downloadaccel-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/ipoe')
-rw-r--r--tests/accel-pppd/ipoe/conftest.py46
-rw-r--r--tests/accel-pppd/ipoe/dhcpv4/test_ipoe_shared_session_wo_auth.py70
-rw-r--r--tests/accel-pppd/ipoe/test_ipoe_driver.py8
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