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

Difficult to call self during integration test #245

Closed
HelloGrayson opened this issue Jun 30, 2016 · 6 comments
Closed

Difficult to call self during integration test #245

HelloGrayson opened this issue Jun 30, 2016 · 6 comments
Milestone

Comments

@HelloGrayson
Copy link
Contributor

For integration testing, a common desire will be to use a random port when listening, and to then configure an outbound for calling yourself. Currently, this isn't possible:

rpc := yarpc.New(
    "myservice",
    Inbounds: []transport.Inbound{
        tch.NewInbound(nil),
    },
    Outbounds: transport.Outbounds{
        "myservice": tch.NewOutbound(nil, tch.HostPort("127.0.0.1:7777")),
    },
)
rpc.Start()

In the above solution, 7777 is the wrong port, but it's not possible to get the random port created when start was called on the inbound...

Options:

  • Create a tchannel ahead of time, call listen on it, and then use the listening port to configure the outbound
  • Create an outbound after the fact and use it directly

None of these options are very satisfying...

@abhinav
Copy link
Contributor

abhinav commented Jun 30, 2016

Related: #87

@HelloGrayson HelloGrayson modified the milestones: post 1.0.0 triage, Post 1.0.0 Triage Dec 28, 2016
@kriskowal
Copy link
Contributor

This is related to trouble @peter-edge has encountered in building multi-process integration tests that need to listen on 0 and cross-communicate the port. It is almost like cases like this need a placement and service discovery system to direct traffic to tasks on ephemeral ports.

How does Mesos hand-off a port to a task? Does it listen on 0, pass the address to the child process through an environment variable, expect the client to listen on the same port with SO_REUSEPORT, then at some point in the future release the socket?

@kriskowal
Copy link
Contributor

I think we might solve this specific case by having transport.Inbound implement a method that returns a peer chooser for its own address.

tch := tchannel.NewTransport()
tchIn := tchIn.NewInbound()
rpc := yarpc.New(
    "myservice",
    Inbounds: []transport.Inbound{tchIn},
    Outbounds: transport.Outbounds{
        "myservice": tchIn.Loopback(),
    },
)
rpc.Start()

@kriskowal kriskowal added this to the Wishlist milestone Apr 11, 2017
@kriskowal
Copy link
Contributor

I’ve asked our Mesos friends how they manage the hand-off of ports to tasks. They reserve a block of high ports just under the ephemeral range, like 30,000 and up and Mesos meters these out to tasks. I’ll make note on Peter’s get ports PR.

@bufdev
Copy link
Contributor

bufdev commented Apr 13, 2017

I thought our goal was to move everything to net.Listeners per our discussion on #866, I started working on this in #897

@HelloGrayson
Copy link
Contributor Author

Closing based on @peter-edge's comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants