Skip to content

Commit

Permalink
specify dockerfiles and docker-compose files and integrate
Browse files Browse the repository at this point in the history
  • Loading branch information
rodonile committed Nov 13, 2024
1 parent 83cb905 commit 03349c4
Show file tree
Hide file tree
Showing 20 changed files with 220 additions and 43 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/ci.backup..yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Basic Checks

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *' # every day at midnight
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"

- name: Checkout repo
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Set up loopback interfaces
run: |
sudo ifconfig lo:1 192.168.100.1 up
sudo ifconfig lo:2 192.168.100.2 up
- name: Start Listener
run: |
touch nc_output.txt
(nc -u -l -k 9991 | hexdump -C > nc_output.txt & echo $! > listener_pid.txt) &
echo "$!" > listener_pid.txt
sleep 5s
echo "Listener PID:"
cat listener_pid.txt
echo "Listener Output:"
cat nc_output.txt
- name: Debug IP Configuration
run: |
ip a
- name: Run main.py
run: |
sudo env PATH="$PATH" python main.py -v -t examples/ipfix-traffic.yml
- name: Stop Listener
run: |
pid=$(cat listener_pid.txt)
sudo kill -SIGINT $pid
sleep 5s
echo "Listener Output:"
cat nc_output.txt
- name: Preprocess Hexdump Output
run: |
awk '{print substr($0, 11, 47)}' nc_output.txt | tr -d ' \n' > nc_output_cleaned.txt
echo "Listener Output Cleaned:"
cat nc_output_cleaned.txt
- name: Count Packets
run: |
packet_count=$(grep -o '000a' nc_output_cleaned.txt | wc -l)
echo $packet_count > packet_count.txt
- name: Check Packet Count
run: |
packet_count=$(cat packet_count.txt)
echo "Packet Count: $packet_count"
if [ "$packet_count" -eq 6 ]; then
echo "Success: 6 packets received."
else
echo "Error: Expected 6 packets but found $packet_count."
exit 1
fi
21 changes: 19 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,39 @@ jobs:

# TODO idea: send all messages from all examples and then do some basic check on collector logs / print files (no warnings, no error, line counts, etc...)

regression-tests:
example-tests:
runs-on: ubuntu-latest
needs: docker-build
steps:
- name: Checkout traffic-reproducer
uses: actions/checkout@v4
with:
path: traffic-reproducer
submodules: recursive

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
pattern: '*_docker_images'
path: /tmp/docker

- name: Import images in the local registry
shell: bash
run: |
docker load -i /tmp/docker/traffic_reproducer_docker_images/traffic_reproducer_docker_images.tar
echo "List Images"
docker images | grep 'traffic-reproducer'
- name: Run traffic-reproducer container
shell: bash
run: |
docker run --rm --name traffic-reproducer traffic-reproducer:latest
docker network create --subnet=192.168.100.0/24 --subnet=cafe::/64 --ipv6 test_network
cd traffic-reproducer/ci/collectors
docker compose up -d
sleep 10
cd ../reproducers
export ADDITIONAL_IPV4_LIST="192.168.100.2/24 192.168.100.3/24"
export ADDITIONAL_IPV6_LIST="cafe::2/64 cafe::3/64 cafe::4/64 cafe::5/64 cafe::6/64 cafe::7/64"
docker compose up
cd ../collectors
cat tmp/logs/*.log
62 changes: 62 additions & 0 deletions ci/collectors/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
version: '3'

networks:
test_network:
external: true

services:
nfacctd:
image: pmacct/nfacctd:v1.7.9
container_name: nfacctd
volumes:
- ./nfacctd.conf:/etc/pmacct/nfacctd.conf
- ./tmp/logs:/var/log/pmacct
networks:
test_network:
ipv4_address: 192.168.100.100
ipv6_address: cafe::100

nfacctd-bgp:
image: pmacct/nfacctd:v1.7.9
container_name: nfacctd-bgp
volumes:
- ./nfacctd-bgp.conf:/etc/pmacct/nfacctd.conf
- ./tmp/logs:/var/log/pmacct
networks:
test_network:
ipv4_address: 192.168.100.101
ipv6_address: cafe::101

nfacctd-bmp:
image: pmacct/nfacctd:v1.7.9
container_name: nfacctd-bmp
volumes:
- ./nfacctd-bmp.conf:/etc/pmacct/nfacctd.conf
- ./tmp/logs:/var/log/pmacct
networks:
test_network:
ipv4_address: 192.168.100.102
ipv6_address: cafe::102

pmtelemetryd-tcp-json:
image: pmacct/pmtelemetryd:v1.7.9
container_name: pmtelemetryd-tcp-json
volumes:
- ./pmtelemetryd-tcp-json.conf:/etc/pmacct/pmtelemetryd.conf
- ./tmp/logs:/var/log/pmacct
networks:
test_network:
ipv4_address: 192.168.100.200
ipv6_address: cafe::200

pmtelemetryd-udp-notif:
image: pmacct/pmtelemetryd:v1.7.9
container_name: pmtelemetryd-udp-notif
volumes:
- ./pmtelemetryd-udp-notif.conf:/etc/pmacct/pmtelemetryd.conf
- ./tmp/logs:/var/log/pmacct
networks:
test_network:
ipv4_address: 192.168.100.201
ipv6_address: cafe::201
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions ci/reproducers/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
version: '3'

networks:
test_network:
external: true

services:
traffic-reproducer:
image: traffic-reproducer:latest
container_name: traffic-reproducer
volumes:
- ./examples:/pcap/traffic-reproducer.conf
networks:
test_network:
ipv4_address: 192.168.100.1
ipv6_address: cafe::1
environment:
- ADDITIONAL_IPV4_LIST=${ADDITIONAL_IPV4_LIST}
- ADDITIONAL_IPV6_LIST=${ADDITIONAL_IPV6_LIST}

# TODO: add additional ip6 as list directly here...
6 changes: 6 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ RUN pip install -r requirements.txt
# Set the entry point command
# CMD ["python", "./main.py", "--cfg", "/pcap/traffic-reproducer.conf"]
CMD ["python", "./main.py", "-h"]

# Make script to add multiple IP addresses executable
RUN chmod +x ./docker/add_interfaces.sh

# Set the entry point command
ENTRYPOINT ["./docker/add_interfaces.sh", "python", "./main.py", "-h"]
18 changes: 18 additions & 0 deletions docker/add_interfaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

ip a

# Add more IPv4 addresses
for ip in ${ADDITIONAL_IPV4_LIST}; do
ip addr add $ip dev eth0
done

# Add more IPv6 addresses
for ip in ${ADDITIONAL_IPV6_LIST}; do
ip -6 addr add $ip dev eth0
done

ip a

# Execute the original entrypoint
exec "$@"
2 changes: 1 addition & 1 deletion examples/bgp-traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ bgp:
dport:
- 179
collector: # collector that will receive the reproduced messages
ip: localhost
ip: 191.168.100.101
port: 179
2 changes: 1 addition & 1 deletion examples/bmp-repeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ bmp:
dport:
- 1790
collector: # collector that will receive the reproduced messages
ip: localhost
ip: cafe::102
port: 1791
4 changes: 2 additions & 2 deletions examples/bmp-traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ bmp:
dport:
- 1790
collector: # collector that will receive the reproduced messages
ip: localhost
port: 1790
ip: 192.168.100.102
port: 1791
29 changes: 0 additions & 29 deletions examples/collector_examples/docker-compose.yml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/ipfix-bmp-scenario-segmented.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bmp:
dport:
- 1790
collector: # collector that will receive the reproduced messages
ip: localhost
ip: cafe::102
port: 1791

ipfix:
Expand All @@ -42,5 +42,5 @@ ipfix:
dport:
- 9991
collector:
ip: localhost
ip: cafe::102
port: 9992
4 changes: 2 additions & 2 deletions examples/ipfix-traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ ipfix:
dport:
- 9991
collector: # define the collector that will receive the reproduced messages
ip: localhost
port: 9991
ip: 192.168.100.100
port: 9992
4 changes: 2 additions & 2 deletions examples/nfv9-traffic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ ipfix:
dport:
- 9991
collector: # define the collector that will receive the reproduced messages
ip: localhost
port: 9991
ip: 192.168.100.100
port: 9992
2 changes: 1 addition & 1 deletion examples/tcp-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ tcp_generic:
dport:
- 10005
collector:
ip: cafe::100
ip: cafe::200
port: 10005
2 changes: 1 addition & 1 deletion examples/udp-notif.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ udp_generic:
dport:
- 10003
collector:
ip: 192.168.100.100
ip: 192.168.100.201
port: 10003

0 comments on commit 03349c4

Please sign in to comment.