Bug 796405 - asserts not working in alert CLI scripts
Summary: asserts not working in alert CLI scripts
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core Server
Version: 4.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: RHQ 4.3.0
Assignee: RHQ Project Maintainer
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks: 796415 796680
TreeView+ depends on / blocked
 
Reported: 2012-02-22 20:07 UTC by Lukas Krejci
Modified: 2013-09-01 10:09 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 796415 796680 (view as bug list)
Environment:
Last Closed: 2013-09-01 10:09:12 UTC
Embargoed:


Attachments (Terms of Use)

Description Lukas Krejci 2012-02-22 20:07:26 UTC
Description of problem:
The CLI is documented to have a series of assert* functions available for the scripts to use. These don't work in the server because we fail to bundle testng.jar in server's lib.

Version-Release number of selected component (if applicable):
4.3.0-SNAPSHOT

How reproducible:
always

Steps to Reproduce:
1. Create a CLI script with the following body:
assertNotNull(null);

2. Define an alert with the above script as a notification
3. Let the alert fire
  
Actual results:
The script seems to have succeeded but the server log contains a NoClassDefFoundError of org/testng/Assert.

Expected results:
The assertion should have executed correctly and produced expected result (in this case, it should throw an AssertionError which should make the notification fail and produce an appropriate error message).

Additional info:

Comment 1 Mike Foley 2012-02-22 20:21:15 UTC
can you document a reference to where you see the assert* statements documented?  i actually can't find this in the JON documentation (and if it is not documented, clone a doc BZ ... if needed)

Comment 2 Lukas Krejci 2012-02-22 20:28:42 UTC
This can be solved in 2 ways:

1) bundle the testng.jar with the RHQ server
2) fix bug 786795

I am in favor of the latter since bundling the whole of testng because of a couple of assert functions seems like a complete waste of diskspace and memory.

Comment 3 Mike Foley 2012-02-22 20:31:04 UTC
<lkrejci> sunny-dee: i found this http://docs.redhat.com/docs/en-US/JBoss_Operations_Network/100/html/Running_JON_Command-Line_Scripts/Running_the_CLI-Running_the_JON_CLI.html#Working_with_the_CLI-Implicit_Variables but that doesn't mention the functions
<sunny-dee> the answer is yes -- except for asserts
<lkrejci> :)
<sunny-dee> assert functions are missing; i have a sticky note to get that fixed

DOC BZ to add documentation on missing CLI assert functionality

https://bugzilla.redhat.com/show_bug.cgi?id=796415

Comment 4 Lukas Krejci 2012-02-23 13:20:15 UTC
As opposed to the original repro steps, the exception that is going to get thrown is ScriptAssertionException.

master http://git.fedorahosted.org/git/?p=rhq/rhq.git;a=commitdiff;h=f89134fbef3b076ccdb048a77296375e83d5c3cd
Author: Lukas Krejci <lkrejci>
Date:   Wed Feb 22 23:54:04 2012 +0100

    [BZ 796405] - Catching any throwable while running a CLI script alert
    notification. This will ensure that whatever exception happens (that the
    script engine doesn't catch and rethrow as ScriptException) will cause the
    notification to fail and be reported as such.

Comment 5 Heiko W. Rupp 2013-09-01 10:09:12 UTC
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.


Note You need to log in before you can comment on or make changes to this bug.