Skip to content
Snippets Groups Projects
Verified Commit ef6276e8 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

rework the last workflows, and start updating the unit test suite

parent f0c5dbdd
No related branches found
No related tags found
1 merge request!96Make use of new callback step for external provisioning
......@@ -4,15 +4,15 @@
"""
import json
import logging
from functools import partial
import requests
from functools import partial
from orchestrator import step
from orchestrator.config.assignee import Assignee
from orchestrator.types import State, UUIDstr, strEnum
from orchestrator.utils.errors import ProcessFailureError
from orchestrator.utils.json import json_dumps
from orchestrator.workflow import Step, callback_step, begin, StepList, inputstep
from orchestrator.workflow import Step, StepList, begin, callback_step, inputstep
from pydantic_forms.core import FormPage, ReadOnlyField
from pydantic_forms.types import FormGenerator
from pydantic_forms.validators import LongText
......@@ -285,8 +285,11 @@ def _show_pp_results(state: State) -> FormGenerator:
def pp_interaction(provisioning_step: Step) -> StepList:
"""
An interaction with the provisioning proxy :term:`LSO` as a callback step.
"""Interact with the provisioning proxy :term:`LSO` using a callback step.
An asynchronous interaction with the provisioning proxy. This is an external system that executes Ansible playbooks
in order to provision service subscriptions. If the playbook fails, this step will also fail, allowing for the user
to retry provisioning from the UI.
:param provisioning_step: A workflow step that performs an operation remotely using the provisioning proxy.
:type provisioning_step: :class:`Step`
......
......@@ -26,10 +26,10 @@ class LAGMember(BaseModel):
@step("[COMMIT] Set ISIS metric to 90.000")
def set_isis_to_90000(subscription: Iptrunk, process_id: UUIDstr, tt_number: str) -> State:
def set_isis_to_90000(subscription: Iptrunk, process_id: UUIDstr, callback_route: str, tt_number: str) -> State:
old_isis_metric = subscription.iptrunk.iptrunk_isis_metric
subscription.iptrunk.iptrunk_isis_metric = 90000
provisioning_proxy.provision_ip_trunk(subscription, process_id, tt_number, "isis_interface", False)
provisioning_proxy.provision_ip_trunk(subscription, process_id, callback_route, tt_number, "isis_interface", False)
return {
"subscription": subscription,
......
import secrets
from ipaddress import IPv4Network, IPv6Network
from typing import Any
......@@ -7,7 +6,7 @@ from orchestrator.forms import FormPage
from orchestrator.forms.validators import Choice
from orchestrator.targets import Target
from orchestrator.types import FormGenerator, State, SubscriptionLifecycle, UUIDstr
from orchestrator.workflow import StepList, conditional, done, init, step, workflow, Step, callback_step
from orchestrator.workflow import StepList, conditional, done, init, step, workflow
from orchestrator.workflows.steps import resync, set_status, store_process_subscription
from orchestrator.workflows.utils import wrap_create_initial_input_form
from pydantic import validator
......
......@@ -42,6 +42,12 @@ def assert_suspended(result):
).issuspend(), f"Unexpected process status. Expected Suspend, but was: {result}"
def assert_awaiting_callback(result):
assert result.on_failed(
_raise_exception
).isawaitingcallback(), f"Unexpected process status. Expected Awaiting Callback, but was: {result}"
def assert_aborted(result):
assert result.on_failed(_raise_exception).isabort(), f"Unexpected process status. Expected Abort, but was: {result}"
......
......@@ -11,6 +11,7 @@ from gso.utils.helpers import LAGMember
from test.services.conftest import MockedNetboxClient
from test.workflows import (
assert_aborted,
assert_awaiting_callback,
assert_complete,
assert_suspended,
extract_state,
......@@ -106,7 +107,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result(
product_id = get_product_id_by_name(ProductType.IP_TRUNK)
initial_site_data = [{"product": product_id}, *input_form_wizard_data]
result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data)
assert_suspended(result)
assert_awaiting_callback(result)
standard_lso_result = {
"pp_run_results": {
......@@ -158,7 +159,7 @@ def test_iptrunk_creation_fails_when_lso_return_code_is_one(
initial_site_data = [{"product": product_id}, *input_form_wizard_data]
result, process_stat, step_log = run_workflow("create_iptrunk", initial_site_data)
assert_suspended(result)
assert_awaiting_callback(result)
standard_lso_result = {
"pp_run_results": {
......
......@@ -2,13 +2,10 @@ from unittest.mock import patch
import pytest
from gso.products import Iptrunk
from gso.products.product_blocks import PhyPortCapacity
from gso.products.product_blocks.iptrunk import IptrunkType
from gso.schemas.enums import ProductType
from gso.services.crm import get_customer_by_name
from gso.products import Iptrunk, ProductType
from gso.products.product_blocks.iptrunk import IptrunkType, PhyPortCapacity
from gso.services.crm import customer_selector, get_customer_by_name
from gso.services.subscriptions import get_product_id_by_name
from gso.workflows.utils import customer_selector
from test.workflows import (
assert_aborted,
assert_complete,
......
......@@ -12,6 +12,8 @@ markers = workflow
[testenv]
passenv = DATABASE_URI_TEST,SKIP_ALL_TESTS
setenv =
OAUTH2_ACTIVE = False
deps =
coverage
flake8
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment