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

Adding tests requested in #295 #298

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

petedmarsh
Copy link
Contributor

I recent raised #295 to fix a bug, this is a bug that could have been caught with tests but no tests had been written (I wrote the original code, so it is my fault).

I've had a stab here at writing some tests for this case, they required a small amount of refactoring. I fully expect that I can improve upon them and I am happy to do so. For one thing the test file is in the main src tree rather than test as it seemed silly to me to make these functions public, but it also seems silly to have a test here.

Anyway, I am happy to improve and add more, I am raising early in the hope I can get some feedback (though I appreciate that that isn't your job to do so!).

@petedmarsh
Copy link
Contributor Author

This'll need to be rebased anyway as 361e3ed is in main under a different SHA, I will sort that out.

@mattklein123
Copy link
Member

cc @nezdolik @ysawa0 for comments.

@nezdolik
Copy link
Member

nezdolik commented Oct 5, 2021

Thanks, I will review this week.

@nezdolik
Copy link
Member

nezdolik commented Oct 8, 2021

Thank you for adding the tests! Few nits from my side, and looks like commits are missing sign-off.

@@ -205,9 +205,9 @@ func refreshServers(serverList memcache.ServerList, srv_ string) error {
return nil
}

func newMemcachedFromSrv(srv_ string, d time.Duration) Client {
func newMemcachedFromSrv(srv_ string, d time.Duration, resolver srv.SrvResolver) Client {
Copy link
Member

Choose a reason for hiding this comment

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

nit: srv_ -> srv (is not common in Go to use underscores for variable names)

Copy link
Member

Choose a reason for hiding this comment

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

and the same nit for all other occurrences in the code above and below

src/srv/srv.go Outdated
@@ -21,7 +27,7 @@ func ParseSrv(srv string) (string, string, string, error) {
return matches[1], matches[2], matches[3], nil
}

func ServerStringsFromSrv(srv string) ([]string, error) {
func (s DnsSrvResolver) ServerStringsFromSrv(srv string) ([]string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: use more descriptive var name instead of s

Copy link
Member

Choose a reason for hiding this comment

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

@petedmarsh ping on this

assert.Equal([]string{mockMemcacheHostPort}, actualMemcacheHosts)
}

func TestRefreshServerSetsServersOnNonEmptyServerList(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: i think more descriptive name this test case would be ...OverridesServersOnNonEmptyServerList

@github-actions
Copy link

github-actions bot commented Nov 7, 2021

This pull request has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in 7 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@github-actions github-actions bot added the stale label Nov 7, 2021
@petedmarsh petedmarsh force-pushed the fix-memcached-srv-tests branch 3 times, most recently from cec7fa2 to 53c19da Compare November 8, 2021 13:02
@petedmarsh
Copy link
Contributor Author

@nezdolik I have updated everything as per your comments

@github-actions github-actions bot removed the stale label Nov 8, 2021
@nezdolik
Copy link
Member

nezdolik commented Nov 9, 2021

@petedmarsh looks like one more nit left and then you can mark this PR as ready for review (instead of Draft)

Signed-off-by: Peter Marsh <pete.d.marsh@gmail.com>
@petedmarsh petedmarsh force-pushed the fix-memcached-srv-tests branch from 53c19da to c886572 Compare November 9, 2021 14:27
@petedmarsh petedmarsh marked this pull request as ready for review November 9, 2021 15:35
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.

Awesome, thanks!

@mattklein123 mattklein123 merged commit f2c9a16 into envoyproxy:main Nov 9, 2021
timcovar pushed a commit to goatapp/ratelimit that referenced this pull request Jan 16, 2024
Signed-off-by: Peter Marsh <pete.d.marsh@gmail.com>
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