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

[management] optimize test execution #3204

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 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
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
30 changes: 25 additions & 5 deletions .github/workflows/golang-test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ 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 -p 1 \
-exec "sudo --preserve-env=CI,NETBIRD_STORE_ENGINE" \
-timeout 10m $(go list ./... | grep /management)

benchmark:
needs: [ build-cache ]
Expand Down Expand Up @@ -254,7 +259,12 @@ 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 10m ./...

api_benchmark:
needs: [ build-cache ]
Expand Down Expand Up @@ -312,9 +322,14 @@ 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 -tags=benchmark -run=^$ -bench=. -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 }} CI=true \
go test -tags=benchmark -run=^$ -bench=. \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 10m $(go list ./... | grep /management)

api_integration_test:
needs: [ build-cache ]
Expand Down Expand Up @@ -363,7 +378,12 @@ 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 -p 1 -exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' -timeout 10m -tags=integration $(go list ./... | grep /management)
run: |
CGO_ENABLED=1 GOARCH=${{ matrix.arch }} \
NETBIRD_STORE_ENGINE=${{ matrix.store }} CI=true \
go test -p 1 \
-exec 'sudo --preserve-env=CI,NETBIRD_STORE_ENGINE' \
-timeout 10m -tags=integration $(go list ./... | grep /management)

test_client_on_docker:
needs: [ build-cache ]
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
2 changes: 1 addition & 1 deletion management/server/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func TestSaveDNSSettings(t *testing.T) {

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

err = am.SaveDNSSettings(context.Background(), account.Id, testCase.userID, testCase.inputSettings)
Expand Down
13 changes: 0 additions & 13 deletions management/server/management_suite_test.go

This file was deleted.

Loading
Loading