A simple need in Quality Center.
Background:
In HP Quality Center -> Test Lab, you can create a testset having many testcases. You can run the testset or individual testcase by clicking on the Run (which starts Test Run Scheduler). Considering that a test script (considering Python) exists for the testcase, when Run is clicked a Automatic Runner popup is seen where you have three columns:
TestName, Run on Host, Status
I am aware of the OTA API which can be really useful to write a testscript.
My question is how can I modify the Final Status seen on the Automatic Runner via the testscript (and OTA API).
I have this requirement because when my following testscript is called, I wish to display a message - 'Testcase Finished' instead of 'Error: Failed to Post Run'. The 2nd message is displayed because my testscript purposely cancels the Run. Here is the script:
def Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun):
TDOutput.Print('Do something before cancel')
CurrentRun.CancelRun()
TDOutput.Print('Do something after cancel')
The answer to this question is that.... it cannot be done!! The reason being, QC has its own way of knowing if the testscript passed successfully, it will make the status Passed. Like in the case of...
def Test_Main(Debug, CurrentTestSet, CurrentTSTest, CurrentRun):
"""
"""
TDOutput.Print("Bye")
The status is Passed.
If any Traceback was caught in the script, it will show the error message and change the status to Failed or Not Complete. I guess QC did not make this tweak-able.
Only thing what we can do is store the output shown on the prompt and attach it to the Run.
Related
I have created a robot framework tool with one testcase.
now 'its showing testcase execution status "Pass" and well report path.
I need to turn off the testcase execution status as well as report path.
Expected to turn off the below details showing in termial
I have a Python 3.6 Lambda function that needs to download dependencies into /tmp (I use layers as well, but /tmp is needed due to size limitations) and import them. I have the code that does the download-zip-and-extract-to-temp part before the handler with the expectation that it only needs to be downloaded on cold start. Say it looks like below (pseudocode):
log('Cold start')
download_deps() # has some log statements of its own
log('init end')
def handler(event, context):
...
Most of the time it works fine. However, every now and then the logs stop showing up somewhere during initialization. (For e.g. it says "Cold start", but not "init end"; it 'dies' somewhere in download_deps). I have exception handling in there and log everything, but nothing shows up. When the handler runs next time it runs into ImportError.
While trying to fix this, I noticed something peculiar. The initialization code is running twice on a single invocation of the Lambda. Given the above pseudocode, the logs look like:
Cold start
<logs from download_deps that indicate it downloaded things into /tmp>
START <RequestId> ...
<RequestId> Cold start
<logs from download_deps that indicate it skipped download because /tmp was already populated by deps>
init end
END <RequestId>
The "init end" part doesn't show up the first time, so logs somehow vanish again. Since it skips download the second time (/tmp is preserved), I know it's not 2 actual cold starts happening. The second time it logs 'Cold start' it includes the RequestId, but not the first time; almost as if the first initialization wasn't caused by a request, even though timing of the request on API gateway matches the timing of the first "Cold start". What is going on here?
I noticed the two 'Cold start's were always ~10 seconds apart. It looks like if the initialization code takes more than ~10 seconds, it is restarted. Also, based on the duration reported in the logs, the time taken by the second initialization is included in the billed duration.
To solve my problem I moved download_deps() inside the handler, making sure that it only does anything if it needs to.
I have a long running python script(let's call it upgrade.py).
The script has many steps or parts (essentially XML API calls to a router to run certain commands on the router).
I need suggestions on how to achieve the following:
I'm looking to compartmentalize the script such that if any step fails the script execution should pause and it notifies the user via email (I can handle the emailing part).
The user can then fix the issue on his router and should be able to RESUME his script i.e. script resumes execution starting from the step that failed.
In short how do I go about compartmentalizing the script into steps (or test cases) so that:
The script PAUSES at a certain step that failed
The user is able to later RESUME the script (starting from that failed step)
Most test automation approaches will break off the test suite and then re-try all test cases after a fix has been applied. This has the added benefit that when a fix impacts already run scripts, this is also discovered.
Given the lengthy nature of your test, this may not be practical. The below scipt will use the Dialogs and the Wait Until Keyword Succeeds to allow for 3 retries before continuing with the next step in the test case.
*** Settings ***
Library Dialogs
*** Test Cases ***
Test Case
Wait Until Keyword Succeeds 3 times 1 second Failing Keyword
Log To Console End Test Case
*** Keywords ***
Failing Keyword
Fail Keyword failed
[Teardown] Dialogs.Pause Execution Please Check your settings.
I've been working on an Openshift app where the action hooks are written in Python.
The action hooks run, and work, but I can not get any output to display when I create the app. So when I run rhc app create ... the app is successfully created, but none of the status or debug messages I try to output ever display.
The code gets called like this:
b = library.Object()
b.build()
I have tried:
Adding a logging function to the object and adding b.showlog() to the code above.
print "Message with value: {0}".format(variable) from inside the build hook script
print >>sys.stderr, "Something bad happened: '{0}'...".format(return_code) from inside the build hook script
When I've written action hooks in bash, echo ... works fine.
This exact question doesn't seem to have been answered before, though there are questions that are superficially similar.
You don't get any action hook output during an app create. You will only see it during a "git push" when you update code. I would suggest having the output write to a log file in your ~/app-root/data directory instead so that you can view it later. Also, if you catch it at the right time, you can ssh into your application while it is being created the first time.
I am running an automated test using an Android emulator driving an app with a Monkey script written in Python.
The script is copying files onto the emulator, clicks buttons in the app and reacts depending on the activities that the software triggers during its operation. The script is supposed to be running the cycle a few thousand times so I have this in a loop to run the adb tool to copy the files, start the activities and see how the software is reacting by calling the getProperty method on the device with the parameter 'am.current.comp.class'.
So here is a very simplified version of my script:
for target in targets:
androidSDK.copyFile(emulatorName, target, '/mnt/sdcard')
# Runs the component
device.startActivity(component='com.myPackage/com.myPackage.myactivity')
while 1:
if device.getProperty('am.current.comp.class') == 'com.myPackage.anotheractivity':
time.sleep(1) # to allow the scree to display the new activity before I click on it
device.touch(100, 100, 'DOWN_AND_UP')
# Log the result of the operation somewhere
break
time.sleep(0.1)
(androidSDK is a small class I've written that wraps some utility functions to copy and delete files using the adb tool).
On occasions the script crashes with one of a number of exceptions, for instance (I am leaving out the full stack trace)
[com.android.chimpchat.adb.AdbChimpDevice]com.android.ddmlib.ShellCommandUnresponsiveException
or
[com.android.chimpchat.adb.AdbChimpDevice] Unable to get variable: am.current.comp.class
[com.android.chimpchat.adb.AdbChimpDevice]java.net.SocketException: Software caused connectionabort: socket write error
I have read that sometimes the socket connection to the device becomes unstable and may need a restart (adb start-server and adb kill-server come in useful).
The problem I'm having is that the tools are throwing Java exceptions (Monkey runs in Jython), but I am not sure how those can be trapped from within my Python script. I would like to be able to determine the exact cause of the failure inside the script and recover the situation so I can carry on with my iterations (re-establish the connection, for instance? Would for instance re-initialising my device with another call to MonkeyRunner.waitForConnection be enough?).
Any ideas?
Many thanks,
Alberto
EDIT. I thought I'd mention that I have discovered that it is possible to catch Java-specific exceptions in a Jython script, should anyone need this:
from java.net import SocketException
...
try:
...
except(SocketException):
...
It is possible to catch Java-specific exceptions in a Jython script:
from java.net import SocketException
...
try:
...
except(SocketException):
...
(Taken from OP's edit to his question)
This worked for me:
device.shell('exit')# Exit the shell