Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] CLI-Testing UI after restarting VMDB #9864

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
49 changes: 49 additions & 0 deletions cfme/tests/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from cfme.utils.version import Version
from cfme.utils.version import VersionPicker

app_menu_v5_10 = {
"config_net": "1",
"set_timezone": "2",
"set_date_time": "3",
"create_db_bak": "4",
"create_db_dump": "5",
"restore_db_from_bak": "6",
"config_db": "7",
"config_db_rep": "8",
"logfile_conf": "9",
"config_app_db_failover_monitor": "10",
"ext_temp_storage": "11",
"config_external_auth": "12",
"update_ext_auth_opt": "13",
"gen_custom_encry_key": "14",
"harden_app_scap_config": "15",
"stop_evm": "16",
"start_evm": "17",
"restart_app": "18",
"showdown_app": "19",
"summary_info": "20",
"quit": "21",
}

app_menu_v5_11 = {
"config_net": "1",
"create_db_bak": "2",
"create_db_dump": "3",
"restore_db_from_bak": "4",
"config_db": "5",
"config_db_rep": "6",
"logfile_conf": "7",
"config_app_db_failover_monitor": "8",
"ext_temp_storage": "9",
"config_external_auth": "10",
"update_ext_auth_opt": "11",
"gen_custom_encry_key": "12",
"harden_app_scap_config": "13",
"stop_evm": "14",
"start_evm": "15",
"restart_app": "16",
"showdown_app": "17",
"summary_info": "18",
"quit": "19",
}
app_con_menu = VersionPicker({Version.lowest(): app_menu_v5_10, "5.11": app_menu_v5_11}).pick()
40 changes: 37 additions & 3 deletions cfme/tests/cli/test_appliance_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from widgetastic.utils import VersionPick

from cfme import test_requirements
from cfme.tests.cli import app_con_menu
from cfme.utils import conf
from cfme.utils import os
from cfme.utils.appliance.console import waiting_for_ha_monitor_started
Expand All @@ -20,6 +21,7 @@
from cfme.utils.log_validator import LogValidator
from cfme.utils.version import LOWEST


pytestmark = [
test_requirements.app_console,
pytest.mark.uncollectif(lambda appliance: appliance.is_pod,
Expand Down Expand Up @@ -1128,9 +1130,9 @@ def test_appliance_console_network_conf_negative(temp_appliance_preconfig_modsco
"Should not able to set incorrect hostname")


@pytest.mark.manual
@pytest.mark.tier(1)
def test_appliance_console_vmdb_httpd():
@pytest.mark.meta(automates=[1337525])
def test_appliance_console_vmdb_httpd(temp_appliance_preconfig_funcscope):
"""
check that httpd starts after restarting vmdb

Expand All @@ -1143,8 +1145,40 @@ def test_appliance_console_vmdb_httpd():
caseimportance: low
caseposneg: negative
initialEstimate: 1/12h
testSteps:
1. Stop the EVM service
2. press "ap"
3. press any key to continue
4. Press "7" for "Configure Database"
5. Press "4" for "Reset Configured Database"
6. Press "Y" for confirmation
7. Enter Region Number
8. Start EVM service
expectedResults:
1.
2.
3.
4.
5.
6.
7. Check "Database reset successfully" message
8. UI should be up and running

"""
pass
appliance = temp_appliance_preconfig_funcscope

# Stopping the EVM service
command_set = ("ap", RETURN, app_con_menu["stop_evm"], TimedCommand("Y", 120))
appliance.appliance_console.run_commands(command_set, timeout=30)

command_set = ("ap", RETURN, app_con_menu["config_db"], "4", "Y", TimedCommand("99", 300))
result = appliance.appliance_console.run_commands(command_set, timeout=30)
assert "Database reset successfully" in result[-1], "DB reset failed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional: I think we should work on result class for appliance_console which will provide output dict of command and output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@digitronik , Thank your suggestion but if we make output dict instead of list then here we are going to override result.
Example:
commands = ("ap", "", "5", "2", "1", "2", "2")
In above example we will not able to store result separately for all 2 and 1 command and we will not get which command executed first due to its dict type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using SSHExpect is a better option here, as its asserting along the way what the prompts are.

Further asserting the output content, we'll have to deal with the list of returned stdout strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mshriver , The code which I used I think that is more simple than SSHExpect due to below reason

  • Expected stdout is not the same for every command so have to define separate SSHExpect.answer() for each call instead for/while loop so code will become more lengthy
  • Hard to manage timeout than current code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that you are doing something about making the answers better defined than just having a stream of numbers. Bad maintainability in case of renumbering was one of the reasons why I started with the SSHExpect thing. I though was aiming even higher -- defining something like a "menu tree model", but didn't get into finishing this.

I think it may be good to unify our approaches in one thing if possible. For this I would like need you to help me understand what should be improved.

About the expectations on stdout... well the question here is whether you want to check what menu question are you answering. Of course when you start checking more things, the test will produce negative (FAIL) results more often. This is not a bad thing every time. I think if the test should fail, it should fail as soon as possible. I think this improves its maintainability. The cost is that even slight change (like a typo correction or such) may cause test to fail while I would say this will be false negative. But I think the false negatives may be eliminated to a good extend a lot by having smart checks. I am not checking all the menu, but the last thing in the SSHExpect buffer (which is actually not too long, especially on PRT, and one should know about it.), which is I think every time, the relevant menu question.

About the timeout, I don't understand what is the problem

 with SSHExpect(appl) as interaction:
     interaction.answer('Press any key to continue.', '', timeout=20)

This will wait 20s for the prompt and when it sees it it will send an empty string that is AFAIR followed by some newline character.

 interaction.answer('Enter the cluster database password: ', pwd)

will wait default timeout and then send pwd. I don't see what is hard here.


# Starting the EVM service
command_set = ("ap", RETURN, app_con_menu["start_evm"], TimedCommand("Y", 120))
appliance.appliance_console.run_commands(command_set, timeout=30)
appliance.wait_for_web_ui()


@pytest.mark.tier(2)
Expand Down