-
Notifications
You must be signed in to change notification settings - Fork 301
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
Follow up on Readiness Reflector #774
Conversation
freehan
commented
Jun 14, 2019
- minor bug fixes
- add tons of unit tests.
/lgtm |
) | ||
|
||
const ( | ||
ClusterID = "clusterid" | ||
|
||
namespace1 = "ns1" |
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.
This is personal preference but it may be better to just inline these values per test. It makes it slightly easier so that you don't have to go back to the top of the file to figure out what the value is.
If its too much work to inline, don't worry about it.
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.
It changes too much stuff. Probably I will just do it next time.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, rramkumar1 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
// This function effectively removes duplicate port with different readiness gate flag if the rest of the field in port info is the same. | ||
func filterPort(p1, p2 negtypes.PortInfoMap) { | ||
for port, portInfo1 := range p1 { | ||
if portInfo2, ok := p2[port]; ok { |
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.
portInfo2, ok := p2[port]
if !ok { continue }
|
||
// filterPort removes duplicate ports in p1 and p2 if the corresponding port info has the same target port and neg name. | ||
// This function effectively removes duplicate port with different readiness gate flag if the rest of the field in port info is the same. | ||
func filterPort(p1, p2 negtypes.PortInfoMap) { |
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.
This is very non-descriptive function name.
removeCommonPorts
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.
where is the unit test for this
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.
hmmmmmmm. forgot to write a test for this. adding
}, | ||
}, | ||
} | ||
manager := NewTestSyncerManager(fake.NewSimpleClientset()) | ||
namer := manager.namer | ||
|
||
for _, tc := range testCases { | ||
if tc.stop { |
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.
use t.Run so you don't have to include tc.desc in all of your errors
} | ||
|
||
for _, tc := range testCases { | ||
ret := manager.ReadinessGateEnabledNegs(tc.namespace, tc.labels) |
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.
t.Run
} | ||
|
||
for _, tc := range testCases { | ||
if manager.ReadinessGateEnabled(tc.key) != tc.expect { |
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.
t.Run
} | ||
|
||
func TestPollerEndpointRegistrationAndScanForWork(t *testing.T) { | ||
poller := newFakePoller() |
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.
t.Parallel
expectEndpointCount: 0, | ||
}, | ||
} { | ||
tc.mutateState() |
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.
t.Run
} | ||
|
||
func TestSyncPod(t *testing.T) { | ||
fakeContext := fakeContext() |
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.
t.Parallel()
}, | ||
}, | ||
} { | ||
tc.mutateState() |
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.
t.Run()
What are we getting for test coverage with these tests? |
|