Update environment queries to look for app provisioning completion as well
This commit is contained in:
parent
b364a1d2a6
commit
17ec944ad5
@ -124,7 +124,10 @@ class Environments(object):
|
|||||||
Any environment with an active CLIN that doesn't yet have a `cloud_id`.
|
Any environment with an active CLIN that doesn't yet have a `cloud_id`.
|
||||||
"""
|
"""
|
||||||
results = (
|
results = (
|
||||||
cls.base_provision_query(now).filter(Application.cloud_id != None).all()
|
cls.base_provision_query(now)
|
||||||
|
.filter(Application.cloud_id != None)
|
||||||
|
.filter(Environment.cloud_id == None)
|
||||||
|
.all()
|
||||||
)
|
)
|
||||||
return [id_ for id_, in results]
|
return [id_ for id_, in results]
|
||||||
|
|
||||||
|
@ -11,13 +11,11 @@ from atst.domain.csp.cloud.models import (
|
|||||||
EnvironmentCSPPayload,
|
EnvironmentCSPPayload,
|
||||||
UserCSPPayload,
|
UserCSPPayload,
|
||||||
)
|
)
|
||||||
from atst.domain.environment_roles import EnvironmentRoles
|
|
||||||
from atst.domain.environments import Environments
|
from atst.domain.environments import Environments
|
||||||
from atst.domain.portfolios import Portfolios
|
from atst.domain.portfolios import Portfolios
|
||||||
from atst.models import JobFailure
|
from atst.models import JobFailure
|
||||||
from atst.models.utils import claim_for_update, claim_many_for_update
|
from atst.models.utils import claim_for_update, claim_many_for_update
|
||||||
from atst.queue import celery
|
from atst.queue import celery
|
||||||
from atst.utils.localization import translate
|
|
||||||
|
|
||||||
|
|
||||||
class RecordFailure(celery.Task):
|
class RecordFailure(celery.Task):
|
||||||
|
@ -132,15 +132,19 @@ class EnvQueryTest:
|
|||||||
def TOMORROW(self):
|
def TOMORROW(self):
|
||||||
return self.NOW.add(days=1)
|
return self.NOW.add(days=1)
|
||||||
|
|
||||||
def create_portfolio_with_clins(self, start_and_end_dates, env_data=None):
|
def create_portfolio_with_clins(
|
||||||
|
self, start_and_end_dates, env_data=None, app_data=None
|
||||||
|
):
|
||||||
env_data = env_data or {}
|
env_data = env_data or {}
|
||||||
|
app_data = app_data or {}
|
||||||
return PortfolioFactory.create(
|
return PortfolioFactory.create(
|
||||||
applications=[
|
applications=[
|
||||||
{
|
{
|
||||||
"name": "Mos Eisley",
|
"name": "Mos Eisley",
|
||||||
"description": "Where Han shot first",
|
"description": "Where Han shot first",
|
||||||
"environments": [{"name": "thebar", **env_data}],
|
"environments": [{"name": "thebar", **env_data}],
|
||||||
}
|
**app_data,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
task_orders=[
|
task_orders=[
|
||||||
{
|
{
|
||||||
@ -168,9 +172,17 @@ class TestGetEnvironmentsPendingCreate(EnvQueryTest):
|
|||||||
self.create_portfolio_with_clins([(self.TOMORROW, self.TOMORROW)])
|
self.create_portfolio_with_clins([(self.TOMORROW, self.TOMORROW)])
|
||||||
assert len(Environments.get_environments_pending_creation(self.NOW)) == 0
|
assert len(Environments.get_environments_pending_creation(self.NOW)) == 0
|
||||||
|
|
||||||
|
def test_with_already_provisioned_app(self, session):
|
||||||
|
self.create_portfolio_with_clins(
|
||||||
|
[(self.YESTERDAY, self.TOMORROW)], app_data={"cloud_id": uuid4().hex}
|
||||||
|
)
|
||||||
|
assert len(Environments.get_environments_pending_creation(self.NOW)) == 1
|
||||||
|
|
||||||
def test_with_already_provisioned_env(self, session):
|
def test_with_already_provisioned_env(self, session):
|
||||||
self.create_portfolio_with_clins(
|
self.create_portfolio_with_clins(
|
||||||
[(self.YESTERDAY, self.TOMORROW)], env_data={"cloud_id": uuid4().hex}
|
[(self.YESTERDAY, self.TOMORROW)],
|
||||||
|
env_data={"cloud_id": uuid4().hex},
|
||||||
|
app_data={"cloud_id": uuid4().hex},
|
||||||
)
|
)
|
||||||
assert len(Environments.get_environments_pending_creation(self.NOW)) == 0
|
assert len(Environments.get_environments_pending_creation(self.NOW)) == 0
|
||||||
|
|
||||||
@ -187,11 +199,10 @@ class TestGetEnvironmentsPendingAtatUserCreation(EnvQueryTest):
|
|||||||
|
|
||||||
def test_with_unprovisioned_environment(self):
|
def test_with_unprovisioned_environment(self):
|
||||||
self.create_portfolio_with_clins(
|
self.create_portfolio_with_clins(
|
||||||
[(self.YESTERDAY, self.TOMORROW)],
|
[(self.YESTERDAY, self.TOMORROW)], app_data={"cloud_id": uuid4().hex},
|
||||||
{"cloud_id": uuid4().hex, "root_user_info": None},
|
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
len(Environments.get_environments_pending_atat_user_creation(self.NOW)) == 1
|
len(Environments.get_environments_pending_atat_user_creation(self.NOW)) == 0
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_with_unprovisioned_expired_clins_environment(self):
|
def test_with_unprovisioned_expired_clins_environment(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user