Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Contributaiong #431

Merged
merged 5 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,57 @@
6. Link the pull request in `issue#<id>`

7. After the pull request is merged, close the `issue#<id>`


## Testing

# Integration Testing for Ansible Modules

To perform integration tests for any specific Ansible module such as the `ntnx_vms` module, follow these step-by-step procedures:

## Prerequisites
- Ensure you are in the collection directory where the module is located.

## Setting up Variables
1. Navigate to the `tests/integration/targets` directory within the collection.
2. Fill in the necessary variables inside different feature-specific var files, such as `prepare_nv_env/vars/main.yml`, `prepare_ndb_env/vars/main.yml`, `prepare_foundation_env/vars/main.yml`, etc. Note: Not all variables are compulsory; define only the required variables for the specific feature you want to test.
alaa-bish marked this conversation as resolved.
Show resolved Hide resolved
3. Run the playbook for the specific feature you intend to test:
- For PC tests, execute the command:
```bash
ansible-playbook prepare_env/tasks/prepare_env.yml
```
- For NDB tests, execute the command:
```bash
ansible-playbook prepare_ndb_env/tasks/prepare_env.yml
```
- For Foundation tests, execute the command:
```bash
ansible-playbook prepare_foundation_env/tasks/prepare_foundation_env.yml
```
- Replace 'feature' with the specific feature you intend to test.

## Running Integration Tests
4. Run the integration tests for all modules using:
```bash
ansible-integration
```

5. To perform an integration test for a specific module, use:
```bash
ansible-integration module_test_name
```
Replace `module_test_name` with the actual module's name.

## Cleanup
6. After completing all integration tests, perform a cleanup specific to the tested feature:
- For PC tests, execute the command:
```bash
ansible-playbook prepare_env/tasks/clean_up.yml
```
- For Foundation tests, execute the command:
```bash
ansible-playbook prepare_foundation_env/tasks/clean_up.yml
```

By following these steps, you can conduct comprehensive integration testing for the specified Ansible module and ensure a clean testing environment afterward. Define only the necessary variables for the specific feature you intend to test.

120 changes: 120 additions & 0 deletions tests/integration/targets/prepare_env/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
ip: EXAMPLE_IP
username: EXAMPLE_USERNAME
password: EXAMPLE_PASSWORD
validate_certs: false
cluster:
name: EXAMPLE_CLUSTER_NAME
uuid: EXAMPLE_CLUSTER_UUID
k8s_version: EXAMPLE_K8S_VERSION
host_os: EXAMPLE_HOST_OS
network:
dhcp:
name: EXAMPLE_VLAN_NAME
uuid: EXAMPLE_VLAN_UUID
static:
ip: EXAMPLE_STATIC_IP
nutanix_cluster_password: EXAMPLE_CLUSTER_PASSWORD
nutanix_cluster_username: EXAMPLE_CLUSTER_USERNAME

cni:
node_cidr_mask_size: "EXAMPLE_MASK_CIDR"
service_ipv4_cidr: "EXAMPLE_SERVICE_CIDR"
pod_ipv4_cidr: "EXAMPLE_POD_CIDR"
vm_owner:
name: EXAMPLE_OWNER_NAME
uuid: EXAMPLE_OWNER_UUID

todelete: []

disk_image:
url: EXAMPLE_IMAGE_URL
dest: EXAMPLE_DEST_PATH
checksum: EXAMPLE_CHECKSUM
centos: "EXAMPLE_CENTOS"

external_nat_subnets:
name: EXAMPLE_NAT_NAME
vlan_id: EXAMPLE_VLAN_ID
gateway_ip_address: EXAMPLE_GATEWAY_IP
network_prefix: EXAMPLE_PREFIX
network_ip: EXAMPLE_NETWORK_IP
dhcp:
start_address: EXAMPLE_START_DHCP
end_address: EXAMPLE_END_DHCP
static:
start_address: EXAMPLE_START_STATIC
end_address: EXAMPLE_END_STATIC

vpc_name: EXAMPLE_VPC_NAME
vm_name: EXAMPLE_VM_NAME
static_subnet_name: EXAMPLE_STATIC_SUBNET
overlay_subnet:
name: EXAMPLE_OVERLAY_NAME
network_ip: EXAMPLE_OVERLAY_NETWORK_IP
network_prefix: EXAMPLE_OVERLAY_PREFIX
gateway_ip: EXAMPLE_OVERLAY_GATEWAY_IP
private_ip: EXAMPLE_OVERLAY_PRIVATE_IP

quarantine_rule_uuid: EXAMPLE_QUARANTINE_UUID
categories:
apptiers:
- Default
- sub_app_1
centos: "EXAMPLE_CENTOS"
ubuntu: "EXAMPLE_UBUNTU"

virtual_switch:
name: EXAMPLE_SWITCH_NAME
uuid: EXAMPLE_SWITCH_UUID

storage_container:
name: EXAMPLE_CONTAINER_NAME
uuid: EXAMPLE_CONTAINER_UUID

users:
- EXAMPLE_USER_UUID_1
- EXAMPLE_USER_UUID_2
user_groups:
- EXAMPLE_GROUP_UUID

project:
name: EXAMPLE_PROJECT_NAME
uuid: EXAMPLE_PROJECT_UUID

roles:
- "EXAMPLE_ROLES_NAME_1"
- "EXAMPLE_ROLES_NAME_2"
- "EXAMPLE_ROLES_NAME_3"
- "EXAMPLE_ROLES_NAME_4"

accounts:
- name: "NTNX_LOCAL_AZ"
uuid: "EXAMPLE_ACCOUNT_UUID"

new_user: "EXAMPLE_NEW_USER_EMAIL"

new_user_group: "EXAMPLE_NEW_USER_GROUP_DN"

acp:
role:
name: "Project Admin"
uuid: EXAMPLE_ROLE_UUID
user_uuid: EXAMPLE_USER_UUID
user_group_uuid: EXAMPLE_GROUP_UUID

distinguished_name: "EXAMPLE_DISTINGUISHED_NAME"
principal_name: "EXAMPLE_PRINCIPAL_NAME"
directory_service_uuid: "EXAMPLE_DIRECTORY_UUID"
identity_provider_uuid: "EXAMPLE_IDENTITY_UUID"

dr_vm_name: EXAMPLE_VM_NAME
dr:
primary_az_url: EXAMPLE_PRIMARY_URL
recovery_az_url: EXAMPLE_RECOVERY_URL
recovery_site_network: "EXAMPLE_RECOVERY_NETWORK"
recovery_ip1: EXAMPLE_RECOVERY_IP1
recovery_ip2: EXAMPLE_RECOVERY_IP2
gateway_ip: EXAMPLE_GATEWAY_IP
prefix: EXAMPLE_PREFIX

url: EXAMPLE_URL
Loading