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

next #243

Open
wants to merge 102 commits into
base: main
Choose a base branch
from
Open

next #243

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
57768db
feat: remove optimizer from main repo
natesales Jul 23, 2023
14d5287
docs: bump deps
natesales Jul 23, 2023
2f50725
chore: remove optimizer page
natesales Jul 23, 2023
8c29f05
chore: remove old docs page
natesales Jul 23, 2023
c2425b2
hack: disable optimizer testes pending v7 release
natesales Jul 23, 2023
5e4e0aa
feat: add kstatics
natesales Jul 23, 2023
f0635d1
chore: add snapshot build
natesales Jul 23, 2023
c12ca2a
fix: prefix length
natesales Jul 23, 2023
b7de78d
refactor: remove IRR source filter arg from bgpq4 (#192)
natesales Jul 29, 2023
f4dfb0a
refactor: include user specified protocol name in config.Peer
natesales Jul 29, 2023
2683502
feat: util.IsPrivateASN method
natesales Jul 29, 2023
d1308e0
refactor: make util.Contains accept a generic comparable type
natesales Jul 29, 2023
0d76201
fix: use bird output directory from config in status command
natesales Jan 17, 2024
cb45add
feat: log nexthop on reject
natesales Jan 17, 2024
c75eb57
Merge branch 'main' into v7
natesales Jan 17, 2024
40ee58a
refactor: rename kernel protocols to include address family suffix
natesales Jan 17, 2024
33ae776
feat: add configurable bgpq binary
natesales Jan 17, 2024
673eb40
fix: bgpq binary
natesales Jan 17, 2024
9adfdbb
fix: kernel protocol naming
natesales Jan 17, 2024
6dca566
feat: reload command
natesales Jan 17, 2024
e75fe59
fix: unset protocol naming bool outside status command
natesales Jan 17, 2024
a88bc83
feat: reload and restart commands
natesales Jan 17, 2024
8dd581e
refactor: bird formatter edge cases
natesales Jan 17, 2024
c4aa3f4
feat: reformat global bird file
natesales Jan 18, 2024
7287a5a
feat: bird-fmt command
natesales Jan 18, 2024
9e16aa5
refactor: cleaner timestamp format
natesales Jan 18, 2024
9f58202
feat: fuzzy search status command
natesales Jan 18, 2024
e035e2e
feat: start docker test env
natesales Jan 18, 2024
ce084ae
refactor: cleanup log newlines
natesales Jul 9, 2024
0534633
chore: bump deps
natesales Jul 9, 2024
1a8a68c
feat: add internal logger
natesales Jul 9, 2024
2256505
style: reformat global template
natesales Jul 9, 2024
c06db5f
docs: add note to check
natesales Jul 9, 2024
4cb1480
Revert "chore: remove optimizer page"
natesales Jul 9, 2024
02023ba
Revert "feat: remove optimizer from main repo"
natesales Jul 9, 2024
87d56b6
Merge remote-tracking branch 'origin/main' into next
natesales Jul 9, 2024
3a80686
chore: go mod tidy
natesales Jul 9, 2024
c223164
refactor: reformat
natesales Jul 9, 2024
5dae4b8
refactor: pass errors through
natesales Jul 9, 2024
ce8282e
refactor: use go1.21 slices package
natesales Jul 9, 2024
29a5deb
chore: reformat
natesales Jul 9, 2024
b8a55fb
fix: prefix set parser
natesales Jul 9, 2024
1d26a37
chore: go generate
natesales Jul 9, 2024
c59fc3d
refactor: extract withGenerateConfigs and mkTempCache
natesales Aug 9, 2024
1a70d49
test(suite): add bravo pathvector config file
natesales Aug 9, 2024
b2df829
chore: go mod tidy
natesales Sep 2, 2024
73ee819
docs: add matrix test docs
natesales Sep 2, 2024
0d7d3d3
refactor: extract lockfile check to function
natesales Sep 2, 2024
63557f7
refactor: cleanup tests
natesales Sep 2, 2024
fbe69b6
refactor: cleanup conditionals
natesales Sep 2, 2024
31fa079
fix: handle nil pointer
natesales Sep 2, 2024
b1bb55e
test: fix process test error handling
natesales Sep 2, 2024
3d0866b
docs: fix duplicate keys
natesales Sep 2, 2024
3e1b390
ci: add pre-commit
natesales Sep 2, 2024
267e2e8
test: install golangci-lint
natesales Sep 2, 2024
996f5c2
Merge remote-tracking branch 'origin/main' into next
natesales Sep 2, 2024
8f1d7c0
ci: install deps
natesales Sep 2, 2024
a963f3d
refactor: cleanup
natesales Sep 2, 2024
39f448c
fix: template container
natesales Sep 2, 2024
7d93b91
test: fix changing as-set
natesales Sep 4, 2024
7fb570d
refactor: use internal logger
natesales Sep 4, 2024
1eda163
refactor(log): capture commands
natesales Sep 4, 2024
335c2d2
test(cmd): capture stdout
natesales Sep 4, 2024
37e49c3
test(match): capture stdout
natesales Sep 4, 2024
825acca
chore: go mod tidy
natesales Sep 4, 2024
f130b9a
fix(templating): data race in array append
natesales Sep 4, 2024
a859e27
refactor: move test-cache to /tmp
natesales Oct 13, 2024
6fa0726
feat: validate BIRD config in docker
natesales Oct 13, 2024
71c38df
fix: store protocols.json in cache
natesales Oct 13, 2024
f4d7f22
ci: remove user flag
natesales Oct 13, 2024
fa17578
ci: install pre commit
natesales Oct 13, 2024
5308cf1
ci: install flask through apt
natesales Oct 13, 2024
1e03763
ci: prevent double run
natesales Oct 13, 2024
0fa6a63
chore: cleanup tests
natesales Jan 15, 2025
830443f
docs: add test info
natesales Jan 15, 2025
187d340
feat: containerize peeringdb test API
natesales Jan 15, 2025
b465692
chore: extract separate tests
natesales Jan 15, 2025
e1ffbad
fix: bird entrypoint
natesales Jan 15, 2025
a8944d4
fix(ci): track go version from go.mod
natesales Jan 15, 2025
42a612b
feat: add clean recipe
natesales Jan 15, 2025
b668e17
feat: completely cleanup test setup
natesales Jan 15, 2025
4071103
Merge remote-tracking branch 'origin/main' into next
natesales Jan 15, 2025
046f931
ci: test on every push
natesales Jan 15, 2025
f1b7b68
Merge branch 'main' into next
natesales Jan 15, 2025
3511db9
chore: remove extra test files
natesales Jan 15, 2025
866ae8e
fix: remove bird host files
natesales Jan 15, 2025
b8442a2
chore: bump versions and run concurrency
natesales Jan 15, 2025
51cda04
fix: validate in docker in test mode
natesales Jan 15, 2025
33cca29
fix: change to warn
natesales Jan 15, 2025
eb2e9f1
refactor(bird): extract runtime config function
natesales Jan 15, 2025
c65c645
fix(optimizer): don't attempt to move cache again
natesales Jan 15, 2025
cff2daa
fix: flush caches before optimizer start
natesales Jan 15, 2025
fb10764
fix(bird): validate on cache directory
natesales Jan 15, 2025
d05ba73
refactor(ci): split test and lint
natesales Jan 15, 2025
7cc4ff2
fix: different cache dir for move test
natesales Jan 15, 2025
1ac411d
refactor: separate optimizer flags
natesales Jan 15, 2025
562d3ce
hack: skip broken optimizer test
natesales Jan 15, 2025
02496df
test: no capture
natesales Jan 15, 2025
f8adf20
fix: log capturer
natesales Jan 15, 2025
40ffbf5
fix(ci): job concurrency
natesales Jan 15, 2025
e960cbe
fix: remove cache dir before creation
natesales Jan 15, 2025
d9381e2
fix: delete cache before create
natesales Jan 15, 2025
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
7 changes: 4 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ jobs:
deploy-docs:
name: Deploy docs
runs-on: ubuntu-latest
concurrency: ci-${{ github.ref }}
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: actions/setup-node@v2
with:
node-version: '16'

- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version-file: go.mod

- name: Generate docs
run: go generate -x
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint

on:
push:

jobs:
lint:
name: lint
runs-on: ubuntu-latest
concurrency: ci-lint-${{ github.ref }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Install pre-commit deps
run: |
sudo apt install -y pre-commit
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install -v github.com/go-critic/go-critic/cmd/gocritic@latest

- name: Hash key for Cache pre-commit
uses: seepine/hash-files@v1
id: key-hash
with:
patterns: ".pre-commit-config.yaml"

- name: Cache pre-commit
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: pre-commit-${{ steps.key-hash.outputs.hash }}

- run: pre-commit run --all-files
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version-file: go.mod

- name: Install PDF generation dependencies
run: |
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -26,10 +26,9 @@ jobs:
body: |
Starting snapshot release [`${{ steps.snapshot_id.outputs.SNAPSHOT_ID }}`](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

- name: Set up Go
uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: 1.18
go-version-file: go.mod

- name: Install PDF generation dependencies
run: |
Expand Down
23 changes: 5 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,24 @@ name: Test

on:
push:
pull_request:

jobs:
test:
name: test
runs-on: ubuntu-latest
concurrency: ci-test-${{ github.ref }}
steps:
- name: Install bgpq4 and bird2
- name: Install bgpq4
run: |
wget http://ftp.us.debian.org/debian/pool/main/b/bgpq4/bgpq4_0.0.6-2_amd64.deb
sudo dpkg -i bgpq4*.deb
sudo apt install -y bird2

- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
- uses: actions/setup-go@v5
with:
args: -E gosec
go-version-file: go.mod

- run: go get -v -t -d ./...
- run: sudo chown $(whoami):$(whoami) /run/bird/bird.ctl
- run: sudo chown -R $(whoami):$(whoami) /etc/bird/
- run: go generate -x
- run: go build -v .
- run: make dep
- run: make test-setup
- run: make test

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ vendorbuild/cisco/ioxclient
vendorbuild/mikrotik/docker-buildx

# Testing
test-cache/
test-conf.yml
nohup.out
coverage.txt
Expand Down
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
exclude: '^\.idea/'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace

# TODO: upstream
- repo: https://github.com/natesales/goimports-reviser
rev: a807b1af1da00a44880668d880ef7d4ce51feb42
hooks:
- id: goimports-reviser

# - repo: https://github.com/igorshubovych/markdownlint-cli
# rev: v0.35.0
# hooks:
# - id: markdownlint
# # MD013: line too long
# # MD033: no inline HTML
# # MD041: first line in a file should be a top-level heading
# args: [ --disable, MD013, MD033, MD041, "--" ]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [
--skip, "go.*",
-L, "statics,socio-economic"
]
stages: [ commit, commit-msg ]
exclude_types: [ json ]

- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: go-vet
- id: go-imports
- id: go-cyclo
args: [ -over=25 ]
- id: golangci-lint
- id: go-critic
- id: go-build
- id: go-mod-tidy
43 changes: 32 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dep:
pip3 install flask
down:
docker rm -f pathvector-peeringdb-test-api || true
docker rm -f pathvector-bird || true
sudo ip link del dev dummy0 || true

dummy-iface:
# Allow UDP ping. For more information, see https://github.com/go-ping/ping#linux
Expand All @@ -9,17 +11,36 @@ dummy-iface:
sudo ip addr add dev dummy0 2001:db8::1/64
sudo ip link set dev dummy0 up

peeringdb-test-harness:
nohup python3 tests/peeringdb/peeringdb-test-api.py &
build-pdb:
docker build -t peeringdb-test-api tests/peeringdb

test-setup: dummy-iface peeringdb-test-harness
run-pdb:
docker rm -f pathvector-peeringdb-test-api || true
docker run --name pathvector-peeringdb-test-api -d -p 5001:5001 peeringdb-test-api

run-bird:
docker rm -f pathvector-bird || true
rm -rf /tmp/bird-conf || true
mkdir -p /tmp/bird-conf
echo "protocol device {}" > /tmp/bird-conf/bird.conf
docker run \
-d \
--privileged \
--name pathvector-bird \
-p 5002:5002 \
-v $(shell pwd)/tests/bird-entrypoint.sh:/entrypoint.sh \
-v /tmp/bird-conf/:/etc/bird/ \
-v /tmp/test-cache/:/tmp/test-cache/ \
pierky/bird:2.16 /entrypoint.sh

pdb-api: build-pdb run-pdb

test-setup: dummy-iface run-bird pdb-api

test:
export PATHVECTOR_TEST=1 && go test -v -race -coverprofile=coverage.txt -covermode=atomic ./pkg/... ./cmd/...
go test -v -p 1 -coverprofile=coverage.txt -covermode=atomic ./pkg/... ./cmd/...

test-teardown:
pkill -f tests/peeringdb/peeringdb-test-api.py
sudo ip link del dev dummy0
rm -f nohup.out
test-sequence: test-setup test down

test-sequence: test-setup test test-teardown
snapshot:
goreleaser --snapshot --clean
80 changes: 80 additions & 0 deletions cmd/bird_fmt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package cmd

import (
"os"
"path/filepath"
"strings"

"github.com/spf13/cobra"

"github.com/natesales/pathvector/pkg/bird"
"github.com/natesales/pathvector/pkg/util/log"
)

func init() {
rootCmd.AddCommand(birdFmtCmd)
}

func isDir(path string) (bool, error) {
fi, err := os.Stat(path)
if err != nil {
return false, err
}

return fi.IsDir(), nil
}

func formatFile(path string) error {
if !strings.HasSuffix(path, ".conf") {
log.Debugf("Skipping %s", path)
return nil
}

log.Infof("Formatting %s", path)

unformatted, err := os.ReadFile(path)
if err != nil {
return err
}

formatted := bird.Reformat(string(unformatted))

if err := os.WriteFile(path, []byte(formatted), 0644); err != nil {
return err
}

return nil
}

var birdFmtCmd = &cobra.Command{
Use: "bird-fmt [file/directory]",
Short: "Format BIRD config",
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
log.Fatal("No file/directory specified")
}

target := args[0]

// Check if directory
dir, err := isDir(target)
if err != nil {
log.Fatal(err)
}
if dir {
// For file in walk directory
if err := filepath.Walk(target, func(path string, info os.FileInfo, err error) error {
if err != nil {
log.Fatal(err)
}
return formatFile(path)
}); err != nil {
log.Fatal(err)
}
} else {
if err := formatFile(target); err != nil {
log.Fatal(err)
}
}
},
}
5 changes: 2 additions & 3 deletions cmd/birdsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package cmd

import (
"bufio"
"fmt"
"net"
"os"
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"

"github.com/natesales/pathvector/pkg/bird"
"github.com/natesales/pathvector/pkg/util/log"
)

var socket = ""
Expand Down Expand Up @@ -50,7 +49,7 @@ var birdshCmd = &cobra.Command{

r := bufio.NewReader(os.Stdin)
for {
fmt.Print("bird> ")
log.Printf("bird> ")
cmd, _ := r.ReadString('\n')
cmd = strings.ReplaceAll(cmd, "\n", "")
if cmd != "" {
Expand Down
Loading
Loading