SANBlaze Test API
The SANBlaze Test API provides the functionality to incorporate custom scripts into the SANBlaze testing framework.
- count_namespaces(fail_type='error')
Return the number of namespaces on the drive
- Returns:
The number of namespaces on the device. -1 if failed
- Return type:
int
Example
Get the number of namespaces on the device:
num_namespaces = count_namespaces()
- custom_post_test(duts, initial_drive_state)
Allow customers to add additional information at the end of a test by adding values to /virtualun/python.conf :param duts: :param initial_drive_state: :return:
- get_other_t(sanblaze, port, target)
Original code. Moved from SB object to fix an error. More work can be done here
- keep_running()
This function manages the test execution. It determines if additional passes are to be performed and determines when a test pass is complete. This function should only be used once per program and should be in the location indicated in the script template.
- lun()
Get our lun (namespace) number :return:
- remove_all_namespaces(fail_type='error', skip_type='action')
Remove all namespaces present on the drive
- fail_type: int or str
- Specifies the action to be taken if the removal fails
0
or'pass'
: Log a PASS
1
or'notify'
: Log a NOTE
2
or'warn'
: Log a WARNING and increment warnings counter
3
or'error'
: Log an ERROR and increment errors counter
4
or'test'
: Log an ERROR and immediately fail the entire test
- skip_type: int or str
- Specifies the skip behavior if namespace management is not supported
0
or'none'
: Do not skip. Proceed with the action
1
or'action'
: Log a SKIPPED message and return immediately
2
or'test'
: Immediately skip the remainder of the entire test
- Returns:
- statusint
0 if the removal was successful, 1 otherwise
- reasonstr
A brief explanation of the result
- Return type:
dict
- remove_namespace(nsid, fail_type='error', skip_type='action')
Remove the namespace with ID equal to nsid
- Parameters:
nsid (int) – The ID of the namespace to be removed
fail_type (int or str) –
- Specifies the action to be taken if the removal fails
0
or'pass'
: Log a PASS
1
or'notify'
: Log a NOTE
2
or'warn'
: Log a WARNING and increment warnings counter
3
or'error'
: Log an ERROR and increment errors counter
4
or'test'
: Log an ERROR and immediately fail the entire test
skip_type (int or str) –
- Specifies the skip behavior if namespace management is not supported
0
or'none'
: Do not skip. Proceed with the action
1
or'action'
: Log a SKIPPED message and return immediately
2
or'test'
: Immediately skip the remainder of the entire test
- Returns:
- statusint
0 or 1, whether the command succeeded or failed respectively
- reason: str
A brief explanation of the result
- Return type:
dict
- report_IO_results(dut, test_id, fail_type='notify')
Log the current statistics of the IO test with ID test_id
- Parameters:
dut (XML_API) – The controller being issued commands
test_id (str) – The test_id to be reported
fail_type (int or str) –
- Specifies the action to be taken if the report fails
0
or'pass'
: Log a PASS
1
or'notify'
: Log a NOTE
2
or'warn'
: Log a WARNING and increment warnings counter
3
or'error'
: Log an ERROR and increment errors counter
4
or'test'
: Log an ERROR and immediately fail the entire test
Example
Format of logged output:
Mon Sep 13 10:37:24 2021 DETAIL: I/O test R0W0D1_1_0_100_1_16 results: Mon Sep 13 10:37:24 2021 DETAIL: ReadLatency ReadIOs ReadBytes ReadErrors WriteLatency WriteIOs WriteBytes WriteErrors Mon Sep 13 10:37:24 2021 DETAIL: 0 0 0 0 175 5985 784465920 0
- run_simultaneous(func1, args1, func2, args2)
Runs func1 and func2 simultaneously (as close as possible)
- Parameters:
func1 (function) – The first function to be executed. Called with args1
args1 (list of any or tuple of any) – Arguments used to call func1
func2 (function) – The second function to be executed. Called with args2
args2 (list of any or tuple of any) – Arguments used to call func2
- Returns:
(return value of func1, return value of func2)
- Return type:
tuple
Examples
Start two IO tests concurrently:
run_simultaneous(start_IO, [dut, params, config], start_IO, [dut, params, config])
Run two resets concurrently:
run_simultaneous(issue_reset, [dut, "ControllerReset", 1], issue_reset, [dut, "flr"])
Warning
The functions being called do not have (), and the normal arguments that are passed need to be passed in a list. The following are not equivalent to the example above and will cause the script to throw errors:
run_simultaneous(start_IO(), [dut, params, config], start_IO(), [dut, params, config]) run_simultaneous(start_IO(dut, params, config), start_IO(dut, params, config))
- set_version(version)
- Parameters:
version
- setup(_locals)
The setup decorator is responsible for running any setup specific to an individual test. It allocates resources and prepares the controller objects for test actions.
Note
This function is called in a required test section as indicated in the test template, and should not be used outside this setting.
- start_IO(dut, params=None, config=None, fail_type='error')
Start an IO test. Return a status and explanation message.
- Parameters:
dut (XML_API) – Controller on which to issue the reset
params (dict) – A dictionary object that specifies the test parameters (Optional)
config (dict) – A dictionary object that specifies the test configuration (Optional)
fail_type (int or str) –
- Specifies the action to be taken if the start operation fails
0
or'pass'
: Log a PASS
1
or'notify'
: Log a NOTE
2
or'warn'
: Log a WARNING and increment warnings counter
3
or'error'
: Log an ERROR and increment errors counter
4
or'test'
: Log an ERROR and immediately fail the entire test
- Returns:
- statusint
0 or 1, indicating success or failure respectively
- reasonstr
Explanation of the result
- Return type:
dict
Examples
Starting an IO test with default config and params:
start_IO(dut)
Starting an IO test with custom configs and params:
start_IO(dut, config, params)
- start_main(main, myLocals)
Start main is the entry point for running the script in the SBExpress test manager. This function handles the running of the script well as the exception handling and the cleanup after both a successful and a failed script.
Note
This should only be directly called by the user at the end of the script in the required entry point.
- stop_IO(test_id, fail_type='error')
Stop the IO test with the ID test_id. test_id is returned from start_IO
- Parameters:
test_id (str) – The ID of the IO test to be stopped
fail_type (int or str) –
- Specifies the action to be taken if stopping the test fails
0
or'pass'
: Log a PASS
1
or'notify'
: Log a NOTE
2
or'warn'
: Log a WARNING and increment warnings counter
3
or'error'
: Log an ERROR and increment errors counter
4
or'test'
: Log an ERROR and immediately fail the entire test
Notes
Using this function is generally not necessary. The execution of
keep_running()
is closely tied to any running IO and will manage test state appropriately once it has completed.Examples
Stop the IO test associated with
dut1
:stop_IO(dut1.target)