-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #343 from rundeck-plugins/rse808-error-handler-not…
…triggered-on-ansible-inlineplaybookstep RSE-824: Fix: Error handler not working as expected with Ansible Node Step
- Loading branch information
Showing
3 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...roovy/com/rundeck/plugins/ansible/plugin/AnsiblePlaybookInlineWorkflowNodeStepSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.rundeck.plugins.ansible.plugin | ||
|
||
import com.dtolabs.rundeck.core.common.Framework | ||
import com.dtolabs.rundeck.core.common.INodeEntry | ||
import com.dtolabs.rundeck.core.common.INodeSet | ||
import com.dtolabs.rundeck.core.execution.ExecutionContext | ||
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException | ||
import com.dtolabs.rundeck.plugins.step.NodeStepPlugin | ||
import com.dtolabs.rundeck.plugins.step.PluginStepContext | ||
import org.junit.jupiter.api.Assertions | ||
import spock.lang.Specification | ||
|
||
|
||
class AnsiblePlaybookInlineWorkflowNodeStepSpec extends Specification{ | ||
|
||
void "failure data should not include null values when throwing"(){ | ||
given: | ||
NodeStepPlugin plugin = new AnsiblePlaybookInlineWorkflowNodeStep() | ||
INodeEntry node = Mock(INodeEntry){ | ||
getNodename() >> 'localhost' | ||
} | ||
|
||
PluginStepContext context = Mock(PluginStepContext){ | ||
getDataContext() >> ['job': ['loglevel':'INFO']] | ||
getExecutionContext() >> Mock(ExecutionContext){ | ||
getDataContext() >> [:] | ||
} | ||
getFramework() >> Mock(Framework) | ||
getNodes() >> Mock(INodeSet){ | ||
getNodes() >> [] | ||
} | ||
} | ||
|
||
Map<String, Object> configuration = [ | ||
'ansible-playbook' : 'path/to/playbook' | ||
] | ||
|
||
when: | ||
plugin.executeNodeStep(context, configuration, node) | ||
|
||
then: | ||
NodeStepException e = thrown(NodeStepException) | ||
e.getFailureData().each { String key, Object value -> | ||
Assertions.assertNotNull(value, "Value for key ${key} should not be null") | ||
} | ||
} | ||
} |