-
Notifications
You must be signed in to change notification settings - Fork 303
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
Add more unit tests for transaction syncer #619
Conversation
80dcf37
to
168fe3e
Compare
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.
minor nits
pkg/neg/syncers/transaction.go
Outdated
syncer.SetSyncFunc(ts.sync) | ||
// Syncer implements life cycle logic | ||
syncer := newSyncer(negSyncerKey, networkEndpointGroupName, serviceLister, recorder, ts) | ||
// TransactionSyncer needs syncer interface for internals |
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.
[minor] isn't transactionSyncer lowercase
pkg/neg/syncers/transaction.go
Outdated
@@ -285,7 +287,7 @@ func (s *transactionSyncer) commitTransaction(err error, networkEndpointMap map[ | |||
for encodedEndpoint := range networkEndpointMap { | |||
entry, ok := s.transactions.Get(encodedEndpoint) | |||
if !ok { | |||
glog.Errorf("Endpoint %q was not found in the transaction table.") | |||
glog.Errorf("Endpoint %q was not found in the transaction table. This is unexpected", encodedEndpoint) |
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 unexpected" probably not needed (you are already logging an Errorf
@@ -44,6 +49,293 @@ const ( | |||
testService = "svc" | |||
) | |||
|
|||
func TestTransactionSyncNetworkEndpoints(t *testing.T) { | |||
fakeGCECloud := gce.FakeGCECloud(gce.DefaultTestClusterValues()) |
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() if possible
} | ||
|
||
func TestCommitTransaction(t *testing.T) { | ||
s, transactionSyncer := newTestTransactionSyncer(gce.FakeGCECloud(gce.DefaultTestClusterValues())) |
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()
pkg/neg/syncers/transaction_test.go
Outdated
} | ||
|
||
func (s *testSyncer) Sync() bool { | ||
s.SyncCount += 1 |
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.
++
pkg/neg/types/mock.go
Outdated
type NetworkEndpointStore map[meta.Key][]NetworkEndpointEntry | ||
|
||
func MockNetworkEndpointAPIs(fakeGCE *gce.GCECloud) { | ||
(fakeGCE.Compute().(*cloud.MockGCE)).MockBetaNetworkEndpointGroups.X = NetworkEndpointStore{} |
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.
probably shorter to
m := (fakeGCE.Compute().(*cloud.MockGCE)
m.MockBeta... = ...
...
Fixed the comments |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bowei, freehan 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 |
No description provided.