summaryrefslogtreecommitdiff
path: root/tests/fixtures/config/cleanup-playbook
diff options
context:
space:
mode:
authorIan Wienand <iwienand@redhat.com>2019-09-12 14:40:54 +1000
committerIan Wienand <iwienand@redhat.com>2019-09-12 14:42:09 +1000
commitb6544f514f70a7abf5a6e8885e6f6dad06f06ba0 (patch)
tree06fce4f13f3f5d5af1b2cb624f51906a6eefc35f /tests/fixtures/config/cleanup-playbook
parentb98f1d28cb214d3b9644650a90ab4d013ad9f79b (diff)
downloadzuul-b6544f514f70a7abf5a6e8885e6f6dad06f06ba0.tar.gz
Remove auto-add of localhost from unit test inventory
Unit test playbooks are generally written as - hosts: all tasks: ... However, many of the unit tests don't specify any nodes for their jobs. With no nodes specified, Ansible gets a empty host list and thus the only host available is the special "implicit localhost". Since "all" doesn't match the implicit localhost, under normal circumstances Ansible does not match anything and doesn't run any of the playbooks. To get around this, the extant code in RecordingAnsibleJob:getHostList() (tests/base.py) overrides the host list and explicitly adds a host named "localhost". This is put into the Ansible inventory and now the "all" matcher has something to match against and the playbooks run. This work-around was initially added with I5e23f330476f064acf3cb87f746c5d3193cce274. The situation became a bit more confused with Iacf670d992bb051560a0c46c313beaa6721489c4 where the "localhost" fake node is only added if other nodes are *not* specified. Several tests rely on this now as they specify various forms of nodes explicitly and don't want this fake node added. This change removes the automatic addition of "localhost" in unit-tests all together. I believe this is the correct direction to move in, because it's a fairly confusing anti-feature if, for example, you write a unit test that *is* explicitly executor-only (i.e. a blank node list). Such a test fails because the unit-test framework adds a host for you; something that does not happen in production. It's also a bit confusing if you're reading the config files and thinking "hosts: all shouldn't match anything here" without digging into the test framework. There are two ways this could be fixed. The playbooks that are part of jobs that have no nodes defined could be re-written to "hosts: localhost" so that they match the "implicit localhost" and always run. This does not really seem to be their intent, however. The other option, which is taken here, is to always add nodes to the job. I believe this is a better approach, as it more closely matches what you would see in actual jobs. Change-Id: I6b52b7e4bc591c09034461b534ca5225945f76cf
Diffstat (limited to 'tests/fixtures/config/cleanup-playbook')
-rw-r--r--tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml b/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml
index 2bbda53db..42f83bb14 100644
--- a/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/cleanup-playbook/git/common-config/zuul.yaml
@@ -15,6 +15,10 @@
- job:
name: base
parent: null
+ nodeset:
+ nodes:
+ - name: test_node
+ label: test_label
- job:
name: python27