Skip to content

Commit

Permalink
Changes test case for Agent xmlmode
Browse files Browse the repository at this point in the history
Updated Reporter test cases and moved them to CommandLine_Features.robot to make them nogui only
  • Loading branch information
ArekKuczynski committed Aug 23, 2024
1 parent 30dc23a commit 65cb0c5
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 187 deletions.
57 changes: 10 additions & 47 deletions Tests/Regression/Agent/CommandLine_Features.robot
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Agent Command Line AGENTDIR -d

Log To Console Run Agent with custom dir.
Run Agent ${agnt_options}
Sleep 10s
Stop Agent
Show Log ${OUTPUT DIR}${/}stdout_agent.txt
@{agentdir_dirs}= List Directories In Directory ${agentdir}
Expand Down Expand Up @@ -103,60 +104,22 @@ Agent Command Line ROBOT -r
Agent Command Line XMLMODE -x
[Tags] ubuntu-latest macos-latest windows-latest Issue #14
VAR ${scenario_dir} ${CURDIR}${/}testdata${/}Issue-#14${/}xmlmode.rfs
VAR @{agnt_options} -x
VAR @{mngr_options} -n -s ${scenario_dir}
VAR ${agentdir} ${CURDIR}${/}testdata${/}Issue-#14${/}xmlmode_dir
VAR @{agnt_options} -x -d ${agentdir}

Log To Console Run Agent with xmlmode.
Run Manager CLI ${mngr_options}
Run Agent ${agnt_options}
Wait For Manager 4min
Stop Agent
Show Log ${OUTPUT DIR}${/}stdout_agent.txt
Show Log ${OUTPUT DIR}${/}stdout_manager.txt
${M_result_stdout}= Get File ${OUTPUT DIR}${/}stdout_manager.txt

Log To Console Checking result data base
${dbfile} Find Result DB result_pattern=*_xmlmode
${summary_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricType='Summary' ORDER BY MetricTime LIMIT 1
${running_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricValue='Running' ORDER BY MetricTime LIMIT 1
${stopping_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricValue='Stopping' ORDER BY MetricTime LIMIT 1

Should Be True ${summary_result} > ${stopping_result}

[Teardown] Run Keywords Stop Agent Stop Manager

Agent Command Line XMLMODE -x TEMP. COPY SHOULD FAIL
[Tags] ubuntu-latest macos-latest windows-latest Issue #14
VAR ${scenario_dir} ${CURDIR}${/}testdata${/}Issue-#14${/}xmlmode.rfs
VAR @{agnt_options} -g 1
VAR @{mngr_options} -n -s ${scenario_dir}

Log To Console Run Agent with xmlmode.
Run Manager CLI ${mngr_options}
Run Agent ${agnt_options}
Wait For Manager 4min
Sleep 10s
Stop Agent
Show Log ${OUTPUT DIR}${/}stdout_agent.txt
Show Log ${OUTPUT DIR}${/}stdout_manager.txt
${M_result_stdout}= Get File ${OUTPUT DIR}${/}stdout_manager.txt

Log To Console Checking result data base
${dbfile} Find Result DB result_pattern=*_xmlmode
${summary_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricType='Summary' ORDER BY MetricTime LIMIT 1
${running_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricValue='Running' ORDER BY MetricTime LIMIT 1
${stopping_result} Query Result DB ${dbfile}
... SELECT MetricTime FROM MetricData WHERE MetricValue='Stopping' ORDER BY MetricTime LIMIT 1

Should Be True ${summary_result} > ${stopping_result}
@{agentdir_dirs}= List Directories In Directory ${agentdir}
List Should Contain Value ${agentdir_dirs} scripts msg=Can't find scripts dir in custom Agent dir
${agentdir_scripts}= List Files In Directory ${agentdir}${/}scripts
List Should Not Contain Value ${agentdir_scripts} RFSListener3.py
List Should Not Contain Value ${agentdir_scripts} RFSListener2.py

[Teardown] Run Keywords Stop Agent Stop Manager
[Teardown] Stop Agent

Agent Command Line AGENTNAME -a
[Tags] ubuntu-latest macos-latest Issue #14
Expand Down
13 changes: 0 additions & 13 deletions Tests/Regression/Agent/testdata/Issue-#14/xmlmode.rfs

This file was deleted.

14 changes: 0 additions & 14 deletions Tests/Regression/Agent/testdata/Issue-#14/xmlmode.robot

This file was deleted.

6 changes: 3 additions & 3 deletions Tests/Regression/Manager/GUI_Features.robot
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Manager Command Line PORT -p
... GUI_Common.Stop Agent

Manager Command Line IPADDRESS -e
#[Tags] windows-latest ubuntu-latest macos-latest Issue #14
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
[Setup] Set Global Filename And Default Save Path ${robot_data}[0]

${ipv4} ${ipv6} Get IP addresses
Expand Down Expand Up @@ -66,7 +66,7 @@ Manager Command Line DIR -d

[Teardown] Run Keywords
... Terminate Process ${process_manager} AND
... Remove Directory ${global_path}${/}Issue-#14 recursive=${True}
... Remove Directory ${global_path}${/}Issue-#14 recursive=${True}

Manager Command Line STARTTIME -t
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
Expand Down Expand Up @@ -119,7 +119,7 @@ Manager Command Line AGENTS -a
[Setup] Set Global Filename And Default Save Path ${robot_data}[0]

${scenariofile}= Normalize Path ${CURDIR}${/}testdata${/}Issue-#14${/}Issue-#14.rfs
VAR @{mngr_options} -s ${scenariofile} -a 2
VAR @{mngr_options} -s ${scenariofile} -a 2

Open Manager GUI ${mngr_options}
Log To Console Run Agents only once, but 2 are needed. The Manager should display a special message.
Expand Down
119 changes: 119 additions & 0 deletions Tests/Regression/Reporter/CommandLIne_Features.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
*** Settings ***
Resource GUI_Common.robot

Suite Setup Set Platform
Test Teardown Close GUI

*** Test Cases ***
Reporter Command Line INI -i
[Tags] ubuntu-latest macos-latest windows-latest Issue #14
VAR ${testdata} Issue-#14${/}result_dir
VAR ${resultdata} ini_testcase
VAR ${basefolder} ${CURDIR}${/}testdata${/}${testdata}
VAR ${resultfolder} ${basefolder}${/}${resultdata}

${test_dir}= Normalize Path ${CURDIR}${/}testdata${/}Issue-#14
${ini_content}= Get File ${test_dir}${/}RFSwarmReporter.ini
${ini_content}= Replace String ${ini_content} template_here ${test_dir}${/}Issue-#14.template
${ini_content}= Replace String ${ini_content} template_dir_here ${test_dir}
Remove File ${test_dir}${/}RFSwarmReporter.ini
Log ${ini_content}
Append To File ${test_dir}${/}RFSwarmReporter.ini ${ini_content}

Log To Console Run Reporter with alternate ini file with variable: template = ${test_dir}${/}RFSwarmReporter.ini.
Open GUI -i ${test_dir}${/}RFSwarmReporter.ini -d ${resultfolder} -n --html
Log To Console Check that Robots section exist in html.
@{html_files}= List Files In Directory ${resultfolder} absolute=True pattern=*.html
Log To Console ${\n}All result files: ${html_files}${\n}
Length Should Be ${html_files} 1
${html_content}= Get File ${html_files}[0]

Should Contain ${html_content} <title>Report for Issue-#14</title>
Should Contain ${html_content} <h1>4 Issue-#14</h1>
Should Contain ${html_content} <div class="body"><p>This is a test for Issue-#14</p></div>

Manager Command Line DIR -d
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
${testdata} Set Variable Issue-#14${/}result_dir
${resultdata} Set Variable 20240622_182505_test_scenario
${basefolder} Set Variable ${CURDIR}${/}testdata${/}${testdata}
${resultfolder} Set Variable ${basefolder}${/}${resultdata}

Open GUI -n -d ${resultfolder}
${inifile}= Get Reporter INI Location
${inifile_content}= Get File ${inifile}
${inifile_content}= Split String ${inifile_content}

${resultdir_offset} Get Index From List ${inifile_content} resultdir
Should Be Equal resultdir ${inifile_content}[${resultdir_offset}] msg=resultdir value is missing!
Should Be Equal ${basefolder} ${inifile_content}[${resultdir_offset + 2}]
... msg=resultdir path value did not save correctly [settings != scenario]!

${results_offset} Get Index From List ${inifile_content} results
Should Be Equal results ${inifile_content}[${results_offset}] msg=results value is missing!
Should Be Equal ${resultfolder}${/}${resultdata}.db ${inifile_content}[${results_offset + 2}]
... msg=results path value did not save correctly [settings != scenario]!

Reporter Command Line TEMPLATE -t
[Tags] ubuntu-latest macos-latest windows-latest Issue #14
${basefolder}= Normalize Path ${CURDIR}${/}testdata${/}Issue-#14
${templatefile}= Normalize Path ${basefolder}${/}Issue-#14.template

Open GUI -n -t ${templatefile}
${inifile}= Get Reporter INI Location
${inifile_content}= Get File ${inifile}
${inifile_content}= Split String ${inifile_content}

${template_offset} Get Index From List ${inifile_content} template
Should Be Equal template ${inifile_content}[${template_offset}] msg=template value is missing!
${inifile_content}[${template_offset + 2}]= Evaluate r"${inifile_content}[${template_offset + 2}]".replace('x35', '#')
Should Be Equal ${templatefile} ${inifile_content}[${template_offset + 2}]
... msg=template path value did not save correctly [settings != scenario]!

${templatedir_offset} Get Index From List ${inifile_content} templatedir
Should Be Equal templatedir ${inifile_content}[${templatedir_offset}] msg=templatedir value is missing!
${inifile_content}[${templatedir_offset + 2}]= Evaluate r"${inifile_content}[${templatedir_offset + 2}]".replace('x35', '#')
Should Be Equal ${basefolder} ${inifile_content}[${templatedir_offset + 2}]
... msg=templatedir path value did not save correctly [settings != scenario]!

Manager Command Line HTML report --html
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
${testdata} Set Variable Issue-#14${/}result_dir
${resultdata} Set Variable 20240622_182505_test_scenario
${basefolder} Set Variable ${CURDIR}${/}testdata${/}${testdata}
${resultfolder} Set Variable ${basefolder}${/}${resultdata}

Open GUI -n -d ${resultfolder} --html
@{result_files}= List Files In Directory ${resultfolder}
Log To Console ${\n}All result files: ${result_files}${\n}
List Should Contain Value ${result_files} ${resultdata}.html

Manager Command Line HTML report --docx
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
${testdata} Set Variable Issue-#14${/}result_dir
${resultdata} Set Variable 20240622_182505_test_scenario
${basefolder} Set Variable ${CURDIR}${/}testdata${/}${testdata}
${resultfolder} Set Variable ${basefolder}${/}${resultdata}

Open GUI -n -d ${resultfolder} --docx
@{result_files}= List Files In Directory ${resultfolder}
Log To Console ${\n}All result files: ${result_files}${\n}
List Should Contain Value ${result_files} ${resultdata}.docx

Manager Command Line HTML report --xlsx
[Tags] windows-latest ubuntu-latest macos-latest Issue #14
${testdata} Set Variable Issue-#14${/}result_dir
${resultdata} Set Variable 20240622_182505_test_scenario
${basefolder} Set Variable ${CURDIR}${/}testdata${/}${testdata}
${resultfolder} Set Variable ${basefolder}${/}${resultdata}

Open GUI -n -d ${resultfolder} --xlsx
@{result_files}= List Files In Directory ${resultfolder}
Log To Console ${\n}All result files: ${result_files}${\n}
List Should Contain Value ${result_files} ${resultdata}.xlsx
41 changes: 38 additions & 3 deletions Tests/Regression/Reporter/GUI_Common.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,41 @@ ${process} None
${sssleep} 0.5

*** Keywords ***
Set Platform
Set Platform By Python
Set Platform By Tag

Set Platform By Python
${system}= Evaluate platform.system() modules=platform

IF "${system}" == "Windows"
Set Suite Variable ${platform} macos
END
IF "${system}" == "Windows"
Set Suite Variable ${platform} windows
END
IF "${system}" == "Linux"
Set Suite Variable ${platform} ubuntu
END


Set Platform By Tag
# [Arguments] ${ostag}
Log ${OPTIONS}
Log ${OPTIONS}[include]
Log ${OPTIONS}[include][0]
${ostag}= Set Variable ${OPTIONS}[include][0]

IF "${ostag}" == "macos-latest"
Set Suite Variable ${platform} macos
END
IF "${ostag}" == "windows-latest"
Set Suite Variable ${platform} windows
END
IF "${ostag}" == "ubuntu-latest"
Set Suite Variable ${platform} ubuntu
END

Make Clipboard Not None
Evaluate clipboard.copy("You should never see this after copy") modules=clipboard

Expand Down Expand Up @@ -261,14 +296,14 @@ Open GUI windows
Open GUI ubuntu
[Arguments] @{appargs}
Set Suite Variable ${platform} ubuntu
Set Confidence 0.9
#Set Confidence 0.9
# ${process}= Start Process python3 ${pyfile} -g 6 @{appargs} alias=Reporter stdout=${OUTPUT DIR}${/}stdout.txt stderr=${OUTPUT DIR}${/}stderr.txt
${process}= Start Process ${cmd_reporter} -g 6 @{appargs} alias=Reporter stdout=${OUTPUT DIR}${/}stdout.txt stderr=${OUTPUT DIR}${/}stderr.txt
Set Suite Variable $process ${process}
# Sleep 60
# Capture Screen
Set Screenshot Folder ${OUTPUT DIR}
Take A Screenshot
#Set Screenshot Folder ${OUTPUT DIR}
#Take A Screenshot

Open GUI macos
[Arguments] @{appargs}
Expand Down
Loading

0 comments on commit 65cb0c5

Please sign in to comment.