Remove std.mistral_http action from tests
Unit tests should not rely on internet connection. This commit adds new 'std.sleep' action that can symulate long running action. Change-Id: Ib7bede239942d429d1bb1ed6f5a2611f64520848 Closes-bug: 1538996
This commit is contained in:
parent
2e8b36d825
commit
716776a58e
@ -21,6 +21,7 @@ from email.mime import text
|
||||
import json
|
||||
import requests
|
||||
import smtplib
|
||||
import time
|
||||
|
||||
from mistral.actions import base
|
||||
from mistral import exceptions as exc
|
||||
@ -432,3 +433,29 @@ class JavaScriptAction(base.Action):
|
||||
|
||||
def test(self):
|
||||
return self.script
|
||||
|
||||
|
||||
class SleepAction(base.Action):
|
||||
"""Sleep action.
|
||||
|
||||
This action sleeps for given amount of seconds. It can be mostly useful
|
||||
for testing and debugging purposes.
|
||||
"""
|
||||
def __init__(self, seconds=1):
|
||||
try:
|
||||
self._seconds = int(seconds)
|
||||
self._seconds = 0 if self._seconds < 0 else self._seconds
|
||||
except ValueError:
|
||||
self._seconds = 0
|
||||
|
||||
def run(self):
|
||||
LOG.info('Running sleep action [seconds=%s]' % self._seconds)
|
||||
|
||||
time.sleep(self._seconds)
|
||||
|
||||
return None
|
||||
|
||||
def test(self):
|
||||
time.sleep(1)
|
||||
|
||||
return None
|
||||
|
@ -171,7 +171,7 @@ workflows:
|
||||
- pause
|
||||
|
||||
task2:
|
||||
action: std.mistral_http url="http://google.com"
|
||||
action: std.async_noop
|
||||
# This one won't be finished when execution is already PAUSED.
|
||||
on-complete:
|
||||
- task4
|
||||
|
Loading…
Reference in New Issue
Block a user