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

test: Add testing of connect()-ion abort ability #2301

Closed
wants to merge 1 commit into from

Conversation

xemul
Copy link
Contributor

@xemul xemul commented Jun 25, 2024

Docs say, that calling socket::shutdown() aborts any in-flight connection. This happens to be true for linux-aio backend, but not for the io-uring one. Here's the test.

Copy link
Contributor

@nyh nyh left a comment

Choose a reason for hiding this comment

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

If this is a bug, please open an issue for it and "Refs" to it from this test.
If the test is know to fail on io-uring, how can we have it in our test suite? Maybe we need something like "xfail"?

But I don't understand what this test does. It appears it calls sk.shutdown() (which I assume has nothing to do with shutdown(2) :-( ), and then doesn't check anything else.

return seastar::async([&] {
bool too_late = false;
auto sk = make_socket();
auto cf = sk.connect(ipv4_addr("10.255.255.1", 12345)).then([] (auto cs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is supposed to happen in this address? I assume you hope it will never respond?
Maybe it's better to use a really reserved address for this? E.g., something from TEST-NET-1 (192.0.2.0/24). See https://www.rfc-editor.org/rfc/rfc5735

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is supposed to happen in this address? I assume you hope it will never respond?

Yes. 10.0.0.0/8 is reserved range for local communications, I assume that 10.255.255.* is not routable in any ... practical environments like CI instances which seems to be true

Maybe it's better to use a really reserved address for this? E.g., something from TEST-NET-1 (192.0.2.0/24). See https://www.rfc-editor.org/rfc/rfc5735

Ah, 192.0.2.0/24 sounds much better, thanks


auto check = sleep(std::chrono::seconds(2)).then([&too_late] {
fmt::print("Connection must have been aborted already\n");
too_late = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is it defined that connect() should time out in less than 2 seconds?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I think I understand now - it's not about timeout at all. The code below after 0.5 seconds calls shutdown() on the connection, and then the connect() code (above) will stop and check too_late wasn't yet set. And it wasn't - it will be set only after 2 seconds.

Maybe the code could have been organized in a different order to make this clearer, but at least it looks corect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's exactly as you described.

@xemul
Copy link
Contributor Author

xemul commented Jun 27, 2024

If this is a bug, please open an issue for it and "Refs" to it from this test.

Already there -- #2302

If the test is know to fail on io-uring, how can we have it in our test suite? Maybe we need something like "xfail"?

The CI runs with aio backend which works

But I don't understand what this test does. It appears it calls sk.shutdown() (which I assume has nothing to do with shutdown(2) :-( ), and then doesn't check anything else.

It is shutdown(2) for TCP sockets:

    virtual void shutdown() override {
        if (_fd) {
            try {
                _fd.shutdown(SHUT_RDWR);
            } catch (std::system_error& e) {
                if (e.code().value() != ENOTCONN) {
                    throw;
                }
            }
        }
    }

@xemul xemul force-pushed the br-socket-connect-abort-test branch from 82a5204 to ec4546b Compare June 27, 2024 16:33
@xemul
Copy link
Contributor Author

xemul commented Jun 27, 2024

upd:

  • use 192.0.2.1 as "truly reserved" IP address
  • swapped abort and check futures for better readability

@nyh
Copy link
Contributor

nyh commented Jun 30, 2024

If this is a bug, please open an issue for it and "Refs" to it from this test.

Already there -- #2302

Thanks, so please "Refs" to it from this PR.

If the test is know to fail on io-uring, how can we have it in our test suite? Maybe we need something like "xfail"?

The CI runs with aio backend which works

This is very awkward :-( It suggests we some specific tests which check networking and some other features, we need to run them multiple times with different backends... Of course, you don't need to fix this in this PR.

Copy link
Contributor

@nyh nyh left a comment

Choose a reason for hiding this comment

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

Looks good, but please add a comment what this test does, and referencing the new issue you opened on its failure on some of the backend choices.

tests/unit/socket_test.cc Show resolved Hide resolved
Docs say, that calling socket::shutdown() aborts any in-flight
connection. This happens to be true for linux-aio backend, but not for
the io-uring one. Here's the test.

Signed-off-by: Pavel Emelyanov <[email protected]>
@xemul xemul force-pushed the br-socket-connect-abort-test branch from ec4546b to d2beaab Compare July 1, 2024 06:37
@xemul xemul requested a review from nyh July 1, 2024 06:38
@nyh nyh closed this in a901853 Jul 1, 2024
ptrsmrn pushed a commit to ptrsmrn/seastar that referenced this pull request Jul 17, 2024
Docs say, that calling socket::shutdown() aborts any in-flight
connection. This happens to be true for linux-aio backend, but not for
the io-uring one. Here's the test.

Signed-off-by: Pavel Emelyanov <[email protected]>

Closes scylladb#2301
lovio pushed a commit to lovio/seastar that referenced this pull request Aug 30, 2024
Docs say, that calling socket::shutdown() aborts any in-flight
connection. This happens to be true for linux-aio backend, but not for
the io-uring one. Here's the test.

Signed-off-by: Pavel Emelyanov <[email protected]>

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

Successfully merging this pull request may close these issues.

2 participants