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

Add more unit tests for transaction syncer #619

Merged
merged 3 commits into from
Feb 15, 2019

Conversation

freehan
Copy link
Contributor

@freehan freehan commented Jan 28, 2019

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 28, 2019
@freehan freehan force-pushed the unit-test branch 3 times, most recently from 80dcf37 to 168fe3e Compare January 28, 2019 20:20
Copy link
Member

@bowei bowei left a comment

Choose a reason for hiding this comment

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

minor nits

syncer.SetSyncFunc(ts.sync)
// Syncer implements life cycle logic
syncer := newSyncer(negSyncerKey, networkEndpointGroupName, serviceLister, recorder, ts)
// TransactionSyncer needs syncer interface for internals
Copy link
Member

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

@@ -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)
Copy link
Member

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())
Copy link
Member

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()))
Copy link
Member

Choose a reason for hiding this comment

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

t.Parallel()

}

func (s *testSyncer) Sync() bool {
s.SyncCount += 1
Copy link
Member

Choose a reason for hiding this comment

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

++

type NetworkEndpointStore map[meta.Key][]NetworkEndpointEntry

func MockNetworkEndpointAPIs(fakeGCE *gce.GCECloud) {
(fakeGCE.Compute().(*cloud.MockGCE)).MockBetaNetworkEndpointGroups.X = NetworkEndpointStore{}
Copy link
Member

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... = ...
...

@freehan
Copy link
Contributor Author

freehan commented Feb 4, 2019

Fixed the comments

@bowei
Copy link
Member

bowei commented Feb 15, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 9683255 into kubernetes:master Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants