Add delay option to std.echo to emulate external lags.
Change-Id: Id177246996434d2ad1c111b0b7bf78664390045a Signed-off-by: Oleg Ovcharuk <vgvoleg@gmail.com>
This commit is contained in:
parent
a461e07916
commit
f9f994751a
|
@ -1118,6 +1118,8 @@ Input parameters:
|
|||
|
||||
- **output** - Value of any type that needs to be returned as a result
|
||||
of the action. *Required*.
|
||||
- **delay** - Float value that defines with what delay (in seconds)
|
||||
the result should be returned. *Optional*.
|
||||
|
||||
std.javascript
|
||||
''''''''''''''
|
||||
|
|
|
@ -42,13 +42,24 @@ class EchoAction(actions.Action):
|
|||
stub.
|
||||
"""
|
||||
|
||||
def __init__(self, output):
|
||||
def __init__(self, output, delay=0):
|
||||
super(EchoAction, self).__init__()
|
||||
|
||||
self.output = output
|
||||
try:
|
||||
self._delay = float(delay)
|
||||
self._delay = 0 if self._delay < 0 else self._delay
|
||||
except ValueError:
|
||||
self._delay = 0
|
||||
|
||||
def run(self, context):
|
||||
LOG.info('Running echo action [output=%s]', self.output)
|
||||
LOG.info(
|
||||
'Running echo action [output=%s, delay=%s]',
|
||||
self.output,
|
||||
self._delay
|
||||
)
|
||||
|
||||
time.sleep(self._delay)
|
||||
|
||||
return self.output
|
||||
|
||||
|
|
Loading…
Reference in New Issue