Skip to content

Commit

Permalink
Issue #2 Adding tests for error handling use case
Browse files Browse the repository at this point in the history
  • Loading branch information
tmullender committed Oct 27, 2014
1 parent 511588a commit 5627a9e
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/it/error-handling-ansible-fail/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
invoker.failureBehavior = fail-at-end
invoker.buildResult = failure
38 changes: 38 additions & 0 deletions src/it/error-handling-ansible-fail/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>co.escapeideas.maven.it</groupId>
<artifactId>error-handling-ansible</artifactId>
<version>1.0-SNAPSHOT</version>

<description>An IT verifying the error handling use case.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>simple</id>
<phase>pre-integration-test</phase>
<goals>
<goal>ansible</goal>
</goals>
<configuration>
<connection>ERROR</connection>
<failOnAnsibleError>true</failOnAnsibleError>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
4 changes: 4 additions & 0 deletions src/it/error-handling-ansible-fail/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
String output = new File( basedir, "build.log" ).text;

assert output =~ "ERROR: ansible -c ERROR -m ping localhost"
assert output =~ "Non-zero exit status returned"
2 changes: 2 additions & 0 deletions src/it/error-handling-ansible-playbook/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[all]
dummy ansible_host=localhost
5 changes: 5 additions & 0 deletions src/it/error-handling-ansible-playbook/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all
tasks:
- name: Touch file
command: "touch {{ root }}/touch.txt"
37 changes: 37 additions & 0 deletions src/it/error-handling-ansible-playbook/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>co.escapeideas.maven.it</groupId>
<artifactId>error-handling-ansible-playbook</artifactId>
<version>1.0-SNAPSHOT</version>

<description>An IT verifying the error handling use case.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>simple</id>
<phase>pre-integration-test</phase>
<goals>
<goal>playbook</goal>
</goals>
<configuration>
<connection>ERROR</connection>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
3 changes: 3 additions & 0 deletions src/it/error-handling-ansible-playbook/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
String output = new File( basedir, "build.log" ).text;

assert output =~ "ERROR: ansible-playbook -c ERROR .*/playbook.yml"
8 changes: 7 additions & 1 deletion src/test/resources/ansible
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash

echo "ansible $@" > output
if [ "$2" == "ERROR" ]
then
>&2 echo "ERROR: ansible $@"
exit 1
else
echo "ansible $@" > output
fi
8 changes: 7 additions & 1 deletion src/test/resources/ansible-playbook
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/bin/bash

echo "ansible-playbook $@" > output
if [ "$2" == "ERROR" ]
then
>&2 echo "ERROR: ansible-playbook $@"
exit 1
else
echo "ansible-playbook $@" > output
fi

0 comments on commit 5627a9e

Please sign in to comment.