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

Better tests for credential validator worker. #8594

Merged
merged 2 commits into from
Apr 16, 2018

Conversation

anastasiamac
Copy link
Contributor

Description of change

Based on review comments in PR #8586, this PR improves credential validator worker tests:

  • in worker pkg itself - watcher is constructed deterministically and sends definitive changes; added compliant StartStop test;
  • in cmd/jujud/agent pkg - only models with cloud credential are expected to have a credential validator worker.

QA steps

Internal change so all unit tests are expected to pass.

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

I like the improved tests.

worker, err := testWorker(s.config)
c.Assert(err, jc.ErrorIsNil)

s.sendChange(c)
Copy link
Member

Choose a reason for hiding this comment

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

Is the first change needed? This should still pass with exists=false followed by sendChange()?
Same comment for other test cases below.

@anastasiamac
Copy link
Contributor Author

So according to the testing, I had to add that additional change tot he watched channel as .Add(ing) watcher to the catacomb in a Work method (here, the loop()) consumed a change. To avoid this additional gobbling up, the watcher need to be added to the catacomb before the Plan.Work method, i.e. using Plan.Init in the worker constructor. Doing so did not consume an additional change. However, it did tie the watcher to the lifecycle of the worker and destroyed it when the worker was destroyed.

@anastasiamac
Copy link
Contributor Author

$$merge$$

@jujubot jujubot merged commit ca82ad6 into juju:develop Apr 16, 2018
@anastasiamac anastasiamac deleted the test-improvement-for-cred-worker branch April 16, 2018 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants