Skip to content

Commit d3c74f9

Browse files
authored
Merge pull request #376 from rundeck-plugins/add-test-large-intentory
add a functional test for larges inventories
2 parents b4d9fd9 + 4bce092 commit d3c74f9

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package functional
2+
3+
import functional.base.BaseTestConfiguration
4+
import org.testcontainers.spock.Testcontainers
5+
6+
@Testcontainers
7+
class LargeInventorySpec extends BaseTestConfiguration {
8+
9+
static String PROJ_NAME = 'ansible-large-inventory'
10+
11+
def setupSpec() {
12+
startCompose()
13+
configureRundeck(PROJ_NAME, "Node-0")
14+
}
15+
16+
def "test large inventory"(){
17+
when:
18+
19+
def result = client.apiCall {api-> api.listNodes(PROJ_NAME,".*")}
20+
21+
then:
22+
result!=null
23+
result.size()==8001
24+
result.get("Node-0")!=null
25+
result.get("Node-0").getAttributes().get("ansible_host") == "ssh-node"
26+
result.get("Node-0").getAttributes().get("ansible_ssh_user") == "rundeck"
27+
result.get("Node-0").getAttributes().get("some-var") == "1234"
28+
result.get("Node-7999")!=null
29+
result.get("Node-7999").getAttributes().get("ansible_host") == "ssh-node"
30+
result.get("Node-7999").getAttributes().get("ansible_ssh_user") == "rundeck"
31+
result.get("Node-7999").getAttributes().get("some-var") == "1234"
32+
}
33+
}

functional-test/src/test/groovy/functional/base/BaseTestConfiguration.groovy

+1
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,5 @@ class BaseTestConfiguration extends Specification{
139139
count++
140140
}
141141
}
142+
142143
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env python3
2+
import json
3+
4+
nodes_meta = {}
5+
nodes = []
6+
7+
for x in range(8000):
8+
node_name = "Node-" + str(x)
9+
nodes_meta[node_name] = {
10+
"ansible_ssh_user": "rundeck",
11+
"ansible_host": "ssh-node",
12+
"some-var": "1234"
13+
}
14+
15+
nodes.append(node_name)
16+
17+
18+
output = {
19+
"_meta": {
20+
"hostvars": nodes_meta
21+
},
22+
"test": {
23+
"hosts": nodes
24+
}
25+
}
26+
27+
28+
29+
print(json.dumps(output))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
by:
2+
urn: project:ansible-large-inventory
3+
for:
4+
storage:
5+
- match:
6+
path: 'keys/.*'
7+
allow: [read]
8+
description: Allow access to key storage
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#edit below
2+
project.disable.executions=false
3+
project.disable.schedule=false
4+
project.execution.history.cleanup.batch=500
5+
project.execution.history.cleanup.enabled=false
6+
project.execution.history.cleanup.retention.days=60
7+
project.execution.history.cleanup.retention.minimum=50
8+
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
9+
project.jobs.gui.groupExpandLevel=1
10+
project.later.executions.disable.value=0
11+
project.later.executions.disable=false
12+
project.later.executions.enable.value=
13+
project.later.executions.enable=false
14+
project.later.schedule.disable.value=
15+
project.later.schedule.disable=false
16+
project.later.schedule.enable.value=
17+
project.later.schedule.enable=false
18+
project.name=ansible-large-inventory
19+
project.nodeCache.enabled=false
20+
project.nodeCache.firstLoadSynch=true
21+
project.output.allowUnsanitized=false
22+
project.retry-counter=3
23+
project.ssh-authentication=privateKey
24+
resources.source.1.type=local
25+
resources.source.2.config.ansible-config-file-path=/home/rundeck/ansible/ansible.cfg
26+
resources.source.2.config.ansible-gather-facts=false
27+
resources.source.2.config.ansible-ignore-errors=true
28+
resources.source.2.config.ansible-inventory=/home/rundeck/ansible/large-inventory.py
29+
resources.source.2.type=com.batix.rundeck.plugins.AnsibleResourceModelSourceFactory
30+
service.FileCopier.default.provider=sshj-scp
31+
service.NodeExecutor.default.provider=sshj-ssh

0 commit comments

Comments
 (0)