Skip to content

[ca/dispatcher]: Use the mock proposer in the test CA memory store#2097

Merged
cyli merged 1 commit into
moby:masterfrom
cyli:use-mock-proposer-in-testca-store
Apr 6, 2017
Merged

[ca/dispatcher]: Use the mock proposer in the test CA memory store#2097
cyli merged 1 commit into
moby:masterfrom
cyli:use-mock-proposer-in-testca-store

Conversation

@cyli
Copy link
Copy Markdown
Contributor

@cyli cyli commented Apr 6, 2017

This way during tests we can make sure there are no conflicts when updating a store from multiple goroutines simultaneously.

cc @aaronlehmann

@cyli cyli changed the title [ca/dispatcher]:; Use the mock proposer in the test CA memory store [ca/dispatcher]: Use the mock proposer in the test CA memory store Apr 6, 2017
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2017

Codecov Report

Merging #2097 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2097      +/-   ##
==========================================
- Coverage   57.24%   57.22%   -0.03%     
==========================================
  Files         117      117              
  Lines       20128    20124       -4     
==========================================
- Hits        11522    11515       -7     
+ Misses       7279     7274       -5     
- Partials     1327     1335       +8

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3bc480...e1f9b0c. Read the comment docs.

Comment thread manager/dispatcher/dispatcher_test.go Outdated

})
assert.NoError(t, err)
assert.NoError(t, testutils.PollFuncWithTimeout(nil, func() error {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Using PollFuncWithTimeout doesn't seem right here. What temporary error condition is it protecting against?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The intention was to prevent a mismatched version number, I guess in case something updates one of the tasks in between the get and update.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not possible - Only one Update can run at a time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah right, I forgot there's no real agent here that updates the task status

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Even if there was, it would not be able to change the task status in betweenthe GetTask and the UpdateTask. Update transactions are atomic because they take an update lock on the store.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have removed the polls - PTAL

@cyli cyli force-pushed the use-mock-proposer-in-testca-store branch from 587fda9 to eef27d1 Compare April 6, 2017 01:08
@aaronlehmann
Copy link
Copy Markdown
Collaborator

I noticed there are a few places that wrap the context using WithCancel, but don't seem to use the cancel function except at the end of the test. Could these be simplified back to using context.Background() directly?

Comment thread manager/dispatcher/dispatcher_test.go Outdated
recvChan <- struct{}{}
select {
case recvChan <- struct{}{}:
case <-ctx.Done():
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What would cause this case to be reached?

@cyli cyli force-pushed the use-mock-proposer-in-testca-store branch from eef27d1 to e1f9b0c Compare April 6, 2017 19:03
…e when updating during

the tests that there are no conflicts.

Signed-off-by: cyli <ying.li@docker.com>
@cyli
Copy link
Copy Markdown
Contributor Author

cyli commented Apr 6, 2017

Could these be simplified back to using context.Background() directly?

@aaronlehmann Reverted those changes :) Thanks!

@aaronlehmann
Copy link
Copy Markdown
Collaborator

LGTM

@cyli cyli merged commit 14c1727 into moby:master Apr 6, 2017
@cyli cyli deleted the use-mock-proposer-in-testca-store branch April 6, 2017 21:35
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.

2 participants