Skip to content

Commit

Permalink
modified ipam_address tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ybhalchim committed Dec 11, 2024
1 parent 0a3ffce commit 3e24bf7
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 59 deletions.
11 changes: 0 additions & 11 deletions plugins/modules/ipam_address_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@
- Filter query to filter objects
type: str
required: false
inherit:
description:
- Return inheritance information
type: str
required: false
choices:
- full
- partial
- none
default: full
tag_filters:
description:
- Filter dict to filter objects by tags
Expand Down Expand Up @@ -414,7 +404,6 @@ def main():
id=dict(type="str", required=False),
filters=dict(type="dict", required=False),
filter_query=dict(type="str", required=False),
inherit=dict(type="str", required=False, choices=["full", "partial", "none"], default="full"),
tag_filters=dict(type="dict", required=False),
tag_filter_query=dict(type="str", required=False),
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/ipam_address/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
dependencies: [setup_address]
dependencies: [setup_address]
154 changes: 113 additions & 41 deletions tests/integration/targets/ipam_address/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
block:

# Basic tests for Address
- name: Create a Address (check mode)
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "present"
check_mode: true
register: address

- name: Create a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
Expand All @@ -30,7 +38,8 @@
that:
- address is changed
- address is not failed
- address_info.objects | length != 0
- address_info.objects | length == 1
- address_info.objects[0].id == address.id

- name: Create a Address(idempotent)
infoblox.bloxone.ipam_address:
Expand All @@ -43,25 +52,64 @@
- address is not changed
- address is not failed

- name: Create the Address with Name
- name: Delete a Address (check mode)
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
names: [{"name": "test-1", "type": "user"}]
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "present"
state: "absent"
check_mode: true

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.8",
space: "{{ ip_space.id }}"
address: "10.0.0.3",
space: "{{ ip_space.id }}"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length > 0
- address_info.objects | length == 0

- name: Delete a Address(idempotent)
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"
register: address
- assert:
that:
- address is not changed
- address is not failed

- name: Create the Address with Name
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
names:
- name: "test-1"
type: "user"
space: "{{ ip_space.id }}"
state: "present"
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].names[0].name == address.object.names[0].name

- name: Create the Address with comment
infoblox.bloxone.ipam_address:
Expand All @@ -81,64 +129,88 @@
that:
- address is changed
- address is not failed
- address_info.objects[0].comment == "some comment"
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].comment == address.object.comment

- name: Create the Address with hwaddr (check mode)
- name: Create the Address with hwaddr
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
address: "10.0.0.6"
hwaddr: "00:11:22:33:44:55"
space: "{{ ip_space.id }}"
state: "present"
check_mode: true
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.6",
space: "{{ ip_space.id }}",
hwaddr: "00:11:22:33:44:55"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].hwaddr == address.object.hwaddr

- name: Create the Address with Interface (check mode)
- name: Create the Address with Interface
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
address: "10.0.0.7"
interface: "eth0"
space: "{{ ip_space.id }}"
state: "present"
register: address
check_mode: true
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.7",
space: "{{ ip_space.id }}",
interface: "eth0"
}
register: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].interface == address.object.interface

- name: Create the Address with Tags (check mode)
- name: Create the Address with Tags
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
tags: {"tag1": "value1", "tag2": "value2"}
space: "{{ ip_space.id }}"
state: "present"
check_mode: true

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.3"
space: "{{ ip_space.id }}"
state: "absent"

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.5"
space: "{{ ip_space.id }}"
state: "absent"

- name: Delete a Address
infoblox.bloxone.ipam_address:
address: "10.0.0.8"
space: "{{ ip_space.id }}"
state: "absent"

- name: Get information about the address
register: address
- name: Get information about the Address
infoblox.bloxone.ipam_address_info:
filters: {
address: "10.0.0.3",
space: "{{ ip_space.id }}"
address: "10.0.0.8",
space: "{{ ip_space.id }}",
}
register: address_info
- name: Debug address
debug:
var: address

- name: Debug address_info
debug:
var: address_info
- assert:
that:
- address is changed
- address is not failed
- address_info.objects | length == 0
- address_info.objects | length == 1
- address_info.objects[0].id == address.id
- address_info.objects[0].tags.tag1 == "value1"
- address_info.objects[0].tags.tag2 == "value2"

always:
# Cleanup if the test fails
- name: Delete a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
Expand All @@ -150,4 +222,4 @@
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
register: ip_space
2 changes: 1 addition & 1 deletion tests/integration/targets/ipam_address_info/meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
dependencies: [setup_address]
dependencies: [setup_address]
17 changes: 16 additions & 1 deletion tests/integration/targets/ipam_address_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,19 @@
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
register: ip_space

always:
# Cleanup if the test fails
- name: Delete a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
space: "{{ ip_space.id }}"
state: "absent"
register: subnet

- name: Delete IP Space
infoblox.bloxone.ipam_ip_space:
name: "{{ ip_name }}"
state: "absent"
register: ip_space
4 changes: 0 additions & 4 deletions tests/integration/targets/setup_address/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
state: "present"
register: ip_space

- name: Debug the IP space name created
debug:
var: ip_space.object.name

- name: Create a Subnet
infoblox.bloxone.ipam_subnet:
address: "10.0.0.0/16"
Expand Down

0 comments on commit 3e24bf7

Please sign in to comment.