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

XenServer: Initial commit for xenserver_guest module unit tests #56242

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
2 participants
@bvitnik
Copy link
Contributor

commented May 8, 2019

  • xenserver_guest module: implemented full suite of unit tests.
  • FakeXenAPI lib: greatly extended to support loading and manipulation of
    XenAPI DB sample data thus reducing a number of explicit mocks needed.
  • xenserver_guest_facts module: unit tests refactored and ported to new
    FakeXenAPI.
  • xenserver_guest_powerstate module: unit tests refactored and ported to
    new FakeXenAPI.
SUMMARY

Initial commit for xenserver_guest module unit tests and refactoring of unit tests for xenserver_guest_facts and xenserver_guest_powerstate modules.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

xenserver_guest
xenserver_guest_facts
xenserver_guest_powerstate

ADDITIONAL INFORMATION

Since xenserver_guest is using a large number of XenAPI methods, mocking all of them individually and keeping track of data manipulation proved to be very hard to do. Mocking any XenAPI method itself is hard to do because of the way method calls are implemented in XenAPI library. They are implemented by dynamically resolving call stack (XenAPI class hierarchy) and instantiating callable objects along the way. Unlike xenserver_guest_facts and xenserver_guest_powerstate modules, for xenserver_guest module I needed a better solution. What I ended up with was to greatly extend FakeXenAPI library to support loading and manipulation of XenAPI DB sample data (kept in .json files). All needed XenAPI methods are implemented directly in FakeXenAPI library where they manipulate in-memory XenAPI DB data, valid during the lifetime of a test function. This way I almost entirely removed mocks. Some mocking is still done but usually mocks are used to wrap functions and keep track of their calls. Unit tests for xenserver_guest_facts and xenserver_guest_powerstate modules were then ported to this new FakeXenAPI library thus greatly reducing the number of mocks, simplifying test functions and producing better coverage.

I understand that some tests now look almost like integration tests but since there is no XenServer simulator and using real XenServer for integration tests would be hard or impossible to do, this is the next best thing.

XenServer: Initial commit for xenserver_guest module unit tests
 - xenserver_guest module: implemented full suite of unit tests.
 - FakeXenAPI lib: greatly extended to support loading and manipulation of
   XenAPI DB sample data thus reducing a number of explicit mocks needed.
 - xenserver_guest_facts module: unit tests refactored and ported to new
   FakeXenAPI.
 - xenserver_guest_powerstate module: unit tests refactored and ported to
   new FakeXenAPI.
@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

@bvitnik This PR was evaluated as a potentially problematic PR for the following reasons:

  • More than 50 changed files.

Such PR can only be merged by human. Contact a Core team member to review this PR on IRC: #ansible-devel on irc.freenode.net

click here for bot help

@bvitnik

This comment has been minimized.

Copy link
Contributor Author

commented May 8, 2019

bot_status

@ansibot

This comment has been minimized.

Copy link
Contributor

commented May 9, 2019

Components
Metadata

waiting_on: maintainer
changes_requested_by: null
needs_info: False
needs_revision: False
needs_rebase: False
merge_commits: []
too many files or commits: True
mergeable_state: clean
shippable_status: success
maintainer_shipits (module maintainers): 0
community_shipits (namespace maintainers): 0
ansible_shipits (core team members): 0
shipit_actors (maintainer or core team member): []
shipit_actors_other: []
automerge: automerge shipit test failed

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.