Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
5b8636c
refactor ginkgo test and add cancel to sync client test
pascal-fischer Jan 17, 2025
3662872
mark test helper functions
pascal-fischer Jan 17, 2025
801ce51
except input dsn an run testcontainer only once
pascal-fischer Jan 18, 2025
9e09de1
start postgres container from github actions
pascal-fischer Jan 18, 2025
f2d800a
run store test for all engines example
pascal-fischer Jan 18, 2025
293bf6e
fix local container startup
pascal-fischer Jan 18, 2025
70bd33f
explicitly start postgres on github
pascal-fischer Jan 18, 2025
009e742
revert tests to old version
pascal-fischer Jan 18, 2025
c283492
update workflow
pascal-fischer Jan 18, 2025
6644de9
remove drop with force
pascal-fischer Jan 18, 2025
9258adb
close db connection
pascal-fischer Jan 18, 2025
5cffe78
add mysql container and fix close
pascal-fischer Jan 18, 2025
58e00bb
fix typo
pascal-fischer Jan 18, 2025
5eb5e37
enable for other workflows
pascal-fischer Jan 18, 2025
de920b3
grant permissions
pascal-fischer Jan 18, 2025
cd4e191
wait for mysql to be ready
pascal-fischer Jan 18, 2025
5c50f06
update grant privileges
pascal-fischer Jan 18, 2025
8849b40
mysql without a password
pascal-fischer Jan 19, 2025
3525837
use proper credentials for mysql root
pascal-fischer Jan 19, 2025
229610a
fix other workflows
pascal-fischer Jan 19, 2025
4697879
remove other test runs
pascal-fischer Jan 19, 2025
83c1070
remove with force when dropping database
pascal-fischer Jan 19, 2025
441313d
allow force for postgres
pascal-fischer Jan 19, 2025
3c820a2
don't cleanup containers after tests
pascal-fischer Jan 19, 2025
46ff4f4
remove container startup from workflow files
pascal-fischer Jan 19, 2025
b00d633
use basic drop table again
pascal-fischer Jan 19, 2025
6328112
extract supported engines
pascal-fischer Jan 20, 2025
4e40ceb
merge
pascal-fischer Feb 17, 2025
dc75d98
fix expectations
pascal-fischer Feb 17, 2025
55291a9
extract reused store creation
pascal-fischer Feb 17, 2025
cad26d6
Merge branch 'main' into tests/optimize-test-execution
pascal-fischer Feb 18, 2025
9742165
cascade on PAT delete
pascal-fischer Feb 18, 2025
9b5151c
Merge remote-tracking branch 'origin/tests/optimize-test-execution' i…
pascal-fischer Feb 18, 2025
ebcbcd5
extend errors
pascal-fischer Feb 18, 2025
92946fd
extend errors
pascal-fischer Feb 18, 2025
76d716a
extract store creation in test
pascal-fischer Feb 18, 2025
d1cca3b
use UUID for DB names
pascal-fischer Feb 18, 2025
a5f8b8f
remove kill mysql connections
pascal-fischer Feb 18, 2025
ece60de
change dbname
pascal-fischer Feb 18, 2025
a010728
change dbname
pascal-fischer Feb 18, 2025
8695c88
remove helper
pascal-fischer Feb 18, 2025
8f30b4b
add sleep
pascal-fischer Feb 18, 2025
f8efa63
add sleep
pascal-fischer Feb 18, 2025
f54f420
remove sleep and exclude linter
pascal-fischer Feb 18, 2025
387bf32
DB name replacement
pascal-fischer Feb 18, 2025
74fcd64
update regex
pascal-fischer Feb 18, 2025
6b319e4
increase benchmark timeout
pascal-fischer Feb 18, 2025
5a2cc28
update actions workflow
pascal-fischer Feb 18, 2025
c0b3b6e
add workflow names
pascal-fischer Feb 18, 2025
2308305
revert name
pascal-fischer Feb 18, 2025
c754eea
Merge branch 'main' into tests/optimize-test-execution
pascal-fischer Feb 18, 2025
ebe1f9a
update names
pascal-fischer Feb 18, 2025
6039055
update name
pascal-fischer Feb 18, 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
150 changes: 142 additions & 8 deletions .github/workflows/golang-test-linux.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test Code Linux
name: Linux

on:
push:
Expand All @@ -12,6 +12,7 @@ concurrency:

jobs:
build-cache:
name: "Build Cache"
runs-on: ubuntu-22.04
outputs:
management: ${{ steps.filter.outputs.management }}
Expand Down Expand Up @@ -47,7 +48,6 @@ jobs:
key: ${{ runner.os }}-gotest-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gotest-cache-${{ hashFiles('**/go.sum') }}


- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -98,6 +98,7 @@ jobs:
run: CGO_ENABLED=1 GOARCH=386 go build -o relay-386 .

test:
name: "Client / Unit"
needs: [build-cache]
strategy:
fail-fast: false
Expand Down Expand Up @@ -143,9 +144,116 @@ jobs:
run: git --no-pager diff --exit-code

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} CI=true go test -tags devcert -exec 'sudo' -timeout 10m -p 1 $(go list ./... | grep -v /management)
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} CI=true go test -tags devcert -exec 'sudo' -timeout 10m -p 1 $(go list ./... | grep -v -e /management -e /signal -e /relay)

test_relay:
name: "Relay / Unit"
needs: [build-cache]
strategy:
fail-fast: false
matrix:
arch: [ '386','amd64' ]
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
cache: false

- name: Checkout code
uses: actions/checkout@v4

- name: Get Go environment
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

- name: Cache Go modules
uses: actions/cache/restore@v4
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-gotest-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gotest-cache-

- name: Install dependencies
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev gcc-multilib libpcap-dev

- name: Install 32-bit libpcap
if: matrix.arch == '386'
run: sudo dpkg --add-architecture i386 && sudo apt update && sudo apt-get install -y libpcap0.8-dev:i386

- name: Install modules
run: go mod tidy

- name: check git status
run: git --no-pager diff --exit-code

- name: Test
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
go test \
-exec 'sudo' \
-timeout 10m ./signal/...

test_signal:
name: "Signal / Unit"
needs: [build-cache]
strategy:
fail-fast: false
matrix:
arch: [ '386','amd64' ]
runs-on: ubuntu-22.04
steps:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
cache: false

- name: Checkout code
uses: actions/checkout@v4

- name: Get Go environment
run: |
echo "cache=$(go env GOCACHE)" >> $GITHUB_ENV
echo "modcache=$(go env GOMODCACHE)" >> $GITHUB_ENV

- name: Cache Go modules
uses: actions/cache/restore@v4
with:
path: |
${{ env.cache }}
${{ env.modcache }}
key: ${{ runner.os }}-gotest-cache-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-gotest-cache-

- name: Install dependencies
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev gcc-multilib libpcap-dev

- name: Install 32-bit libpcap
if: matrix.arch == '386'
run: sudo dpkg --add-architecture i386 && sudo apt update && sudo apt-get install -y libpcap0.8-dev:i386

- name: Install modules
run: go mod tidy

- name: check git status
run: git --no-pager diff --exit-code

- name: Test
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
go test \
-exec 'sudo' \
-timeout 10m ./signal/...

test_management:
name: "Management / Unit"
needs: [ build-cache ]
strategy:
fail-fast: false
Expand Down Expand Up @@ -203,9 +311,15 @@ jobs:
run: docker pull mlsmaycon/warmed-mysql:8

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -tags=devcert -p 1 -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 10m $(go list ./... | grep /management)
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
NETBIRD_STORE_ENGINE=${{ matrix.store }} \
go test -tags=devcert \
-exec "sudo --preserve-env=CI,NETBIRD_STORE_ENGINE" \
-timeout 10m ./management/...

benchmark:
name: "Management / Benchmark"
needs: [ build-cache ]
if: ${{ needs.build-cache.outputs.management == 'true' || github.event_name != 'pull_request' }}
strategy:
Expand Down Expand Up @@ -264,9 +378,15 @@ jobs:
run: docker pull mlsmaycon/warmed-mysql:8

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -tags devcert -run=^$ -bench=. -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 20m ./...
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \
go test -tags devcert -run=^$ -bench=. \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 20m ./...

api_benchmark:
name: "Management / Benchmark (API)"
needs: [ build-cache ]
if: ${{ needs.build-cache.outputs.management == 'true' || github.event_name != 'pull_request' }}
strategy:
Expand Down Expand Up @@ -323,11 +443,19 @@ jobs:
- name: download mysql image
if: matrix.store == 'mysql'
run: docker pull mlsmaycon/warmed-mysql:8

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -run=^$ -tags=benchmark -bench=. -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 30m $(go list -tags=benchmark ./... | grep /management)
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \
go test -tags=benchmark \
-run=^$ \
-bench=. \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 20m ./management/...

api_integration_test:
name: "Management / Integration"
needs: [ build-cache ]
if: ${{ needs.build-cache.outputs.management == 'true' || github.event_name != 'pull_request' }}
strategy:
Expand Down Expand Up @@ -375,9 +503,15 @@ jobs:
run: git --no-pager diff --exit-code

- name: Test
run: CGO_ENABLED=1 GOARCH=${{ matrix.arch }} NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true go test -tags=integration -p 1 -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 30m $(go list -tags=integration ./... | grep /management)
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \
go test -tags=integration \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 10m ./management/...

test_client_on_docker:
name: "Client (Docker) / Unit"
needs: [ build-cache ]
runs-on: ubuntu-20.04
steps:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ linters:
- predeclared # predeclared finds code that shadows one of Go's predeclared identifiers
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- thelper # thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers.
# - thelper # thelper detects Go test helpers without t.Helper() call and checks the consistency of test helpers.
- wastedassign # wastedassign finds wasted assignment statements
issues:
# Maximum count of issues with the same text.
Expand Down
5 changes: 4 additions & 1 deletion management/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ func TestClient_Sync(t *testing.T) {

ch := make(chan *mgmtProto.SyncResponse, 1)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

go func() {
err = client.Sync(context.Background(), info, func(msg *mgmtProto.SyncResponse) error {
err = client.Sync(ctx, info, func(msg *mgmtProto.SyncResponse) error {
ch <- msg
return nil
})
Expand Down
14 changes: 7 additions & 7 deletions management/server/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestGetDNSSettings(t *testing.T) {

account, err := initTestDNSAccount(t, am)
if err != nil {
t.Fatal("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}

dnsSettings, err := am.GetDNSSettings(context.Background(), account.Id, dnsAdminUserID)
Expand Down Expand Up @@ -124,12 +124,12 @@ func TestSaveDNSSettings(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
am, err := createDNSManager(t)
if err != nil {
t.Error("failed to create account manager")
t.Fatalf("failed to create account manager")
}

account, err := initTestDNSAccount(t, am)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %v", err)
}

err = am.SaveDNSSettings(context.Background(), account.Id, testCase.userID, testCase.inputSettings)
Expand All @@ -156,22 +156,22 @@ func TestGetNetworkMap_DNSConfigSync(t *testing.T) {

am, err := createDNSManager(t)
if err != nil {
t.Error("failed to create account manager")
t.Fatalf("failed to create account manager: %s", err)
}

account, err := initTestDNSAccount(t, am)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}

peer1, err := account.FindPeerByPubKey(dnsPeer1Key)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}

peer2, err := account.FindPeerByPubKey(dnsPeer2Key)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}

newAccountDNSConfig, err := am.GetNetworkMap(context.Background(), peer1.ID)
Expand Down
6 changes: 3 additions & 3 deletions management/server/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestDefaultAccountManager_CreateGroup(t *testing.T) {

_, account, err := initTestGroupAccount(am)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}
for _, group := range account.Groups {
group.Issued = types.GroupIssuedIntegration
Expand Down Expand Up @@ -59,12 +59,12 @@ func TestDefaultAccountManager_CreateGroup(t *testing.T) {
func TestDefaultAccountManager_DeleteGroup(t *testing.T) {
am, err := createManager(t)
if err != nil {
t.Error("failed to create account manager")
t.Fatalf("failed to create account manager: %s", err)
}

_, account, err := initTestGroupAccount(am)
if err != nil {
t.Error("failed to init testing account")
t.Fatalf("failed to init testing account: %s", err)
}

testCases := []struct {
Expand Down
13 changes: 0 additions & 13 deletions management/server/management_suite_test.go

This file was deleted.

Loading
Loading