-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] Fix incorrect user and sysprep error in GOSC test cases (#519)
Signed-off-by: Diane Wang <[email protected]>
- Loading branch information
Showing
16 changed files
with
385 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,52 @@ | ||
# Copyright 2021-2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Get auto Admin logon value after gosc | ||
- include_tasks: ../utils/win_execute_cmd.yml | ||
# Check logon as Administrator automatically is set in guest OS | ||
- name: "Initialize the registry value of logon as Administrator automatically" | ||
ansible.builtin.set_fact: | ||
auto_admin_logon: 0 | ||
|
||
- name: "Get logon as Administrator automatically registry value" | ||
include_tasks: ../utils/win_execute_cmd.yml | ||
vars: | ||
win_powershell_cmd: "(get-itemproperty -path 'HKLM:\\software\\microsoft\\Windows NT\\CurrentVersion\\Winlogon').AutoAdminLogon" | ||
- name: Set fact of the Admin auto logon | ||
win_powershell_cmd: >- | ||
(Get-ItemProperty -path 'HKLM:\\software\\microsoft\\Windows NT\\CurrentVersion\\Winlogon').AutoAdminLogon | ||
- name: "Set fact of logon as Administrator automatically registry value" | ||
ansible.builtin.set_fact: | ||
auto_admin_logon: "{{ win_powershell_cmd_output.stdout_lines[0] }}" | ||
- ansible.builtin.debug: | ||
msg: "Get auto Admin logon enabled value: {{ auto_admin_logon }}" | ||
when: enable_debug | ||
when: | ||
- win_powershell_cmd_output.stdout_lines is defined | ||
- win_powershell_cmd_output.stdout_lines | length != 0 | ||
|
||
- name: Get auto admin logon count value after GOSC | ||
ansible.windows.win_shell: "(get-itemproperty -path 'HKLM:\\software\\microsoft\\Windows NT\\CurrentVersion\\Winlogon').AutoLogonCount" | ||
- name: "Check logon as Administrator automatically is enabled" | ||
ansible.builtin.assert: | ||
that: | ||
- auto_admin_logon | int == 1 | ||
success_msg: "Logon as Administrator automatically is enabled in guest OS." | ||
fail_msg: >- | ||
Logon as Administrator automatically is not enabled in guest OS, | ||
got registry value '{{ auto_admin_logon }}', not expected value 1. | ||
- name: "Get number of times to logon as Administrator automatically" | ||
ansible.windows.win_shell: >- | ||
(Get-ItemProperty -path 'HKLM:\\software\\microsoft\\Windows NT\\CurrentVersion\\Winlogon').AutoLogonCount | ||
register: get_auto_logon_count | ||
delegate_to: "{{ vm_guest_ip }}" | ||
until: | ||
- get_auto_logon_count.stdout_lines is defined | ||
- get_auto_logon_count.stdout_lines | length != 0 | ||
- get_auto_logon_count.stdout_lines[0] | int == customize_autologon_count | int - 1 | ||
- get_auto_logon_count.stdout_lines[0] | int == win_gosc_spec.gosc_autologon_count | int - 1 | ||
retries: 100 | ||
delay: 3 | ||
ignore_errors: true | ||
|
||
- name: "Check auto admin logon count value after GOSC" | ||
- name: "Check number of times to logon as Administrator automatically" | ||
ansible.builtin.assert: | ||
that: | ||
- get_auto_logon_count is defined | ||
- get_auto_logon_count.stdout_lines | length != 0 | ||
- get_auto_logon_count.stdout_lines[0] | int == customize_autologon_count | int - 1 | ||
- not get_auto_logon_count.failed | ||
success_msg: "Number of times to logon as Administrator automatically is set correctly: {{ get_auto_logon_count.stdout_lines[0] }}." | ||
fail_msg: >- | ||
Auto admin logon count value after GOSC is still incorrect after 300 seconds. | ||
Current auto admin logon count value is '{{ get_auto_logon_count.stdout_lines[0] | int | default("") }}', | ||
not expected '{{ customize_autologon_count | int - 1 }}'. | ||
- ansible.builtin.debug: | ||
msg: "Get remain auto logon count: {{ get_auto_logon_count.stdout_lines[0] }}" | ||
when: enable_debug | ||
|
||
- name: Check auto admin logon enabled and count is accurate | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ auto_admin_logon | int == 1 }}" | ||
success_msg: "Auto Admin logon is enabled and customized auto logon count is accurate." | ||
fail_msg: "Auto Admin logon is not enabled." | ||
The number of times to logon as Administrator automatically is incorrect after 300 seconds. | ||
Got value '{{ get_auto_logon_count.stdout_lines[0] | default('') }}' in guest OS after GOSC, | ||
expected value is '{{ win_gosc_spec.gosc_autologon_count | int - 1 }}'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright 2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
- name: "Wait for VM IP address after GOSC" | ||
include_tasks: ../../common/vm_wait_guest_ip.yml | ||
vars: | ||
wait_ipv4: "{{ win_gosc_spec.gosc_ip | default('') }}" | ||
|
||
- name: "Update in-memory inventory after GOSC" | ||
include_tasks: ../utils/win_update_inventory.yml | ||
when: gosc_network_type == "dhcp" | ||
|
||
- name: "Wait for guest OS hostname after GOSC" | ||
include_tasks: ../../common/vm_wait_guest_hostname.yml | ||
vars: | ||
wait_guest_hostname: "{{ win_gosc_spec.gosc_hostname }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
# Copyright 2021-2023 VMware, Inc. | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
--- | ||
# Check timezone name after gos customization | ||
- ansible.builtin.debug: | ||
msg: "Configured timezone: {{ customize_timezone_name }}" | ||
when: enable_debug is defined and enable_debug | ||
- name: Check timezone in guest OS | ||
# Check timezone name after GOS customization | ||
- name: "Initialize the timezone name in guest OS" | ||
ansible.builtin.set_fact: | ||
timezone_after_gosc: "" | ||
|
||
- name: "Print timezone name in Windows GOSC spec" | ||
ansible.builtin.debug: | ||
msg: "Configured timezone in GOSC spec: {{ win_gosc_spec.gosc_timezone_name }}" | ||
|
||
- name: "Get timezone info in guest OS" | ||
include_tasks: ../utils/win_execute_cmd.yml | ||
vars: | ||
win_powershell_cmd: "tzutil /g" | ||
- name: Set fact of the timezone in guest OS | ||
|
||
- name: "Set fact of the timezone in guest OS" | ||
ansible.builtin.set_fact: | ||
timezone_after_customize: "{{ win_powershell_cmd_output.stdout_lines[0] if not win_powershell_cmd_output.failed else 'NA'}}" | ||
- ansible.builtin.debug: | ||
msg: "Get timezone after customize: {{ timezone_after_customize }}" | ||
- name: Check returned timezone name is the specified one | ||
timezone_after_gosc: "{{ win_powershell_cmd_output.stdout_lines[0] }}" | ||
when: | ||
- win_powershell_cmd_output.stdout_lines is defined | ||
- win_powershell_cmd_output.stdout_lines | length != 0 | ||
|
||
- name: "Check customized timezone in guest OS" | ||
ansible.builtin.assert: | ||
that: | ||
- "{{ not win_powershell_cmd_output.failed }}" | ||
- "{{ win_powershell_cmd_output.stdout_lines[0] == customize_timezone_name }}" | ||
success_msg: "Check customized timezone in guest OS succeed." | ||
fail_msg: "Check customized timezone in guest OS failed." | ||
- timezone_after_gosc == win_gosc_spec.gosc_timezone_name | ||
success_msg: "Timezone '{{ timezone_after_gosc }}' is set by GOSC successfully in guest OS." | ||
fail_msg: >- | ||
Got timezone in guest OS '{{ timezone_after_gosc }}', | ||
which is not the one set in GOSC sepc '{{ win_gosc_spec.gosc_timezone_name }}'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.