Repository navigation
fix: advertise reset_stream_at on mvfst listeners #797
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * Copyright (c) OpenMOQ contributors. | ||
| * This source code is licensed under the Apache 2.0 license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| #include "MoqxRelayServer.h" | ||
|
|
||
| #include <folly/coro/BlockingWait.h> | ||
| #include <folly/coro/Sleep.h> | ||
| #include <folly/io/IOBuf.h> | ||
| #include <folly/portability/GTest.h> | ||
| #include <moxygen/util/InsecureVerifierDangerousDoNotUseInProduction.h> | ||
| #include <moxygen/util/QuicConnector.h> | ||
| #include <quic/client/QuicClientTransport.h> | ||
| #include <quic/state/StateData.h> | ||
|
|
||
| #include <chrono> | ||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| namespace openmoq::moqx::test { | ||
| namespace { | ||
|
|
||
| class MoqxRelayServerTest : public ::testing::Test { | ||
| protected: | ||
| void SetUp() override { | ||
| config::ListenerConfig listener; | ||
| listener.address = folly::SocketAddress("::1", 0); | ||
| listener.tlsMode = config::Insecure{}; | ||
| listener.endpoint = "/moq"; | ||
| listener.moqtVersions = "18"; | ||
| auto context = std::make_shared<MoqxRelayContext>( | ||
| folly::F14FastMap<std::string, config::ServiceConfig>{}, | ||
| "test-relay" | ||
| ); | ||
| server_ = std::make_unique<MoqxRelayServer>(listener, std::move(context), &ioExecutor_); | ||
| server_->start(); | ||
| } | ||
|
|
||
| void TearDown() override { | ||
| if (client_) { | ||
| client_->closeNow({}); | ||
| client_.reset(); | ||
| } | ||
| if (server_) { | ||
| server_->stop(); | ||
| server_.reset(); | ||
| } | ||
| clientEvb_.loop(); | ||
| } | ||
|
|
||
| void connect(const std::string& alpn, bool reliableResetSupport) { | ||
| quic::TransportSettings settings; | ||
| settings.advertisedReliableResetStreamSupport = reliableResetSupport; | ||
| client_ = folly::coro::blockingWait( | ||
| moxygen::QuicConnector::connectQuic( | ||
| &clientEvb_, | ||
| server_->getAddress(), | ||
| std::chrono::seconds(5), | ||
| std::make_shared<moxygen::test::InsecureVerifierDangerousDoNotUseInProduction>(), | ||
| {alpn}, | ||
| settings | ||
| ), | ||
| &clientEvb_ | ||
| ); | ||
| } | ||
|
|
||
| folly::EventBase clientEvb_; | ||
| folly::IOThreadPoolExecutor ioExecutor_{1}; | ||
| std::unique_ptr<MoqxRelayServer> server_; | ||
| std::shared_ptr<quic::QuicClientTransport> client_; | ||
| }; | ||
|
|
||
| TEST_F(MoqxRelayServerTest, AdvertisesReliableResetSupportForWebTransport) { | ||
| connect("h3", true); | ||
|
|
||
| ASSERT_NE(client_, nullptr); | ||
| ASSERT_NE(client_->getState(), nullptr); | ||
| EXPECT_TRUE(client_->getState()->peerAdvertisedReliableStreamResetSupport); | ||
| } | ||
|
|
||
| TEST_F(MoqxRelayServerTest, AcceptsHttp3PeerWithoutReliableResetSupport) { | ||
| connect("h3", false); | ||
|
|
||
| ASSERT_NE(client_, nullptr); | ||
| EXPECT_TRUE(client_->good()); | ||
| } | ||
|
|
||
| TEST_F(MoqxRelayServerTest, ReliableResetKeepsConnectionOpen) { | ||
| connect("h3", true); | ||
| ASSERT_NE(client_, nullptr); | ||
| ASSERT_TRUE(client_->getState()->peerAdvertisedReliableStreamResetSupport); | ||
|
|
||
| auto stream = client_->createUnidirectionalStream(); | ||
| ASSERT_TRUE(stream.has_value()); | ||
| // Reserved HTTP/3 stream type 0x21, which the server must ignore. | ||
| ASSERT_TRUE(client_->writeChain(*stream, folly::IOBuf::copyBuffer("\x21reliable"), false)); | ||
| ASSERT_TRUE(client_->updateReliableDeliveryCheckpoint(*stream)); | ||
| ASSERT_TRUE(client_->writeChain(*stream, folly::IOBuf::copyBuffer("unreliable"), false)); | ||
| ASSERT_TRUE(client_->resetStreamReliably(*stream, quic::ApplicationErrorCode(0x10c))); | ||
|
|
||
| folly::coro::blockingWait(folly::coro::sleep(std::chrono::seconds(1)), &clientEvb_); | ||
|
|
||
| EXPECT_TRUE(client_->good()); | ||
| EXPECT_FALSE(client_->getState()->localConnectionError.has_value()); | ||
| EXPECT_FALSE(client_->getState()->peerConnectionError.has_value()); | ||
| } | ||
|
|
||
| } // namespace | ||
| } // namespace openmoq::moqx::test | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.