-
Notifications
You must be signed in to change notification settings - Fork 25
Ovalenti/rox 29399 directional ext i ps jv 2 #2142
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
base: master
Are you sure you want to change the base?
Conversation
@@ -155,4 +156,95 @@ TEST(CollectorConfigTest, TestEnableExternalIpsRuntimeConfig) { | |||
EXPECT_TRUE(config.ExternalIPsConf().IsEnabled(Direction::BOTH)); | |||
} | |||
|
|||
TEST(CollectorConfigTest, TestIsEnabledIngress) { |
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.
These tests could all be done in one test in a loop.
@@ -11,7 +11,7 @@ namespace collector { | |||
class ExternalIPsConfig { | |||
public: | |||
enum Direction { | |||
NONE = 0, | |||
NONE = 1 << 2, |
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.
I think it makes more sense to change IsEnabled
like this:
bool IsEnabled(Direction direction) const { return direction != Direction::None && (direction & direction_enabled_) == direction; }
On a different note, I don't think IsEnabled(Direction::NONE)
is something anyone would write, so I'm not convinced the extra overhead for the check is worth it. Maybe we can do a static check instead?
bool IsEnabled(Direction direction) const {
static_assert(direction != Direction::NONE);
return (direction & direction_enabled_) == direction;
}
Or, if a compile time check is not possible, then just use good old assert
to make the invariant explicit.
bool IsEnabled(Direction direction) const {
assert(direction != Direction::NONE);
return (direction & direction_enabled_) == direction;
}
Description
Fixes a problem where
IsEnabled(Direction::NONE)
always returns true.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
CI is sufficient.