Skip to content

Commit

Permalink
[ignore] Add negative tests for IPv4/IPv6 configuration requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmicol committed Dec 16, 2024
1 parent 3fcbb58 commit fc0e13e
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 9 deletions.
12 changes: 6 additions & 6 deletions plugins/modules/nd_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,14 @@ def check_network_requirements(nd, version, nodes, internal_network_ipv4, intern
# checking minimum requirements for internal network
if not all(internal_network_ipv4) and not all(internal_network_ipv6):
nd.fail_json(msg="Application and service network addresses, IPv4 or IPv6, are required during ND setup.")
# Conditions fo Dual Stack configuration for internal network
# Conditions for Dual Stack configuration for internal network
elif all(internal_network_ipv4) and any(internal_network_ipv6) and not all(internal_network_ipv6):
nd.fail_json(
msg="For a dual stack configuration, application and service network IPv6 addresses are required. Otherwise, the extra one must be removed."
msg="For a dual stack configuration, application and service network IPv6 addresses are required. Otherwise, the extra address must be removed."
)
elif all(internal_network_ipv6) and any(internal_network_ipv4) and not all(internal_network_ipv4):
nd.fail_json(
msg="For a dual stack configuration, application and service network IPv4 addresses are required. Otherwise, the extra one must be removed."
msg="For a dual stack configuration, application and service network IPv4 addresses are required. Otherwise, the extra address must be removed."
)
for node in nodes:
for network in ["data_network", "management_network"]:
Expand All @@ -373,18 +373,18 @@ def check_network_requirements(nd, version, nodes, internal_network_ipv4, intern
# checking minimum requirements for external network
if not all(network_ipv4_config) and not all(network_ipv6_config):
nd.fail_json(msg="A complete IPv4 subnet/gateway or IPv6 subnet/gateway configuration is required in node's {0}.".format(network))
# Conditions fo Dual Stack configuration for external network
# Conditions for Dual Stack configuration for external network
elif all(network_ipv4_config) and any(network_ipv6_config) and not all(network_ipv6_config):
nd.fail_json(
msg="For a dual stack configuration,"
/ " a complete IPv6 subnet/gateway configuration in node's {0} must be provided.".format(network)
/ " Otherwise, the extra one must be removed"
/ " Otherwise, the extra address must be removed."
)
elif all(network_ipv6_config) and any(network_ipv4_config) and not all(network_ipv4_config):
nd.fail_json(
msg="For a dual stack configuration,"
/ " a complete IPv4 subnet/gateway configuration in node's {0} must be provided.".format(network)
/ " Otherwise, the extra one must be removed"
/ " Otherwise, the extra address must be removed."
)
else:
# checking minimum requirements for internal network
Expand Down
146 changes: 143 additions & 3 deletions tests/integration/targets/nd_setup/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,70 @@
ignore_errors: true
register: cluster_name_invalid_hyphen

- name: Install ND without complete node's management network
cisco.nd.nd_setup:
output_level: debug
cluster_name: cluster-one
dns_server: "{{ dns_server }}"
dns_search_domain: cisco.com
app_network: "{{ app_network }}"
service_network: "{{ service_network }}"
ntp_config:
servers:
- ntp_host: "{{ ntp_server }}"
ntp_key_id: 1
preferred: true
keys:
- ntp_key_id: 1
ntp_key: "ntp_secure_key"
authentication_type: "AES128CMAC"
trusted: true
nodes:
- hostname: Test
serial_number: "{{ serial_number }}"
management_ip_address: "{{ management_ip_address }}"
username: "{{ deployment_username | default('rescue-user') }}"
password: "{{ deployment_password }}"
management_network:
ipv4_address: "{{ management_ip }}"
data_network:
ipv4_address: "{{ data_ip }}"
ipv4_gateway: "{{ data_gateway }}"
ignore_errors: true
register: cluster_invalid_node_management_network

- name: Install ND without application network
cisco.nd.nd_setup:
output_level: debug
cluster_name: cluster-one
dns_server: "{{ dns_server }}"
dns_search_domain: cisco.com
service_network: "{{ service_network }}"
ntp_config:
servers:
- ntp_host: "{{ ntp_server }}"
ntp_key_id: 1
preferred: true
keys:
- ntp_key_id: 1
ntp_key: "ntp_secure_key"
authentication_type: "AES128CMAC"
trusted: true
nodes:
- hostname: Test
serial_number: "{{ serial_number }}"
management_ip_address: "{{ management_ip_address }}"
username: "{{ deployment_username | default('rescue-user') }}"
password: "{{ deployment_password }}"
management_network:
ipv4_address: "{{ management_ip }}"
ipv4_gateway: "{{ management_gateway }}"
data_network:
ipv4_address: "{{ data_ip }}"
ipv4_gateway: "{{ data_gateway }}"
ignore_errors: true
register: cluster_invalid_application_network

- name: Install ND in normal mode
cisco.nd.nd_setup:
output_level: debug
Expand Down Expand Up @@ -168,6 +232,8 @@
- cluster_name_length_error.msg == "A length of 1 to 63 characters is allowed."
- cluster_name_invalid_chars.msg == "Valid characters include letters, digits and hyphen."
- cluster_name_invalid_hyphen.msg == "The name cannot start or end with a hyphen."
- cluster_invalid_node_management_network.msg == "A complete IPv4 subnet/gateway configuration is required in node's management_network."
- cluster_invalid_application_network.msg == "Application and service network IPv4 addresses are required during ND setup."
- cluster_cm.current.clusterConfig.appNetwork == "{{ app_network }}"
- cluster_cm.current.clusterConfig.nameServers.0 == "{{ dns_server }}"
- cluster_cm.current.clusterConfig.ntpConfig.servers.0.host == "{{ ntp_server }}"
Expand Down Expand Up @@ -266,7 +332,7 @@
ignore_errors: true
register: cluster_name_invalid_hyphen

- name: Install ND without management network ipv4 address
- name: Install ND without complete node's management network
cisco.nd.nd_setup:
<<: *nd_setup_test_config
nodes:
Expand All @@ -277,12 +343,81 @@
username: "{{ deployment_username | default('rescue-user') }}"
password: "{{ deployment_password }}"
management_network:
ipv4_gateway: "{{ management_gateway }}"
ipv4_address: "{{ management_ip }}"
data_network:
ipv4_address: "{{ data_ip }}"
ipv4_gateway: "{{ data_gateway }}"
ignore_errors: true
register: cluster_invalid_node_management_network

- name: Install ND without complete dual stack ipv6 configurations in node management network
cisco.nd.nd_setup:
<<: *nd_setup_test_config
nodes:
- hostname: Test
serial_number: "{{ serial_number }}"
role: primary
management_ip_address: "{{ management_ip_address }}"
username: "{{ deployment_username | default('rescue-user') }}"
password: "{{ deployment_password }}"
management_network:
ipv4_address: "{{ management_ip }}"
ipv4_gateway: "{{ management_gateway }}"
ipv6_address: "{{ management_ipv6 }}"
data_network:
ipv4_address: "{{ data_ip }}"
ipv4_gateway: "{{ data_gateway }}"
ipv6_address: "{{ data_ipv6 }}"
ipv6_gateway: "{{ data_gateway_ipv6 }}"
ignore_errors: true
register: cluster_invalid_dual_stack_node_management_network_v6

- name: Install ND without complete dual stack ipv4 configurations in node management network
cisco.nd.nd_setup:
<<: *nd_setup_test_config
nodes:
- hostname: Test
serial_number: "{{ serial_number }}"
role: primary
management_ip_address: "{{ management_ip_address }}"
username: "{{ deployment_username | default('rescue-user') }}"
password: "{{ deployment_password }}"
management_network:
ipv4_address: "{{ management_ip }}"
ipv6_address: "{{ management_ipv6 }}"
ipv6_gateway: "{{ management_gateway_ipv6 }}"
data_network:
ipv4_address: "{{ data_ip }}"
ipv4_gateway: "{{ data_gateway }}"
ipv6_address: "{{ data_ipv6 }}"
ipv6_gateway: "{{ data_gateway_ipv6 }}"
ignore_errors: true
register: cluster_invalid_dual_stack_node_management_network_v4

- name: Install ND without any application network addresses
cisco.nd.nd_setup:
<<: *nd_setup_test_config
app_network: null
ignore_errors: true
register: cluster_invalid_application_network

- name: Install ND without complete dual stack ipv6 configurations in internal network
cisco.nd.nd_setup:
<<: *nd_setup_test_config
app_network: "{{ app_network }}"
service_network: "{{ service_network }}"
service_network_ipv6: "{{ service_network_ipv6 }}"
ignore_errors: true
register: cluster_invalid_dual_stack_application_network_v6

- name: Install ND without complete dual stack ipv4 configurations in internal network
cisco.nd.nd_setup:
<<: *nd_setup_test_config
service_network: "{{ service_network }}"
app_network_ipv6: "{{ app_network_ipv6 }}"
service_network_ipv6: "{{ service_network_ipv6 }}"
ignore_errors: true
register: cluster_invalid_dual_stack_application_network_v4

- name: Install ND in normal mode
cisco.nd.nd_setup:
Expand All @@ -308,7 +443,12 @@
- cluster_name_length_error.msg == "A length of 1 to 63 characters is allowed."
- cluster_name_invalid_chars.msg == "Valid characters include letters, digits and hyphen."
- cluster_name_invalid_hyphen.msg == "The name cannot start or end with a hyphen."
- cluster_invalid_node_management_network.msg == "Missing IPv4 subnet/gateway or IPv6 subnet/gateway in node management network configuration."
- cluster_invalid_node_management_network.msg == "A complete IPv4 subnet/gateway or IPv6 subnet/gateway configuration is required in node's management_network."
- cluster_invalid_dual_stack_node_management_network_v6 == "For a dual stack configuration, a complete IPv6 subnet/gateway configuration in node's management_network must be provided. Otherwise, the extra address must be removed."
- cluster_invalid_dual_stack_node_management_network_v4 == "For a dual stack configuration, a complete IPv4 subnet/gateway configuration in node's management_network must be provided. Otherwise, the extra address must be removed."
- cluster_invalid_application_network.msg == "Application and service network addresses, IPv4 or IPv6, are required during ND setup."
- cluster_invalid_dual_stack_application_network_v6.msg == "For a dual stack configuration, application and service network IPv6 addresses are required. Otherwise, the extra address must be removed."
- cluster_invalid_dual_stack_application_network_v4.msg == "For a dual stack configuration, application and service network IPv4 addresses are required. Otherwise, the extra address must be removed."
- cluster_cm.current.clusterConfig.appNetwork == "{{ app_network }}"
- cluster_cm.current.clusterConfig.nameServers.0 == "{{ dns_server }}"
- cluster_cm.current.clusterConfig.ntpConfig.servers.0.host == "{{ ntp_server }}"
Expand Down

0 comments on commit fc0e13e

Please sign in to comment.