Skip to content
Snippets Groups Projects
Commit d1dd865c authored by Mohammad Torkashvand's avatar Mohammad Torkashvand
Browse files

skip dry_run step in case it is a massive redeploy

parent 319329cb
No related branches found
No related tags found
1 merge request!429Feature/mass base config redeploy
...@@ -11,7 +11,7 @@ run. After confirmation by an operator, the configuration is committed to the ma ...@@ -11,7 +11,7 @@ run. After confirmation by an operator, the configuration is committed to the ma
from orchestrator.forms import SubmitFormPage from orchestrator.forms import SubmitFormPage
from orchestrator.forms.validators import Label from orchestrator.forms.validators import Label
from orchestrator.targets import Target from orchestrator.targets import Target
from orchestrator.workflow import StepList, begin, done, workflow from orchestrator.workflow import StepList, begin, conditional, done, workflow
from orchestrator.workflows.steps import resync, store_process_subscription, unsync from orchestrator.workflows.steps import resync, store_process_subscription, unsync
from orchestrator.workflows.utils import wrap_modify_initial_input_form from orchestrator.workflows.utils import wrap_modify_initial_input_form
from pydantic_forms.types import FormGenerator, UUIDstr from pydantic_forms.types import FormGenerator, UUIDstr
...@@ -28,6 +28,7 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator: ...@@ -28,6 +28,7 @@ def _initial_input_form(subscription_id: UUIDstr) -> FormGenerator:
class RedeployBaseConfigForm(SubmitFormPage): class RedeployBaseConfigForm(SubmitFormPage):
info_label: Label = f"Redeploy base config on {router.router.router_fqdn}?" info_label: Label = f"Redeploy base config on {router.router.router_fqdn}?"
tt_number: TTNumber tt_number: TTNumber
is_massive_redeploy: bool = False
user_input = yield RedeployBaseConfigForm user_input = yield RedeployBaseConfigForm
...@@ -45,11 +46,13 @@ def redeploy_base_config() -> StepList: ...@@ -45,11 +46,13 @@ def redeploy_base_config() -> StepList:
* Perform a dry run of deployment * Perform a dry run of deployment
* Redeploy base config * Redeploy base config
""" """
is_not_massive_redeploy = conditional(lambda state: not bool(state.get("is_massive_redeploy")))
return ( return (
begin begin
>> store_process_subscription(Target.MODIFY) >> store_process_subscription(Target.MODIFY)
>> unsync >> unsync
>> lso_interaction(deploy_base_config_dry) >> is_not_massive_redeploy(lso_interaction(deploy_base_config_dry))
>> lso_interaction(deploy_base_config_real) >> lso_interaction(deploy_base_config_real)
>> resync >> resync
>> done >> done
......
...@@ -57,7 +57,9 @@ def start_redeploy_workflows(tt_number: TTNumber, selected_routers: list[UUIDstr ...@@ -57,7 +57,9 @@ def start_redeploy_workflows(tt_number: TTNumber, selected_routers: list[UUIDstr
for selected_router in selected_routers: for selected_router in selected_routers:
try: try:
result = requests.post( result = requests.post(
workflow_url, json=[{"subscription_id": selected_router}, {"tt_number": tt_number}], timeout=10 workflow_url,
json=[{"subscription_id": selected_router}, {"tt_number": tt_number, "is_massive_redeploy": True}],
timeout=10,
) )
result.raise_for_status() result.raise_for_status()
except HTTPError as e: except HTTPError as e:
......
...@@ -10,7 +10,9 @@ from test.workflows import ( ...@@ -10,7 +10,9 @@ from test.workflows import (
@pytest.mark.workflow() @pytest.mark.workflow()
@pytest.mark.parametrize("is_massive_redeploy", [False, True])
def test_redeploy_base_config_success( def test_redeploy_base_config_success(
is_massive_redeploy,
router_subscription_factory, router_subscription_factory,
faker, faker,
): ):
...@@ -18,10 +20,12 @@ def test_redeploy_base_config_success( ...@@ -18,10 +20,12 @@ def test_redeploy_base_config_success(
product_id = str(router_subscription_factory().subscription_id) product_id = str(router_subscription_factory().subscription_id)
# Run workflow # Run workflow
initial_input_data = [{"subscription_id": product_id}, {"tt_number": faker.tt_number()}] initial_input_data = [
{"subscription_id": product_id},
{"tt_number": faker.tt_number(), "is_massive_redeploy": is_massive_redeploy},
]
result, process_stat, step_log = run_workflow("redeploy_base_config", initial_input_data) result, process_stat, step_log = run_workflow("redeploy_base_config", initial_input_data)
for _ in range(1 if is_massive_redeploy else 2):
for _ in range(2):
result, step_log = assert_lso_interaction_success(result, process_stat, step_log) result, step_log = assert_lso_interaction_success(result, process_stat, step_log)
assert_complete(result) assert_complete(result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment