Tivoli Directory Integrator has a built-in AssemblyLine Debugger for walking through the execution of the Assembline, viewing and modifying data in-flight.
Click the Start Debug session button.
The AssemblyLine Data Stepper
The AssemblyLine Debugger offers two modes: the Data Stepper, which provides simple, straightforward testing features, and the advanced AssemblyLine Debugger where we can dig deeper - like stepping through scripts, interactively working with Java libraries and modifying data on-the-file.
The Data Stepper is a useful tool for stepping through the execution of the AssemblyLine Connectors and viewing the data read, written and transformed. This screen is divided into three main areas:
Along the bottom we can see a Console output window that shows the same information that you got when you ran your AssemblyLine using the Run button.
At this point your AssemblyLine has been dispatched to the test Server and is ready to start running at your command. Press the Next button to begin stepping.
Stepping into the AssemblyLine run
Notice how three things happen onscreen: the AssemblyLine Outline shows that the "Read_CSV_File" Connector is currently active; the AssemblyLine Work Bucket displays the Attributes just read by this Connector; and the data display grid for this Connector is also populated with these Attributes. Each time you press the Next button execution continues to the step and the information displays are refreshed.
We can also use the Run To Here button at the top of the data grid for a Connector to jump to this point. Do this now for the "Write_XML_File" Connector.
Stepping to the Write_XML_File Connector
This data grid then displays the Attributes in the Output Map of this Connector along with their values - including the computed value for "FullName".
Now let's look at the Data Stepper toolbar buttons to see what options we have:
Although the Data Stepper provides a wealth of information about how your AssemblyLine will perform, sometimes we need the added power of the advanced Debugger. Note that we can switch between Stepper and Advanced modes as often as we want during a debugging session. Try it now by pressing the Debugger button located at the far right of the Data Stepper button row.
Advanced Debugger mode
When you switch modes the screen is redrawn to provide new controls for the AssemblyLine Outline and the AssemblyLine Work Bucket is replaced with the Watch List on the right side of the window. The Watch List shows the standard Attribute buckets: work and conn. There is also a folder called "Global variables" that if opened displays all variables defined for your AssemblyLine: both the built-in ones like work and system, plus any that you define in your script code. The last Watch folder is for our own use and we can add variables or entire JavaScript expressions that we want to watch by using the Edit Watch List button at the top of this panel.
Turning our attention to the AssemblyLine Outline, the boxes next to components in this tree-view are called Breakpoints and we can tell TDI to pause at any component during execution by clicking on one of these. We can also right-click on any node in and select Run and break here to bring AssemblyLine execution to this point. The toolbar above the outline gives you some of the same controls that you had in the Data Stepper, plus a couple of new ones:
Debugger buttons
Starting from the left these buttons are:
To get a feel for how Breakpoints work try setting one for the "Write to log" script by clicking in the box next to this component.
Setting a breakpoint
Now press the Continue button and your AssemblyLine will run until the IF-Branch is true and you find control at the "Write to log" Script. TDI also opens up a Script area allowing you to step through the code here. We can even set Breakpoints at any script line by double-clicking in the margin to the left of that line.
Setting a Breakpoint in script
Furthermore, we can double-click on any node in the component list to bring up the Debug display. As we can see in the figure above, there is a button titled Breakpoint Condition. We can use this to set a JavaScript expression that must evaluate to either true or false and which will determine if a Breakpoint is active or not. For example, the Breakpoint shown above could be set to be true if:
work.First.startsWith("R")or
mycounter > 1000This is very handy for debugging issues that only occur deep in some input data set.
And if for some reason we need to go back to a previous step then simply stop and restart your debug session. We can also switch back to the Data Stepper by pressing the Data Stepper button.
But before you leave the advanced Debugger there is one more feature worth noting: the JavaScript Evaluation commandline.
JavaScript Evaluation commandline
This innocent looking input field above the log output area allows you to execute any snippet of script in the context of the running AssemblyLine. Try it now by typing this command and pressing Enter:
task.dumpEntry(work)This will display the contents of the Work Entry in the log output window. Now try this:
i = 42You will see the following message appear in the log: i=42 >> 42.0
This tells you that we have defined a new variable ('i') with the value of 42. The expression itself evaluates (as all script statements do) to the value of the assignment. We can also change the values of variable and Attributes already defined in your AL, for example:
work.First="Rudy"After executing this line then the value of the "First" Attribute will be "Rudy". The ability to modify data in-flight means that we can make sure your AssemblyLine steps into all branch logic, allowing us to thoroughly test our solution.
It is highly recommended that you spend some time to familiarize yourself with the AssemblyLine Data Stepper and Debugger. Not only does it provide unique insight into how your AssemblyLine operates, including all the built-in workflows provided by the TDI Server kernel, but it will also help you validate our own implementation and assumptions about your data.
Parent topic: Introducing IBM TDI