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

support ubuntu 24 in CI #1486

Merged
merged 34 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1ee855f
support ubuntu24
tigercosmos Jul 6, 2024
f3edb1a
Merge branch 'dev' into ubuntu24
tigercosmos Jul 6, 2024
ed212f4
test
tigercosmos Jul 6, 2024
ed73da0
update
tigercosmos Jul 6, 2024
65dc067
update
tigercosmos Jul 6, 2024
800d192
try
tigercosmos Jul 6, 2024
4600133
test
tigercosmos Jul 7, 2024
8054c90
try
tigercosmos Jul 7, 2024
a7603f0
test
tigercosmos Jul 7, 2024
ab07076
use bash for linux
tigercosmos Jul 7, 2024
2868ccf
test
tigercosmos Jul 7, 2024
ce005bd
test
tigercosmos Jul 7, 2024
7d3d143
try
tigercosmos Jul 7, 2024
4a7f697
try
tigercosmos Jul 7, 2024
4f4147f
replace netifaces by psutil
zhengfeihe Jul 7, 2024
e39de2b
Update ci/run_tests/requirements.txt
tigercosmos Jul 7, 2024
5f80c36
temporarily disable other tests
tigercosmos Jul 7, 2024
8541ce1
test
tigercosmos Jul 7, 2024
2241be8
format code
zhengfeihe Jul 7, 2024
84245b7
Merge branch '1489' into ubuntu24
tigercosmos Jun 23, 2024
6d31da5
test
tigercosmos Jul 7, 2024
a5f2dac
Revert "temporarily disable other tests"
tigercosmos Jun 23, 2024
7b18e8b
try activate venv for pre-commit
tigercosmos Jul 18, 2024
5ea9c4f
Revert "try activate venv for pre-commit"
tigercosmos Jul 19, 2024
9963098
Merge remote-tracking branch 'upstream/dev' into ubuntu24
tigercosmos Aug 16, 2024
bd3ce12
update
tigercosmos Aug 16, 2024
a853f08
python3
tigercosmos Aug 16, 2024
10b4866
Merge branch 'dev' into ubuntu24
tigercosmos Aug 16, 2024
5828da4
try
tigercosmos Aug 16, 2024
04a2216
Merge branch 'ubuntu24' of github.com:tigercosmos/PcapPlusPlus into u…
tigercosmos Aug 16, 2024
167664d
add "Prepare environment for tests" step
tigercosmos Aug 19, 2024
4f3dc32
fix
tigercosmos Aug 19, 2024
2b4ac4e
fix
tigercosmos Aug 19, 2024
f3ed6b2
add a comment
tigercosmos Aug 19, 2024
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
46 changes: 36 additions & 10 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
apk update && apk add cppcheck python3-dev
python3 -m pip install cmake-format clang-format==18.1.6

# TODO: investigate how to run pre-commit with `venv`
Copy link
Collaborator

@egecetin egecetin Aug 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related with this PR directly but, it is possible to use pre-commit.ci but we should remove cppcheck and clang-format from pre-commit since they require pre-installed binaries.

- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
tigercosmos marked this conversation as resolved.
Show resolved Hide resolved

- name: CMake format
Expand All @@ -52,6 +53,9 @@ jobs:
strategy:
matrix:
include:
- image: ubuntu2404
python: python3
clementperon marked this conversation as resolved.
Show resolved Hide resolved
config-zstd: OFF
- image: ubuntu2204
python: python3
config-zstd: OFF
Expand Down Expand Up @@ -80,6 +84,19 @@ jobs:
- name: Checkout code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Set up Python
run: |
if [ "${{ matrix.image }}" = "alpine317" ]; then
apk add python3 py3-virtualenv py3-virtualenv python3-dev gcc musl-dev linux-headers
elif [ "${{ matrix.image }}" = "rhel94" ]; then
yum install -y python3 python3-virtualenv python3-devel
elif [ "${{ matrix.image }}" = "fedora39" ]; then
dnf install -y python3 python3-virtualenv python3-devel
else
apt-get update
apt-get install -y python3 python3-venv python3-dev
fi
clementperon marked this conversation as resolved.
Show resolved Hide resolved

# Checkout is performed out of the container and doesn't match our user
- name: Fix checkout ownership
run: chown -R "$(id -u):$(id -g)" "$GITHUB_WORKSPACE"
Expand All @@ -97,15 +114,19 @@ jobs:
run: cmake --build "$BUILD_DIR" -j

- name: Test PcapPlusPlus
shell: bash
run: |
${{ matrix.python }} -m pip install -U pip
${{ matrix.python }} -m venv ./venv
source ./venv/bin/activate
${{ matrix.python }} -m pip install pip
clementperon marked this conversation as resolved.
Show resolved Hide resolved
${{ matrix.python }} -m pip install -r ci/run_tests/requirements.txt
${{ matrix.python }} ci/run_tests/run_tests.py --interface eth0 ${{ matrix.test-flags }}

- name: Test Examples
shell: bash
clementperon marked this conversation as resolved.
Show resolved Hide resolved
run: |
source ./venv/bin/activate
cd Tests/ExamplesTest
${{ matrix.python }} -m pip install -U pip
${{ matrix.python }} -m pip install -r requirements.txt
${{ matrix.python }} -m pytest --interface eth0 --root-path=../../Dist/examples_bin

Expand All @@ -124,7 +145,9 @@ jobs:
run: cd build_examples/tutorials_bin && ./Tutorial-HelloWorld

- name: Create Cobertura Report
shell: bash
run: |
source ./venv/bin/activate
${{ matrix.python }} -m pip install gcovr
gcovr -v -r . ${{ matrix.additional-gcov-flags }} $GCOVR_FLAGS -o coverage.xml

Expand Down Expand Up @@ -278,15 +301,16 @@ jobs:
# We can't run cross compiled binaries
if: ${{ matrix.arch == 'x86_64' }}
run: |
python -m pip install -U pip
python -m venv ./venv
source ./venv/bin/activate
python -m pip install pip
python -m pip install -r ci/run_tests/requirements.txt
python ci/run_tests/run_tests.py --interface en0

- name: Test Examples
if: ${{ matrix.arch == 'x86_64' }}
run: |
cd Tests/ExamplesTest
python -m pip install -U pip
python -m pip install -r requirements.txt
python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin

Expand Down Expand Up @@ -355,14 +379,15 @@ jobs:

- name: Test PcapPlusPlus
run: |
python -m pip install -U pip
python -m venv ./venv
source ./venv/bin/activate
python -m pip install pip
python -m pip install -r ci/run_tests/requirements.txt
python ci/run_tests/run_tests.py --interface en0

- name: Test Examples
run: |
cd Tests/ExamplesTest
python -m pip install -U pip
python -m pip install -r requirements.txt
python -m pytest --interface en0 --use-sudo --root-path=../../Dist/examples_bin

Expand Down Expand Up @@ -602,7 +627,6 @@ jobs:

echo "Testing PcapPlusPlus examples"
cd Tests/ExamplesTest
python3 -m ensurepip
python3 -m pip install -r requirements.txt
python3 -m pytest --interface "$interface_name" --root-path=../../Dist/examples_bin

Expand Down Expand Up @@ -691,9 +715,11 @@ jobs:

- name: Test PcapPlusPlus
run: |
python -m pip install -U pip
python -m pip install -r ci/run_tests/requirements.txt
python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp"
python -m venv ./venv
source ./venv/bin/activate
python -m pip install pip
python -m pip install -r ci/run_tests/requirements.txt
python ci/run_tests/run_tests.py --interface eth0 --use-sudo --pcap-test-args="-t xdp"

- name: Create Cobertura Report
run: |
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
strategy:
matrix:
include:
- image: ubuntu2404
config-zstd: OFF
- image: ubuntu2204
config-zstd: OFF
- image: ubuntu2204-icpx
Expand Down
2 changes: 1 addition & 1 deletion ci/run_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
netifaces==0.11.0
psutil==6.0.0
16 changes: 14 additions & 2 deletions ci/run_tests/run_tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import os
import subprocess
import argparse
import netifaces as ni
import psutil
import socket

PCAP_FILE_PATH = os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap")


def get_ip_address(interface):
addresses = psutil.net_if_addrs().get(interface)
if not addresses:
return None
for address in addresses:
if address.family == socket.AF_INET:
return address.address
return None


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--interface", type=str, required=True, help="interface to use")
Expand All @@ -32,7 +43,8 @@ def main():
)
args = parser.parse_args()

ip_address = ni.ifaddresses(args.interface)[ni.AF_INET][0]["addr"]
ip_address = get_ip_address(args.interface)

print("IP address is: %s" % ip_address)

try:
Expand Down
19 changes: 16 additions & 3 deletions ci/run_tests/run_tests_windows.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import os
import argparse
import subprocess
import netifaces as ni
import psutil
import socket

TCPREPLAY_PATH = "tcpreplay-4.4.1-win"
PCAP_FILE_PATH = os.path.abspath(
os.path.join("Tests", "Pcap++Test", "PcapExamples", "example.pcap")
)


def get_ip_address(interface):
print(interface)
addresses = psutil.net_if_addrs().get(interface)
print(addresses)
if not addresses:
return None
for address in addresses:
if address.family == socket.AF_INET:
return address.address
return None


def find_interface():
completed_process = subprocess.run(
["tcpreplay.exe", "--listnics"],
Expand All @@ -27,7 +40,7 @@ def find_interface():
interface = columns[1]
try:
ni_interface = interface.lstrip("\\Device\\NPF_")
ip_address = ni.ifaddresses(ni_interface)[ni.AF_INET][0]["addr"]
ip_address = get_ip_address(ni_interface)
if ip_address.startswith("169.254"):
continue
completed_process = subprocess.run(
Expand Down Expand Up @@ -64,7 +77,7 @@ def main():

tcpreplay_interface, ip_address = find_interface()
if not tcpreplay_interface or not ip_address:
print("Cannot find an interface to run tests on!")
print("Cannot find an interface to run tests on! Info from psutil.net_if_addrs() %s"% psutil.net_if_addrs())
exit(1)
print(f"Interface is {tcpreplay_interface} and IP address is {ip_address}")

Expand Down
Loading