Add small sleep to claims test to avoid random failures
This commit is contained in:
parent
3a23c54723
commit
2fc7a0d460
@ -3,8 +3,8 @@ import pytest
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
from atst.models import Environment
|
|
||||||
from atst.domain.csp.cloud import MockCloudProvider
|
from atst.domain.csp.cloud import MockCloudProvider
|
||||||
from atst.jobs import (
|
from atst.jobs import (
|
||||||
RecordEnvironmentFailure,
|
RecordEnvironmentFailure,
|
||||||
@ -19,12 +19,7 @@ from atst.jobs import (
|
|||||||
)
|
)
|
||||||
from atst.models.utils import claim_for_update
|
from atst.models.utils import claim_for_update
|
||||||
from atst.domain.exceptions import ClaimFailedException
|
from atst.domain.exceptions import ClaimFailedException
|
||||||
from tests.factories import (
|
from tests.factories import EnvironmentFactory, EnvironmentRoleFactory, PortfolioFactory
|
||||||
EnvironmentFactory,
|
|
||||||
EnvironmentRoleFactory,
|
|
||||||
UserFactory,
|
|
||||||
PortfolioFactory,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_environment_job_failure(celery_app, celery_worker):
|
def test_environment_job_failure(celery_app, celery_worker):
|
||||||
@ -262,6 +257,7 @@ def test_claim_for_update(session):
|
|||||||
class FirstThread(Thread):
|
class FirstThread(Thread):
|
||||||
def run(self):
|
def run(self):
|
||||||
with claim_for_update(environment):
|
with claim_for_update(environment):
|
||||||
|
sleep(0.1) # doing some work
|
||||||
satisfied_claims.append("FirstThread")
|
satisfied_claims.append("FirstThread")
|
||||||
|
|
||||||
class SecondThread(Thread):
|
class SecondThread(Thread):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user