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

listener: add socket api in os sys calls for additional tests #3968

Merged
merged 5 commits into from
Jul 31, 2018

Conversation

ramaraochavali
Copy link
Contributor

Signed-off-by: Rama rama.rao@salesforce.com

Description:
Adds additional test cases for #3912
Add socket api in os sys calls
Risk Level: Low
Testing: Automated tests
Docs Changes: N/A
Release Notes: N/A

Signed-off-by: Rama <rama.rao@salesforce.com>
Signed-off-by: Rama <rama.rao@salesforce.com>
@ramaraochavali
Copy link
Contributor Author

@ggreenway added tests as discussed in #3912. PTAL.

Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Thanks for writing the tests!

It would be great to also have similar tests for listening on an ipv6 address.

NiceMock<Api::MockOsSysCalls> os_sys_calls;
TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls(&os_sys_calls);

ON_CALL(os_sys_calls, socket(AF_INET6, _, 0)).WillByDefault(Return(-1));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be EXPECT_CALL

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, please add an explicit EXPECT_CALL for AF_INET, that returns >= 0.

EXPECT_CALL(*listener_foo, onDestroy());
}

// Make sure that a listener is created on IPv6 ony setups.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: only

NiceMock<Api::MockOsSysCalls> os_sys_calls;
TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls(&os_sys_calls);

ON_CALL(os_sys_calls, socket(AF_INET, _, 0)).WillByDefault(Return(-1));
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments as previous test

ListenerHandle* listener_foo = expectListenerCreate(false);
EXPECT_CALL(listener_factory_, createListenSocket(_, _, true));

EXPECT_TRUE(manager_->addOrUpdateListener(parseListenerFromJson(listener_foo_json), "", true));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this fail? The address is ipv4, and this test doesn't support ipv4.

Copy link
Contributor Author

@ramaraochavali ramaraochavali Jul 28, 2018

Choose a reason for hiding this comment

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

I should have clarified, I am not testing the "actual" listener creation functionality here, it may fail in the actual setup. But my focus was to test convertDestinationIPsMapToTrie function does not throw exceptions and thus cause listener creation failure of there are no filterMatches defined. I will add this commentary on the test.
Probably that should be validated in the ListenerImpl creation it self. So to your other comment about adding ipv6 address tests does not help.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I understand better now.

I still think this test case is odd, because this configuration is not supposed to work. I understand that the test still succeeds because it doesn't complete the creation of the listener, but I think it would be better for this one if you change the listener address in the config snippet to a v6 address.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. Changed, Please check

@ggreenway ggreenway self-assigned this Jul 27, 2018
Signed-off-by: Rama <rama.rao@salesforce.com>
Signed-off-by: Rama <rama.rao@salesforce.com>
Signed-off-by: Rama <rama.rao@salesforce.com>
Copy link
Contributor

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks!

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

nice

@mattklein123 mattklein123 merged commit b27068b into envoyproxy:master Jul 31, 2018
@ramaraochavali ramaraochavali deleted the fix/test_cases branch August 1, 2018 03:40
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.

3 participants