jenkins_job: add integration tests (#17499)

This commit is contained in:
René Moser 2016-09-13 16:03:58 +02:00 committed by GitHub
parent 4f177e623e
commit 6a3e948a7c
5 changed files with 204 additions and 0 deletions

View file

@ -272,6 +272,11 @@ exoscale:
RC=$$? ; \
exit $$RC;
jenkins:
ansible-playbook jenkins.yml -i $(INVENTORY) -e @$(VARS_FILE) -v $(TEST_FLAGS) ; \
RC=$$? ; \
exit $$RC;
cloudflare: $(CREDENTIALS_FILE)
ansible-playbook cloudflare.yml -i $(INVENTORY) -e @$(VARS_FILE) -e @$(CREDENTIALS_FILE) -e "resource_prefix=$(CLOUD_RESOURCE_PREFIX)" -v $(TEST_FLAGS) ; \
RC=$$? ; \

View file

@ -0,0 +1,8 @@
---
- hosts: localhost
connection: local
gather_facts: no
tags:
- jenkins
roles:
- test_jenkins_job

View file

@ -0,0 +1,5 @@
---
jenkins_url: http://localhost:8080
jenkins_user: admin
jenkins_password: ""
jenkins_days_to_keep: 20

View file

@ -0,0 +1,157 @@
---
- name: setup
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result|success
- name: test create a job
local_action:
module: jenkins_job
config: "{{ lookup('template', 'config.xml.j2') }}"
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
register: result
- name: verify test create a job
assert:
that:
- result|success
- result|changed
- result.enabled
- name: test create a job idempotence
local_action:
module: jenkins_job
config: "{{ lookup('template', 'config.xml.j2') }}"
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
register: result
- name: verify test create a job idempotence
assert:
that:
- result|success
- not result|changed
- result.enabled
- name: test create a enabled job idempotence
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
enabled: true
register: result
- name: verify test create a enabled job idempotence
assert:
that:
- result|success
- not result|changed
- result.enabled
- name: test update a job
local_action:
module: jenkins_job
config: "{{ lookup('template', 'config.xml.j2') }}"
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
register: result
vars:
jenkins_days_to_keep: 10
- name: verify test create a enabled job idempotence
assert:
that:
- result|success
- result|changed
- result.enabled
- name: test disable an exising job without config
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
enabled: false
register: result
- name: verify test disable an exising job without config
assert:
that:
- result|success
- result|changed
- not result.enabled
- name: test disable an exising job without config idempotence
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
enabled: false
register: result
- name: verify test disable an exising job without config idempotence
assert:
that:
- result|success
- not result|changed
- not result.enabled
- name: test reset to config job
local_action:
module: jenkins_job
config: "{{ lookup('template', 'config.xml.j2') }}"
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
register: result
- name: verify test reset to config job
assert:
that:
- result|success
- result|changed
- name: test remove job
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
state: absent
register: result
- name: verify test remove job
assert:
that:
- result|success
- result|changed
- name: test remove job idempotence
local_action:
module: jenkins_job
name: test.job
url: "{{ jenkins_url }}"
user: "{{ jenkins_user }}"
password: "{{ jenkins_password }}"
state: absent
register: result
- name: verify test remove job idempotence
assert:
that:
- result|success
- not result|changed

View file

@ -0,0 +1,29 @@
<?xml version='1.0' encoding='UTF-8'?>
<project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<jenkins.model.BuildDiscarderProperty>
<strategy class="hudson.tasks.LogRotator">
<daysToKeep>{{ jenkins_days_to_keep }}</daysToKeep>
<numToKeep>20</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</strategy>
</jenkins.model.BuildDiscarderProperty>
<org.jenkinsci.plugins.gitbucket.GitBucketProjectProperty plugin="gitbucket@0.8">
<linkEnabled>false</linkEnabled>
</org.jenkinsci.plugins.gitbucket.GitBucketProjectProperty>
</properties>
<scm class="hudson.scm.NullSCM"/>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers/>
<buildWrappers/>
</project>