tests_authentic2: verify calls to sleep() on redeploy (#43035)
This commit is contained in:
parent
e99dc29f4e
commit
bad0618e16
|
@ -1,7 +1,7 @@
|
|||
import requests
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from time import sleep
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from authentic2 import app_settings
|
||||
|
@ -233,7 +233,7 @@ class Command(hobo_deploy.Command):
|
|||
break
|
||||
|
||||
# wait 5, 10, 20, 40, .. seconds
|
||||
time.sleep(self.backoff_factor * (2 ** retries))
|
||||
sleep(self.backoff_factor * (2 ** retries))
|
||||
retries += 1
|
||||
|
||||
if provision_target_ous:
|
||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
|||
import shutil
|
||||
import json
|
||||
import mock
|
||||
import time
|
||||
|
||||
from requests import RequestException
|
||||
|
||||
|
@ -312,8 +313,10 @@ def test_hobo_deploy(monkeypatch, tenant_base, mocker, skeleton_dir):
|
|||
hobo_json.write(hobo_json_content)
|
||||
hobo_json.flush()
|
||||
|
||||
with mock.patch('hobo.agent.authentic2.provisionning.notify_agents') as mock_notify:
|
||||
with mock.patch('hobo.agent.authentic2.provisionning.notify_agents') as mock_notify, \
|
||||
mock.patch('hobo.agent.authentic2.management.commands.hobo_deploy.sleep', wraps=time.sleep) as sleep_mock:
|
||||
call_command('hobo_deploy', 'http://sso.example.net', hobo_json.name)
|
||||
assert sleep_mock.call_count == 1 # there is one retry, as the third service's metadata is temporarily unavailable
|
||||
|
||||
# check role mass provisionning to new services
|
||||
# two wcs => two ous => two audiences
|
||||
|
@ -461,6 +464,11 @@ def test_hobo_deploy(monkeypatch, tenant_base, mocker, skeleton_dir):
|
|||
ou=provider.ou, service__isnull=True,
|
||||
name=u'Service état-civil').count() == 1
|
||||
|
||||
with mock.patch('hobo.agent.authentic2.provisionning.notify_agents') as mock_notify, \
|
||||
mock.patch('hobo.agent.authentic2.management.commands.hobo_deploy.sleep', wraps=time.sleep) as sleep_mock:
|
||||
call_command('hobo_deploy', redeploy=True)
|
||||
assert sleep_mock.call_count == 0
|
||||
|
||||
|
||||
def test_import_template(db, tenant_base):
|
||||
def listify(value):
|
||||
|
|
Loading…
Reference in New Issue