Skip to content

Commit

Permalink
Merge branch 'sbezverk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
denizaydin authored May 3, 2024
2 parents 5f2f23d + 72822d6 commit 74e899d
Show file tree
Hide file tree
Showing 47 changed files with 1,808 additions and 195 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: cicd
on:
push:
branches:
- main
pull_request:
jobs:
tests:
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/go.sum"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Require: The version of golangci-lint to use.
version: v1.53
- name: Run go tests
run: |
go test ./...
go test -race ./...
- name: Build binary
run: make build

integration_tests:
needs: [tests]
strategy:
matrix:
os: [ubuntu-latest]
go-version: [1.20.x]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: setup host kernel parameters
run: ./build/set_kernel_params.sh
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
cache-dependency-path: "**/go.sum"
- 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 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
2 changes: 1 addition & 1 deletion .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 All @@ -17,4 +18,3 @@ perf
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

70 changes: 38 additions & 32 deletions BMP.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,24 +283,27 @@ Future:
25: (nei_ip): 10.1.1.2
26: (igp_metric): 1
27: (admin_group): 0
28: (max_link_bw): 1000000
28: (max_link_bw): 0
29: (max_resv_bw): 0
30: (unresv_bw): 0, 0, 0, 0, 0, 0, 0, 0
31: (te_default_metric): 1
32: (link_protection):
33: (mpls_proto_mask):
34: (srlg):
35: (link_name):
36: (remote_node_hash): 6ed5aeb7f5ca0bbea84bdbadb61996e9
37: (local_node_hash): c2679dc1c0d5615c23b3ec45f59f6b15
38: (remote_igp_router_id): 0000.0000.0000.0000
39: (remote_router_id): 10.0.0.0
40: (local_node_asn): 100000
41: (remote_node_asn): 100000
42: (peer_node_sid):
43: (is_prepolicy): 1
44: (is_adj_rib_in): 1
45: (ls_adjacency_sid): BVL 0 24004, VL 0 24005
30: (unresv_bw):
31: (max_link_bw_kbps): 1000000
32: (max_resv_bw_kbps): 0
33: (unresv_bw_kbps): 0, 0, 0, 0, 0, 0, 0, 0
34: (te_default_metric): 1
35: (link_protection):
36: (mpls_proto_mask):
37: (srlg):
38: (link_name):
39: (remote_node_hash): 6ed5aeb7f5ca0bbea84bdbadb61996e9
40: (local_node_hash): c2679dc1c0d5615c23b3ec45f59f6b15
41: (remote_igp_router_id): 0000.0000.0000.0000
42: (remote_router_id): 10.0.0.0
43: (local_node_asn): 100000
44: (remote_node_asn): 100000
45: (peer_node_sid):
46: (is_prepolicy): 1
47: (is_adj_rib_in): 1
48: (ls_adjacency_sid): BVL 0 24004, VL 0 24005
Additional segment routing not accounted for by OpenBMP:
Expand Down Expand Up @@ -363,21 +366,24 @@ Bonus item (OpenBMP never carried remote node router ID field, which would be ve
28: (max_link_bw): 0
29: (max_resv_bw): 0
30: (unresv_bw):
31: (te_default_metric): 0
32: (link_protection):
33: (mpls_proto_mask):
34: (srlg):
35: (link_name):
36: (remote_node_hash): 9b20947913e9b23f4d5ccf4174e9eba4
37: (local_node_hash): 6ed5aeb7f5ca0bbea84bdbadb61996e9
38: (remote_igp_router_id): 0000.0000.0001.0000
39: (remote_router_id): ::
40: (local_node_asn): 100000
41: (remote_node_asn): 100000
42: (peer_node_sid):
43: (is_prepolicy): 1
44: (is_adj_rib_in): 1
45: (ls_adjacency_sid):
31: (max_link_bw_kbps): 0
32: (max_resv_bw_kbps): 0
33: (unresv_bw_kbps):
34: (te_default_metric): 0
35: (link_protection):
36: (mpls_proto_mask):
37: (srlg):
38: (link_name):
39: (remote_node_hash): 9b20947913e9b23f4d5ccf4174e9eba4
40: (local_node_hash): 6ed5aeb7f5ca0bbea84bdbadb61996e9
41: (remote_igp_router_id): 0000.0000.0001.0000
42: (remote_router_id): ::
43: (local_node_asn): 100000
44: (remote_node_asn): 100000
45: (peer_node_sid):
46: (is_prepolicy): 1
47: (is_adj_rib_in): 1
48: (ls_adjacency_sid):
```
#### BMP ls_prefix message:
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

Message updates and major project changes should be documented here.

## [Unreleased]

### 2023-04-13

#### Changed

- SR value "prefix_sid" was previous configured with "omitempty" json tag option, this option is now removed. A valid
SID index of 0 is now explicit in the json output.

### 2023-03-20

#### Fixed

- unresv\_bw\_kbps data structure was appending a slice, leaving initial 0 values and growing beyond the expected length.
Updated function to index the slice to overwrite initial values and keep the expected length.
[\#215](https://github.com/sbezverk/gobmp/issues/215)

### 2023-02-23

#### Added

- ls\_link attribute max\_link\_bw\_kbps BGP-LS TLV Type 1089 stored as an uint64 integer in kbps
[\#213](https://github.com/sbezverk/gobmp/issues/213)
- ls\_link attribute max\_resv\_bw\_kbps BGP-LS TLV Type 1090 stored as uint64 integer in kbps
[\#213](https://github.com/sbezverk/gobmp/issues/213)
- ls\_link attribute unresv\_bw\_kbps BGP-LS TLV Type 1091 stored as a slice of 8 uint64 integers in kbps
[\#213](https://github.com/sbezverk/gobmp/issues/213)

#### Deprecated

- ls\_link attribute max\_link\_bw BGP-LS TLV Type 1089 statically set to 0
[\#213](https://github.com/sbezverk/gobmp/issues/213)
- ls\_link attribute max\_resv\_bw BGP-LS TLV Type 1090 statically set to 0
[\#213](https://github.com/sbezverk/gobmp/issues/213)
- ls\_link attribute unresv\_bw BGP-LS TLV Type 1091 statically set to nil
[\#213](https://github.com/sbezverk/gobmp/issues/213)
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
REGISTRY_NAME?=docker.io/sbezverk
IMAGE_VERSION?=0.0.0

.PHONY: all gobmp player container push clean test
.PHONY: all gobmp player container push clean test lint

ifdef V
TESTARGS = -v -args -alsologtostderr -v 5
else
TESTARGS =
endif

all: gobmp
all: gobmp validator

gobmp:
mkdir -p bin
Expand All @@ -19,21 +19,39 @@ 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

lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run

test:
GO111MODULE=on go test `go list ./... | grep -v 'vendor'` $(TESTARGS)
GO111MODULE=on go vet `go list ./... | grep -v vendor`
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ For the complete list of supported extensions and drafts follow this link: [Supp



The structure of the each record which is published to kafka, stored in the message file or printed to standard output, is defined in the package **_message_** [file types.go](https://github.com/sbezverk/gobmp/blob/master/pkg/message/types.go)
The structure of the each record which is published to kafka, nats, stored in the message file or printed to standard output, is defined in the package **_message_** [file types.go](https://github.com/sbezverk/gobmp/blob/master/pkg/message/types.go)

## Building goBMP

Expand Down Expand Up @@ -240,3 +240,4 @@ gobmp: 06:36:26.088307 {MsgType:7 MsgHash: Msg:{"action":"add","base_attrs":{"ba
## Status

**goBMP** is work in progress, even though a considerable number of AFI/SAFI and BGP-LS attributes are processed, there is still a lot of work for contribution.
See [CHANGELOG.md](https://github.com/sbezverk/gobmp/blob/master/CHANGELOG.md) for latest updates to this project.
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"]
70 changes: 70 additions & 0 deletions build/monitor_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/bash

cn=$1
cid=$(docker ps | grep ${cn} | awk '{ print $1 }')

if [[ ${cid} == "" ]]; then
echo "no container ${cn} detected"
exit 1
fi

echo "Container id: ${cid}"

done=false
found=false
i=0

while [ ${done} == false ]; do

msg=$(docker logs ${cid} | grep "Kafka publisher has been successfully initialized")
if [[ ${msg} != "" ]]; then
done=true
found=true
else
i=$((i+1))
if [[ ${i} -eq 12 ]]; then
done=true
else
sleep 10;
fi
fi
done

if [[ ${found} == true ]]; then
echo "successfully connected to kafka"
else
echo "container ${cn} failed to connect to kafka, check container logs..."
docker logs ${cid}
exit 1
fi

done=false
found=false
i=0

while [ ${done} == false ]; do

msg=$(docker logs ${cid} | grep "client 10.1.1.3")
if [[ ${msg} != "" ]]; then
done=true
found=true
else
i=$((i+1))
if [[ ${i} -eq 24 ]]; then
done=true
else
sleep 10;
fi
fi
done

if [[ ${found} == true ]]; then
echo "bmp session with 10.1.1.3 came up"
else
echo "container ${cn} failed to establish bmp session with 10.1.1.3, check gobmp and xr-1 containers' logs..."
docker logs ${cid}
docker logs $(docker ps | grep xr-1 | awk '{ print $1 }')
exit 1
fi

exit 0
Loading

0 comments on commit 74e899d

Please sign in to comment.