Convert the Automate methods to new style using classes to facilitate testing outside the Automate Engine.
Notes:
- Each method needs to be a class under a well defined namespace
- Each method needs to have a corresponding spec using the same path as the method file.
- Most of the methods can be tested outside of the Automate Engine using
- Mock Service
- Mock Objects
- The methods should not have an exit call since that exits RSpec.
- As each method is converted we should check the box next to the item
- Look for methods which might be the same in Cloud and Infrastructure namespaces.
- @billfitzgerald0120 is working on consolidating the email methods so we should check with him before converting email methods.
- When calling the VMDB objects please ensure that they are service model objects and not the actual vmdb objects.
- Why is this necessary
if __FILE__ == $PROGRAM_NAME
MyMethodClass.new.main
end
This idea is borrowed from Python, which allows us to source in the file without executing any code. The if block gets executed only when we directly pass in the file to the ruby interpreter. When we test the method script we source in the file in the spec and then instantiate it for testing, it allows us to pass in a mock service for testing.
Good sample of a method
https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones.rb
Good sample of a spec
https://github.com/ManageIQ/manageiq-content/blob/master/spec/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones_spec.rb
In the spec the line
require_domain_file
loads the method file from the correct directory
The methods have been categorized based on different lifecycle's
- Provisioning
- Retirement
- Reconfigure/Reconfiguration
- Operations
- Migrate
ManageIQ/Cloud/Orchestration/Operations
ManageIQ/Cloud/Orchestration/Provisioning
ManageIQ/Cloud/Orchestration/Reconfiguration
ManageIQ/Cloud/Orchestration/Retirement
ManageIQ/Cloud/VM/Provisioning
ManageIQ/Cloud/VM/Retirement
ManageIQ/ConfigurationManagement/AnsibleTower/Operations
ManageIQ/ConfigurationManagement/AnsibleTower/Service/Provisioning
ManageIQ/Control/
ManageIQ/Deployment/ContainerProvider/System/
ManageIQ/Infrastructure/Cluster/Operations
ManageIQ/Infrastructure/Configured_System/Provisioning
ManageIQ/Infrastructure/Host/Operations
ManageIQ/Infrastructure/Host/Provisioning
ManageIQ/Infrastructure/VM/Migrate
ManageIQ/Infrastructure/VM/Operations
ManageIQ/Infrastructure/VM/Provisioning
ManageIQ/Infrastructure/VM/Reconfigure
ManageIQ/Infrastructure/VM/Retirement
ManageIQ/Service/Provisioning/
ManageIQ/Service/Retirement
ManageIQ/System
ManageIQ/Transformation
Convert the Automate methods to new style using classes to facilitate testing outside the Automate Engine.
Notes:
This idea is borrowed from Python, which allows us to source in the file without executing any code. The if block gets executed only when we directly pass in the file to the ruby interpreter. When we test the method script we source in the file in the spec and then instantiate it for testing, it allows us to pass in a mock service for testing.
Good sample of a method
https://github.com/ManageIQ/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones.rb
Good sample of a spec
https://github.com/ManageIQ/manageiq-content/blob/master/spec/content/automate/ManageIQ/Cloud/Orchestration/Operations/Methods.class/__methods__/available_availability_zones_spec.rb
In the spec the line
require_domain_file
loads the method file from the correct directory
The methods have been categorized based on different lifecycle's
ManageIQ/Cloud/Orchestration/Operations
ManageIQ/Cloud/Orchestration/Provisioning
ManageIQ/Cloud/Orchestration/Reconfiguration
ManageIQ/Cloud/Orchestration/Retirement
ManageIQ/Cloud/VM/Provisioning
ManageIQ/Cloud/VM/Retirement
ManageIQ/ConfigurationManagement/AnsibleTower/Operations
ManageIQ/ConfigurationManagement/AnsibleTower/Service/Provisioning
ManageIQ/Control/
ManageIQ/Deployment/ContainerProvider/System/
ManageIQ/Infrastructure/Cluster/Operations
ManageIQ/Infrastructure/Configured_System/Provisioning
ManageIQ/Infrastructure/Host/Operations
ManageIQ/Infrastructure/Host/Provisioning
ManageIQ/Infrastructure/VM/Migrate
ManageIQ/Infrastructure/VM/Operations
ManageIQ/Infrastructure/VM/Provisioning
ManageIQ/Infrastructure/VM/Reconfigure
ManageIQ/Infrastructure/VM/Retirement
ManageIQ/Service/Provisioning/
ManageIQ/Service/Retirement
ManageIQ/System
ManageIQ/Transformation