From 1b7915f8516adb6c269a51c994ccac1a339c163c Mon Sep 17 00:00:00 2001 From: Alexander Abarca Date: Wed, 20 Nov 2024 11:42:06 -0300 Subject: [PATCH] Added functional test --- .../groovy/functional/MaxAliasesSpec.groovy | 39 +++++++++++++++++++ .../docker/ansible-max-aliases/ansible.cfg | 6 +++ .../inventory_max_aliases.ini | 14 +++++++ .../test/resources/docker/docker-compose.yml | 1 + .../files/acls/node-acl.aclpolicy | 8 ++++ .../files/etc/project.properties | 32 +++++++++++++++ 6 files changed, 100 insertions(+) create mode 100644 functional-test/src/test/groovy/functional/MaxAliasesSpec.groovy create mode 100644 functional-test/src/test/resources/docker/ansible-max-aliases/ansible.cfg create mode 100644 functional-test/src/test/resources/docker/ansible-max-aliases/inventory_max_aliases.ini create mode 100644 functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/acls/node-acl.aclpolicy create mode 100644 functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/etc/project.properties diff --git a/functional-test/src/test/groovy/functional/MaxAliasesSpec.groovy b/functional-test/src/test/groovy/functional/MaxAliasesSpec.groovy new file mode 100644 index 0000000..575b2fb --- /dev/null +++ b/functional-test/src/test/groovy/functional/MaxAliasesSpec.groovy @@ -0,0 +1,39 @@ +package functional + +import functional.base.BaseTestConfiguration +import org.testcontainers.spock.Testcontainers + +@Testcontainers +class MaxAliasesSpec extends BaseTestConfiguration { + + static String PROJ_NAME = 'ansible-max-aliases' + static String NODE_1 = 'proxy-1.example.net' + static String NODE_2 = 'proxy-2.example.net' + static String NODE_3 = 'proxy-3.example.net' + + def setupSpec() { + startCompose() + configureRundeck(PROJ_NAME, NODE_1) + } + + void "max aliases"() { + when: + def result = client.apiCall {api-> api.listNodes(PROJ_NAME,'.*')} + + then: + result != null + result.size() == 4 + result.get(NODE_1) != null + result.get(NODE_1).getAttributes().get('nodename') == NODE_1 + result.get(NODE_1).getAttributes().get('hostname') == NODE_1 + result.get(NODE_1).getAttributes().get('tags') == 'fr, fr1' + result.get(NODE_2) != null + result.get(NODE_2).getAttributes().get('nodename') == NODE_2 + result.get(NODE_2).getAttributes().get('hostname') == NODE_2 + result.get(NODE_2).getAttributes().get('tags') == 'fr, fr1' + result.get(NODE_3) != null + result.get(NODE_3).getAttributes().get('nodename') == NODE_3 + result.get(NODE_3).getAttributes().get('hostname') == NODE_3 + result.get(NODE_3).getAttributes().get('tags') == 'fr2' + } +} diff --git a/functional-test/src/test/resources/docker/ansible-max-aliases/ansible.cfg b/functional-test/src/test/resources/docker/ansible-max-aliases/ansible.cfg new file mode 100644 index 0000000..974a6c1 --- /dev/null +++ b/functional-test/src/test/resources/docker/ansible-max-aliases/ansible.cfg @@ -0,0 +1,6 @@ +[defaults] +inventory=/home/rundeck/ansible-max-aliases/inventory_max_aliases.ini +interpreter_python=/usr/bin/python3 + + + diff --git a/functional-test/src/test/resources/docker/ansible-max-aliases/inventory_max_aliases.ini b/functional-test/src/test/resources/docker/ansible-max-aliases/inventory_max_aliases.ini new file mode 100644 index 0000000..a3cd4b8 --- /dev/null +++ b/functional-test/src/test/resources/docker/ansible-max-aliases/inventory_max_aliases.ini @@ -0,0 +1,14 @@ +[fr:children] +fr1 +fr2 + +[fr:vars] +api_dcs=["fr1","fr2"] +alias_01=["data-01","data-02"] + +[fr1] +proxy-1.example.net name=proxy-1 peers_ip=10.3.13.221 mgmt_ip=10.3.16.221 is_mon_master=True +proxy-2.example.net name=proxy-2 peers_ip=10.3.13.222 mgmt_ip=10.3.16.222 is_mon_master=True + +[fr2] +proxy-3.example.net name=proxy-3 peers_ip=10.3.13.223 mgmt_ip=10.3.16.223 is_mon_master=True diff --git a/functional-test/src/test/resources/docker/docker-compose.yml b/functional-test/src/test/resources/docker/docker-compose.yml index 10df27f..fedf4ce 100644 --- a/functional-test/src/test/resources/docker/docker-compose.yml +++ b/functional-test/src/test/resources/docker/docker-compose.yml @@ -36,6 +36,7 @@ services: - ./ansible-list:/home/rundeck/ansible-list:rw - ./ansible-yaml-parsing:/home/rundeck/ansible-yaml-parsing:rw - ./ansible-child-groups:/home/rundeck/ansible-child-groups:rw + - ./ansible-max-aliases:/home/rundeck/ansible-max-aliases:rw volumes: rundeck-data: diff --git a/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/acls/node-acl.aclpolicy b/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/acls/node-acl.aclpolicy new file mode 100644 index 0000000..596f7af --- /dev/null +++ b/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/acls/node-acl.aclpolicy @@ -0,0 +1,8 @@ +by: + urn: project:ansible-yaml-parsing +for: + storage: + - match: + path: 'keys/.*' + allow: [read] +description: Allow access to key storage \ No newline at end of file diff --git a/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/etc/project.properties b/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/etc/project.properties new file mode 100644 index 0000000..7356d8c --- /dev/null +++ b/functional-test/src/test/resources/project-import/ansible-max-aliases/rundeck-max-aliases/files/etc/project.properties @@ -0,0 +1,32 @@ +#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-max-aliases +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-max-aliases/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-max-aliases/inventory_max_aliases.ini +resources.source.2.config.ansible-yaml-max-aliases=4 +resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory +service.FileCopier.default.provider=sshj-scp +service.NodeExecutor.default.provider=sshj-ssh \ No newline at end of file