-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
network: add socket interface factory and config option #11630
Merged
Merged
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
388d1f9
network: add socket interface factory
florincoras c241e44
Merge branch 'master' into sock_factory
florincoras cc4d075
updates that try to reflect community conversations
florincoras d77b0a9
address comments
florincoras fdd0e2f
moving back to bootstrap extensions
florincoras 1ca8153
Merge branch 'master' into sock_factory
florincoras 6c34d86
use FactoryRegistry for SocketInterface lookup
florincoras 0f300c8
fix protodoc-title
florincoras 3612cfa
Merge branch 'master' into sock_factory
florincoras af294af
fix socket interface lookup
florincoras 43805c8
move default_socket_interface.proto to extensions
florincoras a02aa41
Merge branch 'master' into sock_factory
florincoras b622854
address comments
florincoras bd1a63d
Merge branch 'master' into sock_factory
florincoras f9cc098
disable integration test on windows
florincoras 97368af
add simple echo test
florincoras 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 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 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 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 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,43 @@ | ||
#include "common/network/socket_interface.h" | ||
|
||
#include "test/integration/integration.h" | ||
#include "test/test_common/environment.h" | ||
#include "test/test_common/utility.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace Envoy { | ||
namespace { | ||
|
||
class SocketInterfaceIntegrationTest : public BaseIntegrationTest, | ||
public testing::TestWithParam<Network::Address::IpVersion> { | ||
public: | ||
SocketInterfaceIntegrationTest() : BaseIntegrationTest(GetParam(), config()) { | ||
use_lds_ = false; | ||
}; | ||
|
||
static std::string config() { | ||
// At least one empty filter chain needs to be specified. | ||
return absl::StrCat(ConfigHelper::httpProxyConfig(), R"EOF( | ||
bootstrap_extensions: | ||
- name: envoy.extensions.network.socket_interface.default_socket_interface | ||
typed_config: | ||
"@type": type.googleapis.com/envoy.extensions.network.socket_interface.v3.DefaultSocketInterface | ||
default_socket_interface: "envoy.extensions.network.socket_interface.default_socket_interface" | ||
)EOF"); | ||
} | ||
}; | ||
|
||
INSTANTIATE_TEST_SUITE_P(IpVersions, SocketInterfaceIntegrationTest, | ||
testing::ValuesIn(TestEnvironment::getIpVersionsForTest()), | ||
TestUtility::ipTestParamsToString); | ||
|
||
TEST_P(SocketInterfaceIntegrationTest, Basic) { | ||
BaseIntegrationTest::initialize(); | ||
const Network::SocketInterface* factory = Network::socketInterface( | ||
"envoy.extensions.network.socket_interface.default_socket_interface"); | ||
ASSERT_TRUE(Network::SocketInterfaceSingleton::getExisting() == factory); | ||
} | ||
|
||
} // namespace | ||
} // namespace Envoy |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be the case even if the registration didn't work? I think what I'm proposing is to define a shim extension in this integration test, and just internally have it return the default implementation, then run some very basic echo like integration test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point no. We have a static global initialization of the default
SocketInterface
done viaSocketInterfaceLoader
, aScopedInjectableLoader
. In this test, that is overridden by theconfig()
above which initializes the default interface as a bootstrap extension and uses it to reinitialize theSocketInterfaceSingleton
(done in the server init phase). We did discuss with @lizan the option to completely remove the static global initialization, but we'll have to update some tests to support that, as not all of them initialize the server. So that's now on the ever growing todo list :-) and maybe can be bundled together with the move of theSocketInterfaceSingleton
to theApi
(if that's eventually possible).As for the test, this does start a listener through the bootstrap initialized
SocketInterface
. I guess we could add something like the Hello echo test fromecho_integration_test.cc
, or were you thinking about something more complex?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK fair enough. Yeah it would be good to get rid of the scoped singleton if possible but agreed that can be done later.
Yes exactly this would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect! Done!