Hello Lustre
Video Transcript
Hello, this is Amir Shehata with another quick tip for the LUTF
Show, Run and Edit
Let's dive right into it and look at a simple "Hello Lustre" script.
First we can show the script like this:
suites['samples'].scripts['sample_01.py'].show()
Each script must have a run()
function. That's what the LUTF executes.
So let's run it and see it in action:
suites['samples'].scripts['sample_01.py'].run()
Now let's say we want to edit that script and change a couple of things and re-run it:
suites['samples'].scripts['sample_01.py'].edit()
I use VIM as the default editor, but you can change that by using the set_editor() function:
lutf.set_editor(<name as string>) example: lutf.set_editor("emacs")
You can then make whatever changes you want in edit mode. In this case, we'll just change what's being printed.
After you're done with the changes, save it and run it:
suites['samples'].scripts['sample_01.py'].run()
The run()
Function Return Value
Each script run()
function must return a value in a specific format. The script writer doesn't need to know what the format is.
As part of the LUTF infrastructure the lutfrc()
function is provided to abstract away that detail.
It takes one mandatory parameter; an integer with 0 signifying success and any other value signifying failure.
It can then take an arbitrary number of key/value pair arguments to package. Let's edit the script to illustrate this.
Now run the script again.
The Script Results
All script results are recorded in a global YAML results dictionary. This can be dumped using the
dumpGlobalTestResults()
Here is what the result looks like. This function can take an optional file name and will write the results into that file.
That's it for this quick tip. In the next quick tip, I'll go over the process of creating a test plan using the LUTF.