Here's the steps to write and run a BeanShell script from the RxScriptlet:

1) Write a bean shell script.  BeanShell scripts are written with Java syntax, so anything you can do in Java, you can do in BeanShell.  The script, however don't require a class with a main method -- just write the commands you want executed without any method or class wrapper.  You can start from one of the script examples in RI_Stack\apps\qa\org\cablelabs\xlet\RiScriptlet\example_scripts.

2) When writing a script, you will want to call the OcapAppDriver interface.  There is no need to instantiate an OcapAppDriver -- the RiScriptlet has already instantiated it.  In BeanShell, this instance is named rxDrvr, so you can just call OcapAppDriver methods on rxDrvr.  There is also a Logger instance (named rxLog) that you can use to log messages to the log file (see the TuneExample.bsh script).

3) As an option, you can return a pass/fail Boolean and a results String to the RxScriptlet.  These values will be recorded in the RiLog and will be sent back over the telnet interface, if the telnet interface was used to launch the script.  In your script, the pass/fail variable is named "rxReturn" and the results String variable is named "rxReturnString".  For the rxReturn variable, true denotes pass.

4) Next we need to set up the RxScriptlet configuration to call your script.  There are two ways to do this: a) you can add the script location to the command line args of RxScriptlet -- RxScriptlet will then run the script on launch, or b) you can telnet into the RxScriptlet once it is running, and instruct it to run your script.

a) To run via the command-line args, go to the RxScriptlet hostapp.properties, and modify the app.0.args.0 var to point to your script (the path is relative to the RI_Stack\bin\CableLabs\simulator\Win32\debug\env\qa\xlet dir).  Use the following to launch the RiScriptlet:

./runRI.sh -xlet RiScriptlet  [-setup]

Using the -setup option will automatically copy all scripts in into the appropriate directory for use by RIScriptlet (RI_Stack\bin\CableLabs\simulator\Win32\debug\env\qa\xlet\scripts directory).  The RiScriptlet xlet will execute the hostapp.properties specified script at start-up.

b) Instructions for the telnet interface are contained here: How to use the RiScriptlet telnet interface.

5) The RiScriptlet can be configured to write out a small file giving the name of the script that has been run as well as the Pass/Fail result and the detailed result string passed from the script.  To enable this functionality, set app.0.args.1=writeCompletionFlagFile=1 in the RxScriptlet hostapp.properties file.  Upon script completionm, the results file will be located in RI_Stack\bin\CableLabs\simulator\Win32\debug\env\persistent\usr\1\6035\SCRIPT_COMPLETE (or a similar directory for your specified target).  The file will contain a single line with the value of rxReturn, the script name, and the value of rxReturnString, all tab-delimited.  For example:

Pass    scripts/level3/SimpleTest3.bsh    SimpleTest3 passed

See Rx Script Guidelines for guidelines and coding conventions when writing bean shell script.

Steps to be done after writing RxScripts

1. Update the excel spreadsheet named OcapAppDriverScriptInventory.xlsx spreadsheet under $OCAPROOT/apps/qa/org/cablelabs/lib/rxdocs/

with the Java function name being tested, respective level1 scriptname and the function within this script which is calling the java function. Do the same for level2 and level 3 scripts as well.

Please Note: Also it is the responsibility of the RI developer to write the respective Rx unit tests and other tests to test any new functions added. If the RI developer is short on time or is busy with other more pressing bugs/issues, he/she can open an OCORI issue to request support from other Rx team members.

  • No labels