Skip to content

Commit

Permalink
Added functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-variacode committed Oct 29, 2024
1 parent 0f483bf commit b30db40
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
34 changes: 34 additions & 0 deletions functional-test/src/test/groovy/functional/YamlParsingSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package functional

import functional.base.BaseTestConfiguration
import org.testcontainers.spock.Testcontainers

@Testcontainers
class YamlParsingSpec extends BaseTestConfiguration {

static String PROJ_NAME = 'ansible-yaml-parsing'
static String NODE_1 = 'server1'
static String NODE_2 = 'server2'

def setupSpec() {
startCompose()
configureRundeck(PROJ_NAME, 'server1')
}

void "hide warnings"() {
when:
def result = client.apiCall {api-> api.listNodes(PROJ_NAME,'.*')}

then:
result != null
result.size() == 3
result.get(NODE_1) != null
result.get(NODE_1).getAttributes().get("ansible_host") == "192.168.1.10"
result.get(NODE_1).getAttributes().get("ansible_user") == "user2"
result.get(NODE_1).getAttributes().get("http_port") == "8080"
result.get(NODE_2) != null
result.get(NODE_2).getAttributes().get("ansible_host") == "192.168.1.20"
result.get(NODE_2).getAttributes().get("ansible_user") == "user3"
result.get(NODE_2).getAttributes().get("http_port") == "8080"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[defaults]
inventory=/home/rundeck/ansible-yaml-parsing/inventory_duplicate_key.yaml
interpreter_python=/usr/bin/python3



Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
all:
hosts:
server1:
ansible_host: 192.168.1.10
ansible_user: user1
# Duplicate key!
ansible_user: user2 # This will cause the warning

server2:
ansible_host: 192.168.1.20
ansible_user: user3

vars:
http_port: 80
# Another duplicate key!
http_port: 8080 # This will also cause the warning
3 changes: 2 additions & 1 deletion functional-test/src/test/resources/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ services:
networks:
- rundeck
ports:
- "4440"
- "4440:4440"
volumes:
- ./ansible:/home/rundeck/ansible:rw
- ./ansible-list:/home/rundeck/ansible-list:rw
- ./ansible-yaml-parsing:/home/rundeck/ansible-yaml-parsing:rw

volumes:
rundeck-data:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
by:
urn: project:ansible-yaml-parsing
for:
storage:
- match:
path: 'keys/.*'
allow: [read]
description: Allow access to key storage
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#edit below
project.disable.executions=false
project.disable.schedule=false
project.execution.history.cleanup.batch=500
project.execution.history.cleanup.enabled=false
project.execution.history.cleanup.retention.days=60
project.execution.history.cleanup.retention.minimum=50
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
project.jobs.gui.groupExpandLevel=1
project.later.executions.disable.value=0
project.later.executions.disable=false
project.later.executions.enable.value=
project.later.executions.enable=false
project.later.schedule.disable.value=
project.later.schedule.disable=false
project.later.schedule.enable.value=
project.later.schedule.enable=false
project.name=ansible-yaml-parsing
project.nodeCache.enabled=false
project.nodeCache.firstLoadSynch=true
project.output.allowUnsanitized=false
project.retry-counter=3
project.ssh-authentication=privateKey
resources.source.1.type=local
resources.source.2.config.ansible-config-file-path=/home/rundeck/ansible-yaml-parsing/ansible.cfg
resources.source.2.config.ansible-gather-facts=false
resources.source.2.config.ansible-ignore-errors=true
resources.source.2.config.ansible-inventory=/home/rundeck/ansible-yaml-parsing/inventory_duplicate_key.yaml
resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
service.FileCopier.default.provider=sshj-scp
service.NodeExecutor.default.provider=sshj-ssh

0 comments on commit b30db40

Please sign in to comment.