ZebraTester Blog

Everything Web Performance


seo3
cloud1
mobile6
seo4
ideoa5



New in ZebraTester: Inline Scripts

ZebraTester has always been a flexible and extensible tool, with its capacity to support plug-ins written in the Java programming language. Starting with version 5.4-i ZebraTester will have an additional extension mechanism – inline scripts. Inline scripts are similar to plug-ins, but they are much easier to develop and to test. Many of the tasks that would have previously been handled with a plug-in can now instead be done with inline scripts. Key advantages of inline scripts over plug-ins include:

  • Direct scripting inside the load test session
  • No compiling required – inline scripts are instantly ready to run and to test
  • A test environment that makes it easy to validate and run scripts

Because Inline Scripts are instantly ready to run, and instantly ready to test – and because they are supported by an almost perfect test environment – developing and testing of Inline Scripts is rapid and easy.

Direct scripting inside the load test session

To get started with inline scripting, first click the “Add Inline Script…” button in the right-hand part of the ZebraTester UI. This will open the “Add Inline Script” dialog window from where all actions related to inline scripting can be accomplished. The code text-field is where all inline code statements should be put. Of particular interest is the test environment built into ZebraTester. The test environment allows for the tracing of execution flow, and makes it extremely easy to check “at a glance” whether the script successfully accomplishes the intended task. The environment is accessible by clicking the “Test script” button from within the scripting UI. Because inline scripts are interpreted, and because the test environment is integrated into ZebraTester, the development of inline scripts does not follow the traditional compile-test-run cycle of traditional software development. For this reason, the inline scripting feature will quietly revolutionize the way ZebraTester scripts are written and lead to immediate productivity gains for the individual performance engineer.

Picture1

Script added to the session: Can be handled later:
inline scripts scripts

Scripting Language Syntax

Inline scripts are written in Prx-BASIC, a programming language developed by Apica. Prx-BASIC is a modern form of BASIC (Beginner’s All-Purpose Symbolic Instruction Code) and is a pragmatic language based on the principle of making things as easy for the end-user as possible. Because of its intuitive commands, simple structure and great flexibility, Prx-BASIC is the ideal language for developing inline scripts. Please refer to “Prx-Basic” Programming Language Manual” for details on the language.

Script Execution Scopes and Script Priority:

inline script

Scoping rules for inline scripts are very similar to those for plug-ins, except that “Before Item” and “After Item” both do not contain a URL context. An “Item” can be either a “Page Break” or an “URL” for added flexibility. In case multiple scripts are bound to the same “location” inside the load test program then the “Priority” allows you to control the Execution Order at that “location”. In this way, scripts that represent logically separate operations can be kept separate without interfering with each other.

Script Timeout

The script timeout feature is a safeguard that prevents poorly written scripts from blocking the load test. In case the execution time exceed the timeout value, the test will not continue and we can see the reason and easily fix it.

Example of Endless Loop/Benchmark

The following script will never finish, since the predicate of the do loop is the Boolean value “true”. With a timeout value of 10 seconds, almost half a million iterations of the loop were run. We can see that, while the speed of the inline scripting engine falls far short of Java, the speed is nonetheless quite sufficient.

Picture7 Picture81

The Test Environment – An almost perfect run-time simulation of the recorded session

When testing an inline script:

  • The value of the Script “Input Vars” are pre-initialized based on the declared “Var Initialization” and are based on the declared “Var Assigners” and “Var Extractors”:
  • Picture9a

  • Run-time information that cannot be pre-calculated can be set by Form Input Fields, like “User Nr.”, “Loop Nr.” and “URL Call passed/failed”
  • All data of the recorded URLs are accessible in the test environment (HTTP request header, HTTP request content, HTTP response header and HTTP response content).
  • Access to Cookies is also simulated in the Test Environment. The “Cookie Store” is initialized based on the recorded session.

Inline scripts have many more features like, Script Templates, ABORT support, Trace ON/OFF, Support of Recorder Plug-Ins, Integrated functions for XML and JSON processing and Autocomplete for Integrated functions.

It is simply impossible to cover all great features of inline scripts in one article, but keep tuned in to the ZebraTester community for regular updates. We at Apica are very excited about this new feature! Please do not hesitate to download ZebraTester and experience the simplicity and power inline scripting affords.

Written by Amir Ashfaq, Software Developer and Per Hjeltman, Senior Performance Engineer, Apica

Note: Support for Inline Scripting will be available for Apica LoadTest Portal shortly

Leave a Reply

Your email address will not be published. Required fields are marked *