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

need Integration Test for disconnecting downstream connections on all roles #1432

Open
plebhash opened this issue Jan 31, 2025 · 3 comments · May be fixed by #1434
Open

need Integration Test for disconnecting downstream connections on all roles #1432

plebhash opened this issue Jan 31, 2025 · 3 comments · May be fixed by #1434
Assignees

Comments

@plebhash
Copy link
Collaborator

#1426 made us notice an edge case that ideally we should cover in CI for all roles that accept downstream connections.

the tests should look something like this:

  • launch role under test (together with all upstream roles it needs as a pre-requisite)
  • connect at least two downstreams to the role under test
  • kill one downstream

the test should assert that the role stays alive (and doesn't die like in #1426)

@plebhash
Copy link
Collaborator Author

currently the ITF doesn't provide any primitives for this, but hopefully #1390 will provide something

@plebhash
Copy link
Collaborator Author

currently the ITF doesn't provide any primitives for this, but hopefully #1390 will provide something

alternatively, I wonder if shutdown APIs could also be a way to move forward with this, similarly to what was done via #1319 and #1321

what do you think @Shourya742 ?

@plebhash
Copy link
Collaborator Author

plebhash commented Feb 1, 2025

after a little investigation I realized that there's actually no need for #1390 nor shutdown APIs, as downstream connections can be easily emulated with a TcpStream::connect

for example:

#[tokio::test]
async fn tproxy_survives_downstream_disconnect() {
    tracing_subscriber::fmt()
        .with_env_filter(EnvFilter::from_default_env())
        .init();
    let (_tp, tp_addr) = start_template_provider(None).await;
    let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
    let (_, tproxy_addr) = start_sv2_translator(pool_addr).await;

    // emulate first downstream
    let downstream_a = std::net::TcpStream::connect(tproxy_addr).unwrap();

    // emulate second downstream
    let _downstream_b = std::net::TcpStream::connect(tproxy_addr).unwrap();

    // wait a bit to make sure the TCP sockets are processed
    tokio::time::sleep(std::time::Duration::from_secs(1)).await;

    // kill downstream_a
    downstream_a.shutdown(std::net::Shutdown::Both).unwrap();
    drop(downstream_a);

    // wait a bit to make sure the TCP sockets are processed
    tokio::time::sleep(std::time::Duration::from_secs(1)).await;

    // tproxy still up
    assert!(tokio::net::TcpListener::bind(tproxy_addr).await.is_err());
}

I'll work on a PR

@plebhash plebhash self-assigned this Feb 1, 2025
@plebhash plebhash changed the title Integration Test for disconnecting downstream connections on all roles need Integration Test for disconnecting downstream connections on all roles Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant