Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a functional test for larges inventories #376

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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, "Node-0")
}

def "test large inventory"(){
when:

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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,5 @@ class BaseTestConfiguration extends Specification{
count++
}
}

}
Original file line number Diff line number Diff line change
@@ -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))
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
by:
urn: project:ansible-large-inventory
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-large-inventory
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/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
Loading