mirror of
https://github.com/siderolabs/discovery-service.git
synced 2025-03-14 09:55:08 +00:00
test: add a client test with affiliate deletion
Test affiliate deletion from PR https://github.com/siderolabs/discovery-client/pull/3. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
2
go.mod
2
go.mod
@ -6,9 +6,9 @@ require (
|
||||
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/siderolabs/discovery-client v0.1.1
|
||||
github.com/stretchr/testify v1.8.0
|
||||
github.com/talos-systems/discovery-api v0.1.0
|
||||
github.com/talos-systems/discovery-client v0.1.0
|
||||
github.com/talos-systems/go-debug v0.2.1
|
||||
go.uber.org/zap v1.23.0
|
||||
go4.org/netipx v0.0.0-20220812043211-3cc044ffd68d
|
||||
|
4
go.sum
4
go.sum
@ -210,6 +210,8 @@ github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5
|
||||
github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4=
|
||||
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/siderolabs/discovery-client v0.1.1 h1:1lhXTepW4V1IJPf91ApvF77cBl086d1OXuC4WdVp8hM=
|
||||
github.com/siderolabs/discovery-client v0.1.1/go.mod h1:gBE5qxdB4BcY2nXOBJ14Qh8u7cBadCofjbxBLohcnbQ=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
|
||||
@ -226,8 +228,6 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/talos-systems/discovery-api v0.1.0 h1:aKod6uqakH6VfeQ6HaxPF7obqFAL1QTJe4HHTb2mVKk=
|
||||
github.com/talos-systems/discovery-api v0.1.0/go.mod h1:ZsbzzOC5bzToaF3+YvUXDf9paeWV5bedpDu5RPXrglM=
|
||||
github.com/talos-systems/discovery-client v0.1.0 h1:m+f96TKGFckMWrhDI+o9+QhcGn8f1A61Jp6YYVwiulI=
|
||||
github.com/talos-systems/discovery-client v0.1.0/go.mod h1:LxqCv16VBB68MgaMnV8jXujYd3Q097DAn22U5gaHmkU=
|
||||
github.com/talos-systems/go-debug v0.2.1 h1:VSN8P1zXWeHWgUBZn4cVT3keBcecCAJBG9Up+F6N2KM=
|
||||
github.com/talos-systems/go-debug v0.2.1/go.mod h1:pR4NjsZQNFqGx3n4qkD4MIj1F2CxyIF8DCiO1+05JO0=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
|
@ -19,10 +19,10 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/siderolabs/discovery-client/pkg/client"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
clientpb "github.com/talos-systems/discovery-api/api/v1alpha1/client/pb"
|
||||
"github.com/talos-systems/discovery-client/pkg/client"
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zaptest"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -190,6 +190,23 @@ func TestClient(t *testing.T) {
|
||||
|
||||
assert.Equal(t, []*client.Affiliate{affiliate1PB}, client2.GetAffiliates())
|
||||
|
||||
// delete affiliate1, client2 should see the update
|
||||
client1.DeleteLocalAffiliate()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-notify2:
|
||||
case <-time.After(time.Second):
|
||||
require.Fail(t, "no incremental update")
|
||||
}
|
||||
|
||||
if len(client2.GetAffiliates()) == 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
require.Len(t, client2.GetAffiliates(), 0)
|
||||
|
||||
cancel()
|
||||
|
||||
err = eg.Wait()
|
||||
|
Reference in New Issue
Block a user