Skip to content

Commit 74b41ff

Browse files
Added functional test
1 parent 2015c1f commit 74b41ff

File tree

6 files changed

+118
-0
lines changed

6 files changed

+118
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package functional
2+
3+
import functional.base.BaseTestConfiguration
4+
import org.testcontainers.spock.Testcontainers
5+
6+
@Testcontainers
7+
class ChildGroupsSpec extends BaseTestConfiguration {
8+
9+
static String NODENAME = 'nodename'
10+
static String HOSTNAME = 'hostname'
11+
static String TAGS = 'tags'
12+
static String PROJ_NAME = 'ansible-child-groups'
13+
static String NODE_1 = 'one.example.com'
14+
static String TAGS_1 = 'dbservers, east, prod'
15+
static String NODE_2 = 'three.example.com'
16+
static String TAGS_2 = 'dbservers, test, west'
17+
static String NODE_3 = 'mail.example.com'
18+
static String TAGS_3 = 'ungrouped'
19+
20+
def setupSpec() {
21+
startCompose()
22+
configureRundeck(PROJ_NAME, NODE_1)
23+
}
24+
25+
void "child groups"() {
26+
when:
27+
def result = client.apiCall {api-> api.listNodes(PROJ_NAME,'.*')}
28+
29+
then:
30+
result != null
31+
result.size() == 7
32+
result.get(NODE_1) != null
33+
result.get(NODE_1).getAttributes().get(NODENAME) == NODE_1
34+
result.get(NODE_1).getAttributes().get(HOSTNAME) == NODE_1
35+
result.get(NODE_1).getAttributes().get(TAGS) == TAGS_1
36+
result.get(NODE_2) != null
37+
result.get(NODE_2).getAttributes().get(NODENAME) == NODE_2
38+
result.get(NODE_2).getAttributes().get(HOSTNAME) == NODE_2
39+
result.get(NODE_2).getAttributes().get(TAGS) == TAGS_2
40+
result.get(NODE_3) != null
41+
result.get(NODE_3).getAttributes().get(NODENAME) == NODE_3
42+
result.get(NODE_3).getAttributes().get(HOSTNAME) == NODE_3
43+
result.get(NODE_3).getAttributes().get(TAGS) == TAGS_3
44+
}
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[defaults]
2+
inventory=/home/rundeck/ansible-child-groups/inventory_child.yaml
3+
interpreter_python=/usr/bin/python3
4+
5+
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
ungrouped:
2+
hosts:
3+
mail.example.com:
4+
webservers:
5+
hosts:
6+
foo.example.com:
7+
bar.example.com:
8+
dbservers:
9+
hosts:
10+
one.example.com:
11+
two.example.com:
12+
three.example.com:
13+
east:
14+
hosts:
15+
foo.example.com:
16+
one.example.com:
17+
two.example.com:
18+
west:
19+
hosts:
20+
bar.example.com:
21+
three.example.com:
22+
prod:
23+
children:
24+
east:
25+
test:
26+
children:
27+
west:

functional-test/src/test/resources/docker/docker-compose.yml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ services:
3535
- ./ansible:/home/rundeck/ansible:rw
3636
- ./ansible-list:/home/rundeck/ansible-list:rw
3737
- ./ansible-yaml-parsing:/home/rundeck/ansible-yaml-parsing:rw
38+
- ./ansible-child-groups:/home/rundeck/ansible-child-groups:rw
3839

3940
volumes:
4041
rundeck-data:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
by:
2+
urn: project:ansible-yaml-parsing
3+
for:
4+
storage:
5+
- match:
6+
path: 'keys/.*'
7+
allow: [read]
8+
description: Allow access to key storage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#edit below
2+
project.disable.executions=false
3+
project.disable.schedule=false
4+
project.execution.history.cleanup.batch=500
5+
project.execution.history.cleanup.enabled=false
6+
project.execution.history.cleanup.retention.days=60
7+
project.execution.history.cleanup.retention.minimum=50
8+
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
9+
project.jobs.gui.groupExpandLevel=1
10+
project.later.executions.disable.value=0
11+
project.later.executions.disable=false
12+
project.later.executions.enable.value=
13+
project.later.executions.enable=false
14+
project.later.schedule.disable.value=
15+
project.later.schedule.disable=false
16+
project.later.schedule.enable.value=
17+
project.later.schedule.enable=false
18+
project.name=ansible-yaml-parsing
19+
project.nodeCache.enabled=false
20+
project.nodeCache.firstLoadSynch=true
21+
project.output.allowUnsanitized=false
22+
project.retry-counter=3
23+
project.ssh-authentication=privateKey
24+
resources.source.1.type=local
25+
resources.source.2.config.ansible-config-file-path=/home/rundeck/ansible-child-groups/ansible.cfg
26+
resources.source.2.config.ansible-gather-facts=false
27+
resources.source.2.config.ansible-ignore-errors=true
28+
resources.source.2.config.ansible-inventory=/home/rundeck/ansible-child-groups/inventory_child.yaml
29+
resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
30+
service.FileCopier.default.provider=sshj-scp
31+
service.NodeExecutor.default.provider=sshj-ssh

0 commit comments

Comments
 (0)