Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#165 from jsafrane/add-mock-address
Browse files Browse the repository at this point in the history
Add StartOnAddress function to listen on unix:// paths
  • Loading branch information
k8s-ci-robot authored Feb 12, 2019
2 parents 42e1912 + 12ab4b6 commit 76b25a7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions driver/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func NewMockCSIDriver(servers *MockCSIDriverServers) *MockCSIDriver {
}
}

func (m *MockCSIDriver) Start() error {
// Listen on a port assigned by the net package
l, err := net.Listen("tcp", "127.0.0.1:0")
// StartOnAddress starts a new gRPC server listening on given address.
func (m *MockCSIDriver) StartOnAddress(network, address string) error {
l, err := net.Listen(network, address)
if err != nil {
return err
}
Expand All @@ -61,6 +61,12 @@ func (m *MockCSIDriver) Start() error {
return nil
}

// Start starts a new gRPC server listening on a random TCP loopback port.
func (m *MockCSIDriver) Start() error {
// Listen on a port assigned by the net package
return m.StartOnAddress("tcp", "127.0.0.1:0")
}

func (m *MockCSIDriver) Nexus() (*grpc.ClientConn, error) {
// Start server
err := m.Start()
Expand Down

0 comments on commit 76b25a7

Please sign in to comment.