Skip to content

Commit

Permalink
add a functional test for larges inventories
Browse files Browse the repository at this point in the history
  • Loading branch information
ltamaster committed Jul 8, 2024
1 parent 6e122b4 commit 8977c4e
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}
}
}
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=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

0 comments on commit 8977c4e

Please sign in to comment.