Skip to content

Commit

Permalink
Add current_test_timestamp as test case common variable
Browse files Browse the repository at this point in the history
Signed-off-by: Qi Zhang <qi-keira.zhang@broadcom.com>
  • Loading branch information
keirazhang committed Jan 18, 2024
1 parent b69332c commit dfc41f7
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 95 deletions.
18 changes: 9 additions & 9 deletions common/reset_base_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@
# base snapshot with a timestamp sufix, if set to true, will
# remove old base snapshot.
#
# Check old base snapshot exists or not
- include_tasks: vm_check_snapshot_exist.yml
- name: "Check current base snapshot exists or not"
include_tasks: vm_check_snapshot_exist.yml
vars:
snapshot_name: "{{ base_snapshot_name }}"

- name: "Set fact of snapshot '{{ base_snapshot_name }}' existence"
ansible.builtin.set_fact:
old_base_snapshot_exist: "{{ snapshot_exist }}"
old_snapshot_new_name: "{{ base_snapshot_name }}-{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
old_snapshot_new_name: "{{ base_snapshot_name }}-{{ current_test_timestamp }}"

# Rename old snapshot with a timestamp
- include_tasks: vm_rename_snapshot.yml
- name: "Rename current base snapshot to {{ old_snapshot_new_name }}"
include_tasks: vm_rename_snapshot.yml
vars:
current_snapshot_name: "{{ base_snapshot_name }}"
new_snapshot_name: "{{ old_snapshot_new_name }}"
when:
- old_base_snapshot_exist
- not remove_old_base_snapshot | default(false)

# Remove old base snapshot
- include_tasks: vm_remove_snapshot.yml
- name: "Remove current base snapshot"
include_tasks: vm_remove_snapshot.yml
vars:
snapshot_name: "{{ base_snapshot_name }}"
when:
- old_base_snapshot_exist
- remove_old_base_snapshot | default(false)

# Take a new snapshot as base snapshot
- include_tasks: vm_take_snapshot.yml
- name: "Take a new snapshot as base snapshot"
include_tasks: vm_take_snapshot.yml
vars:
snapshot_name: "{{ base_snapshot_name }}"

Expand Down
3 changes: 2 additions & 1 deletion common/set_current_testcase_facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
string).rjust(gosv_testcases_count | string | length, '0')) }}"
current_testcase_name: "{{ ansible_play_name }}"

- name: "Set the log folder path for current test case on local machine"
- name: "Set the timestamp and log folder path for current test case on local machine"
ansible.builtin.set_fact:
current_test_timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
current_test_log_folder: "{{ testrun_log_path }}/{{ current_testcase_index }}_{{ ansible_play_name }}"

- name: "Create log folder for current test case"
Expand Down
6 changes: 1 addition & 5 deletions common/test_rescue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# 3. take snapshot of the current failure state,
# 4. or exit testing when parameter 'exit_testing_when_fail' is set to true.
#
- name: "Set timestamp of failure state"
ansible.builtin.set_fact:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"

- name: "Print failed test case"
ansible.builtin.debug:
msg: "Testcase: {{ current_testcase_name }} failed"
Expand Down Expand Up @@ -57,7 +53,7 @@
- name: "Take a snapshot at VM current state"
include_tasks: vm_take_snapshot.yml
vars:
snapshot_name: "{{ current_testcase_name }}_fail_{{ timestamp }}"
snapshot_name: "{{ current_testcase_name }}_fail_{{ current_test_timestamp }}"
dump_memory: true
vm_take_snapshot_ignore_err: true
when:
Expand Down
2 changes: 1 addition & 1 deletion common/vcenter_add_key_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

- name: "Set fact of new key provider name"
ansible.builtin.set_fact:
new_kp_name: "{{ key_provider_type | lower }}{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
new_kp_name: "{{ key_provider_type | lower }}{{ current_test_timestamp }}"

- name: "Add key provider on vCenter server"
include_tasks: vcenter_add_standard_kp.yml
Expand Down
2 changes: 1 addition & 1 deletion common/vm_add_serial_port.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
- name: "Set default serial port output file"
ansible.builtin.set_fact:
vm_serial_port_file_path: "{{ vm_files_path_ds.strip('\\/') }}/serial-{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}.log"
vm_serial_port_file_path: "{{ vm_files_path_ds.strip('\\/') }}/serial-{{ current_test_timestamp }}.log"
when: vm_serial_port_file_path is undefined or not vm_serial_port_file_path

- name: "Add a serial port using output file"
Expand Down
2 changes: 1 addition & 1 deletion linux/check_os_fullname/check_os_fullname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

- name: "Set VMware Tools debug logging directory"
ansible.builtin.set_fact:
vmtools_log_dir: "/tmp/vmware-tools-{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
vmtools_log_dir: "/tmp/vmware-tools-{{ current_test_timestamp }}"

- name: "Enable debug logging for VMware Tools"
include_tasks: ../utils/enable_vmtools_logging.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Take quiesce snapshot
- name: "Set quiesce snapshot variables"
ansible.builtin.set_fact:
qs_snapshot_name: "quiesce_snapshot_{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
qs_snapshot_name: "quiesce_snapshot_{{ current_test_timestamp }}"
backup_script_dir: "/etc/vmware-tools/backupScripts.d"
vss_shell_script: "vss_script_sh.sh"
vss_bin_script: "vss_script_bin_{{ guest_os_bit | replace('-', '') }}"
Expand Down
8 changes: 4 additions & 4 deletions linux/deploy_vm/create_unattend_install_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
block:
- name: "Set fact of generated unattend install ISO file name"
ansible.builtin.set_fact:
unattend_iso_file_name: "{{ guest_id }}{{ '_'.join(''.join(unattend_install_conf.split('.')[:-1]).split('/')) }}-{{ timestamp }}.iso"
unattend_iso_file_name: "{{ guest_id }}{{ '_'.join(''.join(unattend_install_conf.split('.')[:-1]).split('/')) }}-{{ current_test_timestamp }}.iso"

- name: "Set fact of the local path to new generated unattend install ISO"
ansible.builtin.set_fact:
Expand All @@ -71,7 +71,7 @@
block:
- name: "Set fact of the rebuilt new OS installation ISO file name"
ansible.builtin.set_fact:
new_os_installation_iso: "{{ (os_installation_iso_list[0] | basename | splitext)[0] }}-{{ timestamp }}.iso"
new_os_installation_iso: "{{ (os_installation_iso_list[0] | basename | splitext)[0] }}-{{ current_test_timestamp }}.iso"

- name: "Set fact of the local path to the rebuilt OS installation ISO file"
ansible.builtin.set_fact:
Expand All @@ -95,14 +95,14 @@
vars:
seed_iso_dir_path: "{{ unattend_iso_cache }}"
user_data_template: "{{ unattend_install_template }}"
local_hostname: "ubuntu-{{ hostname_timestamp }}"
local_hostname: "ubuntu-{{ current_test_timestamp }}"

- name: "Set facts for generated unattend install ISO, config file and rebuilt OS installation ISO"
ansible.builtin.set_fact:
new_unattend_install_conf: "{{ user_data_path }}"
unattend_iso_file_path: "{{ seed_iso_path }}"
unattend_iso_file_name: "{{ seed_iso_path | basename }}"
new_os_installation_iso: "{{ (os_installation_iso_list[0] | basename | splitext)[0] }}-{{ timestamp }}.iso"
new_os_installation_iso: "{{ (os_installation_iso_list[0] | basename | splitext)[0] }}-{{ current_test_timestamp }}.iso"

- name: "Set fact of the local path to the rebuilt OS installation ISO file"
ansible.builtin.set_fact:
Expand Down
6 changes: 0 additions & 6 deletions linux/deploy_vm/deploy_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
gather_facts: false
collections:
- community.general
vars:
timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
tasks:
- name: "Set current test case index, name and log folder"
include_tasks: ../../common/set_current_testcase_facts.yml
Expand All @@ -27,10 +25,6 @@
- name: "Set user account for new VM"
include_tasks: set_new_vm_user_account.yml

- name: "Set fact of timestamp for VM hostname"
ansible.builtin.set_fact:
hostname_timestamp: "{{ timestamp }}"

- name: "Get SSH public key from localhost"
include_tasks: ../utils/get_local_ssh_public_key.yml

Expand Down
2 changes: 1 addition & 1 deletion linux/deploy_vm/reconfigure_vm_with_cloudinit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
vars:
seed_iso_dir_path: "{{ unattend_iso_cache }}"
user_data_template: "{{ ova_guest_os_type }}-ova-user-data.j2"
local_hostname: "{{ ova_guest_os_type }}-ova-{{ hostname_timestamp }}"
local_hostname: "{{ ova_guest_os_type }}-ova-{{ currest_test_timestamp }}"

- name: "Set fact of cloud-init seed ISO to be uploaded to ESXi datastore"
ansible.builtin.set_fact:
Expand Down
3 changes: 1 addition & 2 deletions linux/network_device_ops/pvrdma_network_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}"
adapter_type: "pvrdma"
tasks:
- name: "Test case block"
Expand Down Expand Up @@ -50,7 +49,7 @@
pvrdma_server_vm_ipv4: "{{ vds_vmk_ip_addr | ansible.utils.ipmath(1) }}"
pvrdma_server_vm_net_prefix: "{{ vds_vmk_net_prefix }}"
pvrdma_server_vm_gateway: "{{ vds_vmk_ip_addr }}"
pvrdma_client_vm_name: "{{ vm_name }}_client_{{ timestamp }}"
pvrdma_client_vm_name: "{{ vm_name }}_client_{{ current_test_timestamp }}"
pvrdma_client_vm_ipv4: "{{ vds_vmk_ip_addr | ansible.utils.ipmath(2) }}"
pvrdma_client_vm_primary_nic_mac: ""
pvrdma_client_vm_guest_ip: ""
Expand Down
4 changes: 2 additions & 2 deletions linux/utils/collect_cloudinit_logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#
- name: "Initialize cloud-init archives in guest OS"
ansible.builtin.set_fact:
cloudinit_logs_src_path: "/tmp/cloud-init-logs_{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}.tar.gz"
cloudinit_cfgs_src_path: "/tmp/cloud-init-configs_{{ lookup('pipe', 'date +%Y%m%d%H%M%S') }}.tar.gz"
cloudinit_logs_src_path: "/tmp/cloud-init-logs_{{ current_test_timestamp }}.tar.gz"
cloudinit_cfgs_src_path: "/tmp/cloud-init-configs_{{ current_test_timestamp }}.tar.gz"

- name: "Set facts of cloud-init archives at local"
ansible.builtin.set_fact:
Expand Down
4 changes: 2 additions & 2 deletions linux/utils/create_seed_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ansible.builtin.set_fact:
user_data_path: "{{ seed_iso_dir_path }}/user-data"
meta_data_path: "{{ seed_iso_dir_path }}/meta-data"
seed_iso_path: "{{ seed_iso_dir_path }}/seed-{{ lookup('pipe','date +%s') }}.iso"
seed_iso_path: "{{ seed_iso_dir_path }}/seed-{{ current_test_timestamp }}.iso"

- name: "Create user-data file for cloud-init local datasource"
ansible.builtin.template:
Expand Down Expand Up @@ -46,4 +46,4 @@
ansible.builtin.stat:
path: "{{ seed_iso_path }}"
register: seed_st
failed_when: not seed_st.stat.exists
failed_when: not seed_st.stat.exists
2 changes: 1 addition & 1 deletion linux/utils/enable_vgauth_logging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- name: "Set default VGAuthService debug log directory"
ansible.builtin.set_fact:
vgauth_log_dir: "/tmp/vmware-vgauthsvc-{{ lookup('pipe', 'date +%s') }}"
vgauth_log_dir: "/tmp/vmware-vgauthsvc-{{ current_test_timestamp }}"

- name: "Set facts of VGAuthService log files"
ansible.builtin.set_fact:
Expand Down
4 changes: 2 additions & 2 deletions linux/vhba_hot_add_remove/lsilogic_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
new_disk_ctrl_type: "lsilogic"
tasks:
- include_tasks: vhba_device_hot_add_remove.yml
- name: "Test with LSI Logic controller"
include_tasks: vhba_device_hot_add_remove.yml
4 changes: 2 additions & 2 deletions linux/vhba_hot_add_remove/lsilogicsas_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
new_disk_ctrl_type: "lsilogicsas"
tasks:
- include_tasks: vhba_device_hot_add_remove.yml
- name: "Test with LSI Logic SAS controller"
include_tasks: vhba_device_hot_add_remove.yml
4 changes: 2 additions & 2 deletions linux/vhba_hot_add_remove/nvme_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
new_disk_ctrl_type: "nvme"
tasks:
- include_tasks: vhba_device_hot_add_remove.yml
- name: "Test with NVMe controller"
include_tasks: vhba_device_hot_add_remove.yml
4 changes: 2 additions & 2 deletions linux/vhba_hot_add_remove/paravirtual_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
new_disk_ctrl_type: "paravirtual"
tasks:
- include_tasks: vhba_device_hot_add_remove.yml
- name: "Test with PVSCSI controller"
include_tasks: vhba_device_hot_add_remove.yml
4 changes: 2 additions & 2 deletions linux/vhba_hot_add_remove/sata_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
hosts: localhost
gather_facts: false
vars:
timestamp: "{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
new_disk_ctrl_type: "sata"
tasks:
- include_tasks: vhba_device_hot_add_remove.yml
- name: "Test with SATA controller"
include_tasks: vhba_device_hot_add_remove.yml
50 changes: 33 additions & 17 deletions windows/check_quiesce_snapshot/check_quiesce_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,48 +9,64 @@
hosts: localhost
gather_facts: false
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
- name: "Test case block"
block:
- name: "Test setup"
include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: true

- include_tasks: check_vmx_disk_enable_uuid.yml
- name: "Check disk.EnableUUID in VMX file"
include_tasks: check_vmx_disk_enable_uuid.yml
when: guest_os_product_type | lower == "server"

- include_tasks: ../utils/win_enable_vss_log.yml
- name: "Enable vss logging"
include_tasks: ../utils/win_enable_vss_log.yml
when:
- vmtools_version is defined and vmtools_version
- vmtools_version is version('11.0.0', '>=')

- name: Set fact of the remote path in guest OS
- name: "Set fact of the remote path in guest OS"
ansible.builtin.set_fact:
quiesce_scripts_freeze_thaw_path: "C:\\Windows\\"
quiesce_scripts_tools_path: "C:\\Program Files\\VMware\\VMware Tools\\backupScripts.d\\"
- include_tasks: ../utils/win_get_time.yml
- name: Set fact of the time before taking snapshot

- name: "Get Windows guest OS time"
include_tasks: ../utils/win_get_time.yml

- name: "Set fact of the time before taking snapshot"
ansible.builtin.set_fact:
before_snapshot_time: "{{ time_variable }}"
- name: Set fact of the snapshot name

- name: "Set fact of the quiesce snapshot name"
ansible.builtin.set_fact:
qs_snapshot_name: "quiesce_{{ lookup('pipe', 'date +%Y-%m-%d-%H-%M-%S') }}"
qs_snapshot_name: "quiesce_{{ current_test_timestamp }}"

- include_tasks: copy_custom_scripts_to_guest.yml
- name: "Copy custom scripts to guest OS"
include_tasks: copy_custom_scripts_to_guest.yml

- name: Set fact of collecting quiesce log file
- name: "Set fact of collecting quiesce log file"
ansible.builtin.set_fact:
collect_vss_logs: true
# Take quiesce snapshot of VM
- include_tasks: ../../common/vm_take_snapshot.yml

- name: "Take quiesce snapshot of VM"
include_tasks: ../../common/vm_take_snapshot.yml
vars:
snapshot_name: "{{ qs_snapshot_name }}"
is_quiesce: true
dump_memory: false

- include_tasks: check_custom_scripts_executed.yml
- include_tasks: ../../common/vm_remove_snapshot.yml
- name: "Check custom scripts executed"
include_tasks: check_custom_scripts_executed.yml

- name: "Remove quiesce snapshot at test success"
include_tasks: ../../common/vm_remove_snapshot.yml
vars:
snapshot_name: "{{ qs_snapshot_name }}"
rescue:
- include_tasks: collect_vss_logs.yml
- name: "Collect vss logs"
include_tasks: collect_vss_logs.yml
when: collect_vss_logs is defined and collect_vss_logs
- include_tasks: ../../common/test_rescue.yml

- name: "Test case failure"
include_tasks: ../../common/test_rescue.yml
Loading

0 comments on commit dfc41f7

Please sign in to comment.