Skip to content

Commit

Permalink
add unit tests for dependent item prototypes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Lathrop committed May 24, 2024
1 parent 381821a commit e4699a1
Showing 1 changed file with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
type: zabbix_agent_active
key: '{% raw %}vfs.fs.size[{#FSNAME},used]{% endraw %}'
value_type: numeric_unsigned
units: GB
units: B
interval: 1m
tags:
- tag: tag
Expand All @@ -30,7 +30,7 @@
type: zabbix_agent_active
key: '{% raw %}vfs.fs.size[{#FSNAME},used]{% endraw %}'
value_type: numeric_unsigned
units: GB
units: B
interval: 1m
tags:
- tag: tag
Expand All @@ -56,6 +56,31 @@
ansible.builtin.assert:
that: zbxhostitem_changed is changed

- name: create dependent item
community.zabbix.zabbix_itemprototype:
name: '{% raw %}{#FSNAME}:TestDependItemPrototype{% endraw %}'
discoveryrule_name: ExampleHostRule
host_name: ExampleHost
params:
type: dependent_item
key: '{% raw %}vfs.fs.size.half[{#FSNAME}]{% endraw %}'
value_type: numeric_float
units: B
master_item:
item_name: '{% raw %}{#FSNAME}:TestItemPrototype{% endraw %}'
discoveryrule_name: ExampleHostRule
host_name: ExampleHost
preprocessing:
- type: javascript
params: 'return value / 2;'
error_handler: zabbix_server
state: present
register: zbxhostdependitem_new

- name: assert that item was created
ansible.builtin.assert:
that: zbxhostdependitem_new is changed

- name: test - attempt to delete previously created zabbix item
community.zabbix.zabbix_itemprototype:
name: '{% raw %}{#FSNAME}:TestItemPrototype{% endraw %}'
Expand All @@ -68,6 +93,18 @@
ansible.builtin.assert:
that: zbxhostitem_existing_delete is changed

- name: test - attempt to delete dependent item
community.zabbix.zabbix_itemprototype:
name: '{% raw %}{#FSNAME}:TestDependItemPrototype{% endraw %}'
discoveryrule_name: ExampleHostRule
host_name: ExampleHost
state: absent
register: zbxhostdependitem_delete

- name: assert that the item had been removed with its master
ansible.builtin.assert:
that: not zbxhostdependitem_delete is changed

- name: test - attempt to delete non-existing zabbix item
community.zabbix.zabbix_itemprototype:
name: '{% raw %}{#FSNAME}:TestItemPrototype{% endraw %}'
Expand Down Expand Up @@ -106,7 +143,7 @@
type: zabbix_agent_active
key: '{% raw %}vfs.fs.size[{#FSNAME},used]{% endraw %}'
value_type: numeric_unsigned
units: GB
units: B
interval: 1m
tags:
- tag: tag
Expand All @@ -127,7 +164,7 @@
type: zabbix_agent_active
key: '{% raw %}vfs.fs.size[{#FSNAME},used]{% endraw %}'
value_type: numeric_unsigned
units: GB
units: B
interval: 1m
tags:
- tag: tag
Expand Down

0 comments on commit e4699a1

Please sign in to comment.