Skip to content

Commit 1a6fe18

Browse files
committed
specify dockerfiles and docker-compose files and integrate
1 parent 83cb905 commit 1a6fe18

20 files changed

+214
-43
lines changed

.github/workflows/ci.backup..yaml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Basic Checks
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *' # every day at midnight
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: "3.10"
19+
20+
- name: Checkout repo
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Install dependencies
26+
run: |
27+
pip install -r requirements.txt
28+
29+
- name: Set up loopback interfaces
30+
run: |
31+
sudo ifconfig lo:1 192.168.100.1 up
32+
sudo ifconfig lo:2 192.168.100.2 up
33+
34+
- name: Start Listener
35+
run: |
36+
touch nc_output.txt
37+
(nc -u -l -k 9991 | hexdump -C > nc_output.txt & echo $! > listener_pid.txt) &
38+
echo "$!" > listener_pid.txt
39+
sleep 5s
40+
echo "Listener PID:"
41+
cat listener_pid.txt
42+
echo "Listener Output:"
43+
cat nc_output.txt
44+
45+
- name: Debug IP Configuration
46+
run: |
47+
ip a
48+
49+
- name: Run main.py
50+
run: |
51+
sudo env PATH="$PATH" python main.py -v -t examples/ipfix-traffic.yml
52+
53+
- name: Stop Listener
54+
run: |
55+
pid=$(cat listener_pid.txt)
56+
sudo kill -SIGINT $pid
57+
sleep 5s
58+
echo "Listener Output:"
59+
cat nc_output.txt
60+
61+
- name: Preprocess Hexdump Output
62+
run: |
63+
awk '{print substr($0, 11, 47)}' nc_output.txt | tr -d ' \n' > nc_output_cleaned.txt
64+
echo "Listener Output Cleaned:"
65+
cat nc_output_cleaned.txt
66+
67+
- name: Count Packets
68+
run: |
69+
packet_count=$(grep -o '000a' nc_output_cleaned.txt | wc -l)
70+
echo $packet_count > packet_count.txt
71+
72+
- name: Check Packet Count
73+
run: |
74+
packet_count=$(cat packet_count.txt)
75+
echo "Packet Count: $packet_count"
76+
if [ "$packet_count" -eq 6 ]; then
77+
echo "Success: 6 packets received."
78+
else
79+
echo "Error: Expected 6 packets but found $packet_count."
80+
exit 1
81+
fi

.github/workflows/ci.yaml

+17-2
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,37 @@ jobs:
3838

3939
# 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...)
4040

41-
regression-tests:
41+
example-tests:
4242
runs-on: ubuntu-latest
4343
needs: docker-build
4444
steps:
45+
- name: Checkout traffic-reproducer
46+
uses: actions/checkout@v4
47+
with:
48+
path: traffic-reproducer
49+
submodules: recursive
50+
4551
- name: Download Artifacts
4652
uses: actions/download-artifact@v4
4753
with:
4854
pattern: '*_docker_images'
4955
path: /tmp/docker
5056

5157
- name: Import images in the local registry
58+
shell: bash
5259
run: |
5360
docker load -i /tmp/docker/traffic_reproducer_docker_images/traffic_reproducer_docker_images.tar
5461
echo "List Images"
5562
docker images | grep 'traffic-reproducer'
5663
5764
- name: Run traffic-reproducer container
65+
shell: bash
5866
run: |
59-
docker run --rm --name traffic-reproducer traffic-reproducer:latest
67+
docker network create --subnet=192.168.100.0/24 --subnet=cafe::/64 --ipv6 test_network
68+
cd traffic-reproducer/ci/collectors
69+
docker compose up -d
70+
sleep 10
71+
cd ../reproducers
72+
export ADDITIONAL_IPV4_LIST="192.168.100.1/24 192.168.100.2/24 192.168.100.3/24"
73+
export ADDITIONAL_IPV6_LIST="cafe::1/64 cafe::2/64 cafe::3/64 cafe::4/64 cafe::5/64 cafe::6/64 cafe::7/64"
74+
docker compose up -d

ci/collectors/docker-compose.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
version: '3'
3+
4+
networks:
5+
test_network:
6+
external: true
7+
8+
services:
9+
nfacctd:
10+
image: pmacct/nfacctd:v1.7.9
11+
container_name: nfacctd
12+
volumes:
13+
- ./nfacctd.conf:/etc/pmacct/nfacctd.conf
14+
- ./tmp/logs:/var/log/pmacct
15+
networks:
16+
test_network:
17+
ipv4_address: 192.168.100.100
18+
ipv6_address: cafe::100
19+
20+
nfacctd-bgp:
21+
image: pmacct/nfacctd:v1.7.9
22+
container_name: nfacctd-bgp
23+
volumes:
24+
- ./nfacctd-bgp.conf:/etc/pmacct/nfacctd.conf
25+
- ./tmp/logs:/var/log/pmacct
26+
networks:
27+
test_network:
28+
ipv4_address: 192.168.100.101
29+
ipv6_address: cafe::101
30+
31+
nfacctd-bmp:
32+
image: pmacct/nfacctd:v1.7.9
33+
container_name: nfacctd-bmp
34+
volumes:
35+
- ./nfacctd-bmp.conf:/etc/pmacct/nfacctd.conf
36+
- ./tmp/logs:/var/log/pmacct
37+
networks:
38+
test_network:
39+
ipv4_address: 192.168.100.102
40+
ipv6_address: cafe::102
41+
42+
pmtelemetryd-tcp-json:
43+
image: pmacct/pmtelemetryd:v1.7.9
44+
container_name: pmtelemetryd-tcp-json
45+
volumes:
46+
- ./pmtelemetryd-tcp-json.conf:/etc/pmacct/pmtelemetryd.conf
47+
- ./tmp/logs:/var/log/pmacct
48+
networks:
49+
test_network:
50+
ipv4_address: 192.168.100.200
51+
ipv6_address: cafe::200
52+
53+
pmtelemetryd-udp-notif:
54+
image: pmacct/pmtelemetryd:v1.7.9
55+
container_name: pmtelemetryd-udp-notif
56+
volumes:
57+
- ./pmtelemetryd-udp-notif.conf:/etc/pmacct/pmtelemetryd.conf
58+
- ./tmp/logs:/var/log/pmacct
59+
networks:
60+
test_network:
61+
ipv4_address: 192.168.100.201
62+
ipv6_address: cafe::201

ci/collectors/pmtelemetryd-tcp-json.conf

Whitespace-only changes.

ci/collectors/pmtelemetryd-udp-notif.conf

Whitespace-only changes.

ci/reproducers/docker-compose.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
version: '3'
3+
4+
networks:
5+
test_network:
6+
external: true
7+
8+
services:
9+
traffic-reproducer:
10+
image: traffic-reproducer:latest
11+
container_name: traffic-reproducer
12+
volumes:
13+
- ${PCAP_MOUNT_DIR}:/pcap
14+
- ./add_interfaces.sh:/usr/local/bin/add_interfaces.sh
15+
networks:
16+
pmacct_test_network:
17+
environment:
18+
- IPV4_LIST=${IPV4_LIST}
19+
- IPV6_LIST=${IPV6_LIST}
20+
entrypoint: ["/bin/bash", "-c", "/usr/local/bin/add_interfaces.sh && exec /app/entrypoint.sh"]

docker/Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@ RUN pip install -r requirements.txt
1616
# Set the entry point command
1717
# CMD ["python", "./main.py", "--cfg", "/pcap/traffic-reproducer.conf"]
1818
CMD ["python", "./main.py", "-h"]
19+
20+
# Make script to add multiple IP addresses executable
21+
RUN chmod +x ./docker/add_interfaces.sh
22+
23+
# Set the entry point command
24+
ENTRYPOINT ["./docker/add_interfaces.sh", "python", "./main.py", "-h"]

docker/add_interfaces.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
# Add more IPv4 addresses
4+
for ip in ${IPV4_LIST}; do
5+
ip addr add $ip dev eth0
6+
done
7+
8+
# Add more IPv6 addresses
9+
for ip in ${IPV6_LIST}; do
10+
ip -6 addr add $ip dev eth0
11+
done
12+
13+
ip a
14+
15+
# Execute the original entrypoint
16+
exec "$@"

examples/bgp-traffic.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ bgp:
2424
dport:
2525
- 179
2626
collector: # collector that will receive the reproduced messages
27-
ip: localhost
27+
ip: 191.168.100.101
2828
port: 179

examples/bmp-repeat.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ bmp:
3636
dport:
3737
- 1790
3838
collector: # collector that will receive the reproduced messages
39-
ip: localhost
39+
ip: cafe::102
4040
port: 1791

examples/bmp-traffic.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ bmp:
2424
dport:
2525
- 1790
2626
collector: # collector that will receive the reproduced messages
27-
ip: localhost
28-
port: 1790
27+
ip: 192.168.100.102
28+
port: 1791

examples/collector_examples/docker-compose.yml

-29
This file was deleted.

examples/ipfix-bmp-scenario-segmented.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ bmp:
3333
dport:
3434
- 1790
3535
collector: # collector that will receive the reproduced messages
36-
ip: localhost
36+
ip: cafe::102
3737
port: 1791
3838

3939
ipfix:
@@ -42,5 +42,5 @@ ipfix:
4242
dport:
4343
- 9991
4444
collector:
45-
ip: localhost
45+
ip: cafe::102
4646
port: 9992

examples/ipfix-traffic.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ipfix:
2727
dport:
2828
- 9991
2929
collector: # define the collector that will receive the reproduced messages
30-
ip: localhost
31-
port: 9991
30+
ip: 192.168.100.100
31+
port: 9992

examples/nfv9-traffic.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ ipfix:
2424
dport:
2525
- 9991
2626
collector: # define the collector that will receive the reproduced messages
27-
ip: localhost
28-
port: 9991
27+
ip: 192.168.100.100
28+
port: 9992

examples/tcp-json.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ tcp_generic:
2929
dport:
3030
- 10005
3131
collector:
32-
ip: cafe::100
32+
ip: cafe::200
3333
port: 10005

examples/udp-notif.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ udp_generic:
2929
dport:
3030
- 10003
3131
collector:
32-
ip: 192.168.100.100
32+
ip: 192.168.100.201
3333
port: 10003

0 commit comments

Comments
 (0)