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

Add StartOnAddress function to listen on unix:// paths #165

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
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
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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment doesn't match the method.

I know it wasn't document before either (or at least not here), but when using random port allocation, how does the caller determine how to reach the mock driver, i.e. determine the port?

Copy link
Contributor Author

@jsafrane jsafrane Feb 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 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