Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lua2 #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Lua2 #20

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 172 additions & 0 deletions .github/workflows/run-tests-bigendian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Run tests (big-endian)

on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- be

jobs:

Test-in-Alpine-s390x:
#if: ${{ false }} # disable for now
runs-on: ubuntu-24.04
name: Test in Qemu (s390x Alpine)

steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
fetch-depth: 0
path: "accel-ppp"
- name: Install build tools for qemu and required tools
run: >
sudo apt update &&
NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
sudo -E apt -y install wget openssh-client screen
libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev libslirp-dev ninja-build
- name: Build Qemu 9.0.2
# Qemu 8.2 from Ubuntu24.04 has critical s390x-related bugs so Qemu9 is required
run: |
wget -nv https://github.com/qemu/qemu/archive/refs/tags/v9.0.2.tar.gz
tar -xf v9.0.2.tar.gz
cd qemu-9.0.2
./configure --target-list=s390x-softmmu --enable-slirp
make -j
sudo make install
- name: Prepare qemu files
run: |
ssh-keygen -t ed25519 -q -N "" -f ssh-key
qemu-img create -f raw disk.raw 5G
wget -nv https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/s390x/netboot/vmlinuz-lts
wget -nv https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/s390x/netboot/initramfs-lts
- name: Run http server for ssh-key
run: |
sudo ip addr add 192.0.2.1/32 dev lo # stable ip for http server
screen -dmS httpserver python3 -m http.server 8000
- name: Run target OS first time (for setup actions)
run: >
sudo screen -dmS qemu
qemu-system-s390x -M s390-ccw-virtio
-m 4096 -smp 2 -nographic
-net nic -net user,hostfwd=tcp::2222-:22
-drive format=raw,file=disk.raw
-kernel vmlinuz-lts
-initrd initramfs-lts
-append "ip=dhcp alpine_repo=https://dl-cdn.alpinelinux.org/alpine/latest-stable/main
modloop=https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/s390x/netboot/modloop-lts
ssh_key=http://192.0.2.1:8000/ssh-key.pub"
- name: Check that target OS is running
run: |
sleep 1
sudo screen -ls
- name: Wait for ssh connection
timeout-minutes: 30
run: >
while ! ssh -o StrictHostKeyChecking=accept-new -p2222 -o ConnectTimeout=5 -i ssh-key root@localhost "exit 0";
do
echo "Trying to establish ssh connection";
sleep 5;
done;
cat ~/.ssh/known_hosts
- name: Setup alpine to disk
run: >
ssh -i ssh-key -p2222 root@localhost "setup-alpine -c setup_alpine_conf &&
sed -i '/^ROOTSSHKEY\|^DISKOPTS\|^APKREPOSOPTS=/d' setup_alpine_conf &&
echo '' >> setup_alpine_conf &&
echo 'DISKOPTS=\"-m sys /dev/vda\"' >> setup_alpine_conf &&
echo 'ROOTSSHKEY=\"http://192.0.2.1:8000/ssh-key.pub\"' >> setup_alpine_conf &&
echo 'APKREPOSOPTS=\"https://dl-cdn.alpinelinux.org/alpine/latest-stable/main\"' >> setup_alpine_conf &&
cat setup_alpine_conf &&
yes | setup-alpine -e -f setup_alpine_conf"
- name: Poweroff the VM
timeout-minutes: 30
run: >
ssh -i ssh-key -p2222 root@localhost "poweroff" &&
while sudo screen -ls;
do
echo "Waiting for poweroff";
sleep 5;
done;
- name: Run target OS
run: >
sudo screen -dmS qemu
qemu-system-s390x -M s390-ccw-virtio
-m 4096 -smp 2 -nographic
-net nic -net user,hostfwd=tcp::2222-:22
-drive format=raw,file=disk.raw
- name: Check that target OS is running
run: |
sleep 1
sudo screen -ls
- name: Wait for ssh connection
timeout-minutes: 30
run: >
while ! ssh -o StrictHostKeyChecking=accept-new -p2222 -o ConnectTimeout=5 -i ssh-key root@localhost "exit 0";
do
echo "Trying to establish ssh connection";
sleep 5;
done;
cat ~/.ssh/known_hosts
- name: Display free space, current dir, kernel version and users
run: |
ssh -i ssh-key -p2222 root@localhost "df -h"
ssh -i ssh-key -p2222 root@localhost "pwd"
ssh -i ssh-key -p2222 root@localhost "uname -a"
ssh -i ssh-key -p2222 root@localhost "cat /etc/passwd"
- name: Install build tools (on target OS)
run: >
ssh -i ssh-key -p2222 root@localhost "setup-apkrepos -o && apk add --no-cache git cmake make g++ pcre-dev openssl-dev linux-headers libucontext-dev lua5.1-dev linux-lts-dev py3-pip
ppp ppp-pppoe iproute2 dhclient &&
(pip3 install pytest pytest-dependency pytest-order || pip3 install --break-system-packages pytest pytest-dependency pytest-order)"
- name: Copy source code to target OS
run: |
tar -Jcf accel-ppp.tar.xz accel-ppp
scp -i ssh-key -P2222 accel-ppp.tar.xz root@localhost:
ssh -i ssh-key -p2222 root@localhost "tar -xf accel-ppp.tar.xz"
- name: Build accel-ppp
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp && git config --global --add safe.directory '*' &&
mkdir build && cd build &&
cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr
-DKDIR=/usr/src/linux-headers-\`uname -r\`
-DLUA=TRUE -DSHAPER=TRUE -DRADIUS=TRUE .. &&
make && make install"
- name: Run tests (not related to ipoe and vlan_mon drivers)
timeout-minutes: 5
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp/tests &&
python3 -m pytest -Wall --order-dependencies -v -m \"not ipoe_driver and not vlan_mon_driver\""
- name: Display processes and dmesg after tests
if: ${{ always() }}
run: ssh -i ssh-key -p2222 -o ConnectTimeout=5 root@localhost "ps aux | grep accel- && dmesg"
- name: Insert ipoe kernel module
if: ${{ always() }}
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp &&
insmod build/drivers/ipoe/driver/ipoe.ko &&
lsmod | grep ipoe"
- name: Run tests (not related to vlan_mon drivers)
timeout-minutes: 5
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp/tests &&
python3 -m pytest -Wall --order-dependencies -v -m \"not vlan_mon_driver\""
- name: Display processes and dmesg after tests
if: ${{ always() }}
run: ssh -i ssh-key -p2222 -o ConnectTimeout=5 root@localhost "ps aux | grep accel- && dmesg"
- name: Insert vlan_mon kernel module
if: ${{ always() }}
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp &&
insmod build/drivers/vlan_mon/driver/vlan_mon.ko &&
lsmod | grep vlan_mon"
- name: Run tests (all)
timeout-minutes: 5
run: >
ssh -i ssh-key -p2222 root@localhost "cd accel-ppp/tests &&
python3 -m pytest -Wall --order-dependencies -v"
- name: Display processes and dmesg after tests
if: ${{ always() }}
run: ssh -i ssh-key -p2222 -o ConnectTimeout=5 root@localhost "ps aux | grep accel- && dmesg"
20 changes: 19 additions & 1 deletion tests/accel-pppd/ipoe/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from common import dhclient_process
from common import dhclient_process, config
import tempfile, os

# dhclient executable file name
Expand Down Expand Up @@ -44,3 +44,21 @@ def dhclient_instance(accel_pppd_instance, veth_pair_netns, dhclient, dhclient_a

# test teardown:
dhclient_process.end(dhclient_thread, dhclient_control)

# lua script as string (should be redefined by specific test)
@pytest.fixture()
def lua_script():
return ""


# lua script file name
@pytest.fixture()
def lua_script_file(lua_script):
# test setup:
filename = config.make_tmp(lua_script)

# test execution
yield filename

# test teardown:
config.delete_tmp(filename)
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import pytest
from common import process
import time


@pytest.fixture()
def chap_secrets_config(veth_pair_netns):
return veth_pair_netns["veth_a"] + " * pass123 192.0.2.57"


@pytest.fixture()
def accel_pppd_config(veth_pair_netns, chap_secrets_config_file):
print(
"accel_pppd_config veth_pair_netns: "
+ str(veth_pair_netns)
+ "chap_secrets_config_file: "
+ str(chap_secrets_config_file)
)
return (
"""
[modules]
connlimit
chap-secrets
ipoe

[cli]
tcp=127.0.0.1:2001

[core]
log-error=/dev/stderr

[log]
log-debug=/dev/stdout
log-file=/dev/stdout
log-emerg=/dev/stderr
level=5

[ipoe]
username=ifname
password=pass123
verbose=5
start=dhcpv4
shared=1
gw-ip-address=192.0.2.1/24
interface=re:."""
+ veth_pair_netns["veth_a"][1:]
+ """
[chap-secrets]
chap-secrets="""
+ chap_secrets_config_file
)


# 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_chap_secrets(
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.57" in out and "active" in out:
# session is found
print(
"test_ipoe_session_chap_secrets: session found in (sec): "
+ str(sleep_time)
)
is_started = True
break
time.sleep(0.1)
sleep_time += 0.1

print("test_ipoe_shared_session_chap_secrets: last accel-cmd out: " + out)

# test that session is started
assert is_started == True
Loading
Loading