diff --git a/functional-test/src/test/groovy/functional/LargeInventorySpec.groovy b/functional-test/src/test/groovy/functional/LargeInventorySpec.groovy new file mode 100644 index 0000000..e1734a9 --- /dev/null +++ b/functional-test/src/test/groovy/functional/LargeInventorySpec.groovy @@ -0,0 +1,36 @@ +package functional + +import functional.base.BaseTestConfiguration +import org.testcontainers.spock.Testcontainers + +@Testcontainers +class LargeInventorySpec extends BaseTestConfiguration { + + static String PROJ_NAME = 'ansible-large-inventory' + + def setupSpec() { + startCompose() + configureRundeck(PROJ_NAME) + } + + def "test large inventory"(){ + when: + + //wait for node to be available + waitForNodes(PROJ_NAME) + + def result = client.apiCall {api-> api.listNodes(PROJ_NAME,".*")} + + then: + result!=null + result.size()==8001 + result.get("Node-0")!=null + result.get("Node-0").getAttributes().get("ansible_host") == "ssh-node" + result.get("Node-0").getAttributes().get("ansible_ssh_user") == "rundeck" + result.get("Node-0").getAttributes().get("some-var") == "1234" + result.get("Node-7999")!=null + result.get("Node-7999").getAttributes().get("ansible_host") == "ssh-node" + result.get("Node-7999").getAttributes().get("ansible_ssh_user") == "rundeck" + result.get("Node-7999").getAttributes().get("some-var") == "1234" + } +} diff --git a/functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy b/functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy index 47fd531..b13d0be 100644 --- a/functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy +++ b/functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy @@ -136,4 +136,15 @@ class BaseTestConfiguration extends Specification{ } } + + void waitForNodes(String projectName){ + def result = client.apiCall {api-> api.listNodes(projectName,".*")} + def count =0 + + while(result.size()<=1 && count<5){ + sleep(2000) + result = client.apiCall {api-> api.listNodes(projectName,".*")} + count++ + } + } } diff --git a/functional-test/src/test/resources/docker/ansible/large-inventory.py b/functional-test/src/test/resources/docker/ansible/large-inventory.py new file mode 100755 index 0000000..0355e82 --- /dev/null +++ b/functional-test/src/test/resources/docker/ansible/large-inventory.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +import json + +nodes_meta = {} +nodes = [] + +for x in range(8000): + node_name = "Node-" + str(x) + nodes_meta[node_name] = { + "ansible_ssh_user": "rundeck", + "ansible_host": "ssh-node", + "some-var": "1234" + } + + nodes.append(node_name) + + +output = { + "_meta": { + "hostvars": nodes_meta + }, + "test": { + "hosts": nodes + } +} + + + +print(json.dumps(output)) diff --git a/functional-test/src/test/resources/project-import/ansible-large-inventory/rundeck-ansible-large-inventory/files/acls/node-acl.aclpolicy b/functional-test/src/test/resources/project-import/ansible-large-inventory/rundeck-ansible-large-inventory/files/acls/node-acl.aclpolicy new file mode 100644 index 0000000..a32cb0a --- /dev/null +++ b/functional-test/src/test/resources/project-import/ansible-large-inventory/rundeck-ansible-large-inventory/files/acls/node-acl.aclpolicy @@ -0,0 +1,8 @@ +by: + urn: project:ansible-large-inventory +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-large-inventory/rundeck-ansible-large-inventory/files/etc/project.properties b/functional-test/src/test/resources/project-import/ansible-large-inventory/rundeck-ansible-large-inventory/files/etc/project.properties new file mode 100644 index 0000000..2e72202 --- /dev/null +++ b/functional-test/src/test/resources/project-import/ansible-large-inventory/rundeck-ansible-large-inventory/files/etc/project.properties @@ -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-large-inventory +project.nodeCache.enabled=true +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/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/large-inventory.py +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