Is it possible to create a variable that is associated with a session profile? Basically the equivalent of a class variable in Java. We have a need to keep a variable between various quick calls. An example would be with an SSH session we have a quickcall that starts a process which sends data to a temporary file. Then there is another quickcall that retrieves the data from the file. We need to store the filename for use between the 2 quickcalls. We could return the filename from the first quickcall and pass it to the second one but not as neat and become difficult for more complex situations. We could create the filename as a global variable but that is messy because the variable could be overwritten by another procedure and we will run into problems if we run 2 sessions.
Answer by Andy Michaels · Dec 18, 2014 at 10:45 PM
AFAIK, there is nothing equivalent in nature to a class variable, or a static variable. What you can do is just set a variable in the scope that calls both quickcalls. This isn't global (using gset or gget), but it is global to the current test case.
This isn't ideal as it means the quickcalls cannot be black boxed as much as I would like. It's then up to the user of my quickcalls to store state for the quickcalls. This makes using my quickcalls more complex and more prone to error. For example, the user could forgot to pass the variable back to the call or pass the wrong value etc. This should probably be a feature request as this has come up a number of times for me and I doubt I'm the only person who has this requirement.
A good work around would probably be to create a global variable with a session id in its name, or something like that.
Answer by Andy Michaels · Dec 18, 2014 at 10:47 PM
Another alternative might be to make the file name a parameter or a property on the device in a topology. In the latter, you can use the tbml command to retrieve the value (but you can't modify it. Same with a parameter)
Answer by MikeKulls · Dec 19, 2014 at 03:20 AM
This looks like a possible workaround. The first quickcall has args of name and value, the second one just name. This isn't perfect but does appear to solve the problem at hand. The only downside is that the variables aren't private to the session. I'd be interested in people's opinions.
The other option that might be a possibility is there is a section in the variable tree called profiles that appears to have 1 branch per session. If the syntax to add something to that branch could be found that might work.
Execution says "Wait for prompt". What do I do? 1 Answer
Preventing iTest from learning propmts automatically 3 Answers
Continuing test execution when SSH login fails 1 Answer
Where does iTest store prompts for each step? 1 Answer
content-type(application/json) for POST in Rest Session profile 4 Answers
Copyright 2008- Spirent Communications, all rights reserved. Terms and Conditions.