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

Container Setup Test Rewrite With Mocks #9260

Merged
merged 13 commits into from Sep 27, 2018

Conversation

manadart
Copy link
Member

@manadart manadart commented Sep 27, 2018

Description of change

The ContainerSetupSuite tests previously used JujuConnSuite and were racy.

This patch rectifies this with the following changes:

  • JujuConnSuite is no longer used. All dependencies are mocked.
  • Some tests were removed that were tautological or that effectively tested functionality from other modules.
  • Some mocks that were previously located close to their usage have been moved to more general locations, which necessitates some edits to code not directly related to container setup.
  • Error traces have been added to places where they were previously absent in the course of debugging.

Note for Reviewers: worker/provisioner/container_initialisation_test.go bears little resemblance to its old form. It might be better than to read this in its own right rather than the diff.

QA steps

The re-written tests pass consistently.

Documentation changes

None.

Bug reference

N/A

@manadart
Copy link
Member Author

@@ -16,7 +16,7 @@ import (

// NewContainerManager creates the appropriate container.Manager for the
// specified container type.
func NewContainerManager(forType instance.ContainerType, conf container.ManagerConfig) (container.Manager, error) {
var NewContainerManager = func(forType instance.ContainerType, conf container.ManagerConfig) (container.Manager, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm still not a huge fan of this, I'd rather we didn't patch these at test time, but considering the changes required to make this a dependency I'm all for this atm.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I don't like calls to patch at all.

If we lived in an ideal world, all these factory-type dependencies would be injected at the top, through the manifold by the dependency engine. Then at worker creation you could pass in a mock by its indirection.

Rolling it all back up would be a hell of a job though.

@manadart
Copy link
Member Author

Check job looks like an intermittent failure. Let's try a $$merge$$.

@jujubot jujubot merged commit ae0f643 into juju:develop Sep 27, 2018
@manadart manadart deleted the container-provisioner-testing branch September 27, 2018 15:02
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