AB#1903 Push keys to restarting nodes on trigger RPC

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2022-04-11 15:28:41 +02:00 committed by Daniel Weiße
parent 152e3985f7
commit 37aff14cab
9 changed files with 193 additions and 24 deletions

View file

@ -1,9 +1,13 @@
package pubapi
import (
"context"
"net"
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/goleak"
grpcpeer "google.golang.org/grpc/peer"
)
func TestMain(m *testing.M) {
@ -14,3 +18,20 @@ func TestMain(m *testing.M) {
goleak.IgnoreTopFunction("k8s.io/klog/v2.(*loggingT).flushDaemon"),
)
}
func TestGetRecoveryPeerFromContext(t *testing.T) {
assert := assert.New(t)
testIP := "192.0.2.1"
testPort := 1234
expectedPeer := net.JoinHostPort(testIP, "9000")
addr := &net.TCPAddr{IP: net.ParseIP(testIP), Port: testPort}
ctx := grpcpeer.NewContext(context.Background(), &grpcpeer.Peer{Addr: addr})
peer, err := GetRecoveryPeerFromContext(ctx)
assert.NoError(err)
assert.Equal(expectedPeer, peer)
_, err = GetRecoveryPeerFromContext(context.Background())
assert.Error(err)
}