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:
Dawid Deja 2016-06-22 11:26:30 +02:00
parent 2e8b36d825
commit 716776a58e
3 changed files with 29 additions and 1 deletions

View File

@ -21,6 +21,7 @@ from email.mime import text
import json import json
import requests import requests
import smtplib import smtplib
import time
from mistral.actions import base from mistral.actions import base
from mistral import exceptions as exc from mistral import exceptions as exc
@ -432,3 +433,29 @@ class JavaScriptAction(base.Action):
def test(self): def test(self):
return self.script 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

View File

@ -171,7 +171,7 @@ workflows:
- pause - pause
task2: task2:
action: std.mistral_http url="http://google.com" action: std.async_noop
# This one won't be finished when execution is already PAUSED. # This one won't be finished when execution is already PAUSED.
on-complete: on-complete:
- task4 - task4

View File

@ -60,3 +60,4 @@ mistral.actions =
std.ssh_proxied = mistral.actions.std_actions:SSHProxiedAction std.ssh_proxied = mistral.actions.std_actions:SSHProxiedAction
std.email = mistral.actions.std_actions:SendEmailAction std.email = mistral.actions.std_actions:SendEmailAction
std.javascript = mistral.actions.std_actions:JavaScriptAction std.javascript = mistral.actions.std_actions:JavaScriptAction
std.sleep = mistral.actions.std_actions:SleepAction