jenkins_job: add integration tests (#17499)
This commit is contained in:
parent
4f177e623e
commit
6a3e948a7c
5 changed files with 204 additions and 0 deletions
|
@ -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=$$? ; \
|
||||
|
|
8
test/integration/jenkins.yml
Normal file
8
test/integration/jenkins.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tags:
|
||||
- jenkins
|
||||
roles:
|
||||
- test_jenkins_job
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
jenkins_url: http://localhost:8080
|
||||
jenkins_user: admin
|
||||
jenkins_password: ""
|
||||
jenkins_days_to_keep: 20
|
157
test/integration/roles/test_jenkins_job/tasks/main.yml
Normal file
157
test/integration/roles/test_jenkins_job/tasks/main.yml
Normal 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
|
|
@ -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>
|
Loading…
Reference in a new issue