Skip to content

Commit

Permalink
Merge pull request #226 from sbezverk/test_validator
Browse files Browse the repository at this point in the history
ipv4 unicast message validation
  • Loading branch information
sbezverk authored Jul 15, 2023
2 parents 5e2c1b5 + b97186f commit 9d732d2
Show file tree
Hide file tree
Showing 24 changed files with 954 additions and 244 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,29 @@ jobs:
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/go.sum"
- name: Build local container
- name: Build gobmp container
run: make container REGISTRY_NAME=localhost IMAGE_VERSION=cicd
- name: Build validator binary
run: make validator
- name: pulling XRd container
run: docker pull sbezverk/xrd-control-plane:7.9.2
- name: check for gobmp container
run: docker images
- name: starts test bed components
run: docker compose -f ./build/test_bed.yml up --detach
- name: starts unicast v4 integration test
run: docker compose -f ./build/unicastv4-bgp/test_bed.yml up --detach
- name: check conection to kafka and bmp session with a router
id: session
run: ./build/monitor_container.sh gobmp
continue-on-error: true
- name: run validator for ipv4 unicast
id: validation
run: ./bin/validator --validate=true --kafka=127.0.0.1:9092 --msg-file=./testdata/validator/ipv4_unicast.msg
continue-on-error: true
- name: Check on failures
if: steps.session.outcome != 'success' || steps.validation.outcome != 'success'
run: |
docker ps -a
docker logs gobmp
docker logs xr-1
exit 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cmd/bin
.vscode
perf
*.pdf
.DS_Store

# Test binary, built with `go test -c`
*.test
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ else
TESTARGS =
endif

all: gobmp
all: gobmp validator

gobmp:
mkdir -p bin
Expand All @@ -19,18 +19,32 @@ player:
mkdir -p bin
$(MAKE) -C ./cmd/player compile-player

validator:
mkdir -p bin
$(MAKE) -C ./cmd/validator compile-validator

validator-mac:
mkdir -p bin
$(MAKE) -C ./cmd/validator compile-validator-mac

container: gobmp
docker build -t $(REGISTRY_NAME)/gobmp:$(IMAGE_VERSION) -f ./build/Dockerfile.gobmp .

player-container: player
docker build -t $(REGISTRY_NAME)/gobmp-player:$(IMAGE_VERSION) -f ./build/Dockerfile.player .

validator-container: validator
docker build -t $(REGISTRY_NAME)/gobmp-validator:$(IMAGE_VERSION) -f ./build/Dockerfile.validator .

push: container
docker push $(REGISTRY_NAME)/gobmp:$(IMAGE_VERSION)

player-push: player-container
docker push $(REGISTRY_NAME)/gobmp-player:$(IMAGE_VERSION)

validator-push: validator-container
docker push $(REGISTRY_NAME)/gobmp-validator:$(IMAGE_VERSION)

clean:
rm -rf bin

Expand Down
4 changes: 4 additions & 0 deletions build/Dockerfile.validator
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM scratch

COPY ./bin/validator /validator
ENTRYPOINT ["/validator"]
2 changes: 1 addition & 1 deletion build/monitor_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ while [ ${done} == false ]; do
found=true
else
i=$((i+1))
if [[ ${i} -eq 12 ]]; then
if [[ ${i} -eq 24 ]]; then
done=true
else
sleep 10;
Expand Down
42 changes: 0 additions & 42 deletions build/simple-bgp/xrd-1_xrconf.cfg

This file was deleted.

40 changes: 0 additions & 40 deletions build/simple-bgp/xrd-2_xrconf.cfg

This file was deleted.

13 changes: 6 additions & 7 deletions build/test_bed.yml → build/unicastv4-bgp/test_bed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ services:
ports:
- "9092:9092"
- "29092:29092"
- "9999:9999"
environment:
- KAFKA_ENABLE_KRAFT=no
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_ADVERTISED_HOST_NAME=kafka
- KAFKA_CFG_ZOOKEEPER_CONNECT=zoo:2181
- KAFKA_CFG_ZOOKEEPER_CONNECT=10.1.1.5:2181
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,PLAINTEXT_HOST://:29092
- KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092,PLAINTEXT_HOST://127.0.0.1:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://10.1.1.4:9092,PLAINTEXT_HOST://127.0.0.1:9092
- BITNAMI_DEBUG=true
depends_on:
- zoo
Expand All @@ -63,8 +62,8 @@ services:
hostname: gobmp
container_name: gobmp
command:
--v=5
--kafka-server=kafka:9092
--v=9
--kafka-server=10.1.1.4:9092
ports:
- "5000:5000"
cap_add:
Expand Down Expand Up @@ -122,7 +121,7 @@ services:
stdin_open: true
tty: true
volumes:
- source: ./simple-bgp/xrd-1_xrconf.cfg
- source: ./xrd-1_xrconf.cfg
target: /etc/xrd/startup.cfg
type: bind
- xr-1:/xr-storage/
Expand Down Expand Up @@ -170,7 +169,7 @@ services:
stdin_open: true
tty: true
volumes:
- source: ./simple-bgp/xrd-2_xrconf.cfg
- source: ./xrd-2_xrconf.cfg
target: /etc/xrd/startup.cfg
type: bind
- xr-2:/xr-storage/
Expand Down
32 changes: 32 additions & 0 deletions build/unicastv4-bgp/xrd-1_xrconf.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
hostname r1
logging console debugging
username gobmp
username gobmp group root-lr
username gobmp group cisco-support
username gobmp password 7 13021810061C557878
interface Loopback0
interface Loopback0 ipv4 address 1.1.1.1 255.255.255.255
interface MgmtEth0/RP0/CPU0/0 ipv4 address 172.30.0.2 255.255.255.0
interface GigabitEthernet0/0/0/0 ipv4 address 10.1.1.3 255.255.255.0
interface GigabitEthernet0/0/0/1 ipv4 address 10.2.1.2 255.255.255.0
!
route-policy pass-all
pass
end-policy
!
router bgp 100
router bgp 100 bgp router-id 1.1.1.1
router bgp 100 bgp update-delay 0
router bgp 100 address-family ipv4 unicast
router bgp 100 address-family ipv4 unicast redistribute connected
router bgp 100 neighbor 10.2.1.3
router bgp 100 neighbor 10.2.1.3 remote-as 200
router bgp 100 neighbor 10.2.1.3 bmp-activate server 1
router bgp 100 neighbor 10.2.1.3 address-family ipv4 unicast
router bgp 100 neighbor 10.2.1.3 address-family ipv4 unicast route-policy pass-all in
router bgp 100 neighbor 10.2.1.3 address-family ipv4 unicast route-policy pass-all out
bmp server 1
bmp server 1 host 10.1.1.2 port 5000
ssh server v2
ssh server vrf default
end
31 changes: 31 additions & 0 deletions build/unicastv4-bgp/xrd-2_xrconf.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
hostname r2
logging console debugging
username gobmp
username gobmp group root-lr
username gobmp group cisco-support
username gobmp password 7 13021810061C557878
interface Loopback0
interface Loopback0 ipv4 address 2.2.2.2 255.255.255.255
interface MgmtEth0/RP0/CPU0/0 ipv4 address 172.30.0.3 255.255.255.0
interface GigabitEthernet0/0/0/0 ipv4 address 10.2.1.3 255.255.255.0
!
route-policy pass-all
pass
end-policy
!
router bgp 200
router bgp 200 bgp router-id 2.2.2.2
router bgp 200 bgp update-delay 0
router bgp 200 address-family ipv4 unicast
router bgp 200 address-family ipv4 unicast redistribute connected
router bgp 200 neighbor 10.2.1.2
router bgp 200 neighbor 10.2.1.2 remote-as 100
router bgp 200 neighbor 10.2.1.2 bmp-activate server 1
router bgp 200 neighbor 10.2.1.2 address-family ipv4 unicast
router bgp 200 neighbor 10.2.1.2 address-family ipv4 unicast route-policy pass-all in
router bgp 200 neighbor 10.2.1.2 address-family ipv4 unicast route-policy pass-all out
bmp server 1
bmp server 1 host 10.1.1.2 port 5000
ssh server v2
ssh server vrf default
end
5 changes: 5 additions & 0 deletions cmd/validator/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compile-validator:
CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -ldflags '-extldflags "-static"' -o ../../bin/validator ./validator.go

compile-validator-mac:
CGO_ENABLED=0 GOOS=darwin GO111MODULE=on go build -a -ldflags '-extldflags "-static"' -o ../../bin/validator.mac ./validator.go
Loading

0 comments on commit 9d732d2

Please sign in to comment.