Merge pull request #105 from sartography/feature/avoid_logs_when_call_activity_waiting
do not write to logs when a task is inheriting data from the parent w…
This commit is contained in:
commit
b5be1745d8
|
@ -29,7 +29,13 @@ else
|
||||||
export FLASK_DEBUG=1
|
export FLASK_DEBUG=1
|
||||||
|
|
||||||
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
|
if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then
|
||||||
SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
RUN_BACKGROUND_SCHEDULER=false SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py
|
||||||
fi
|
fi
|
||||||
FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
|
|
||||||
|
if [[ -z "${RUN_BACKGROUND_SCHEDULER:-}" ]]; then
|
||||||
|
RUN_BACKGROUND_SCHEDULER=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# this line blocks
|
||||||
|
RUN_BACKGROUND_SCHEDULER="${RUN_BACKGROUND_SCHEDULER}" FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1787,7 +1787,7 @@ lxml = "*"
|
||||||
type = "git"
|
type = "git"
|
||||||
url = "https://github.com/sartography/SpiffWorkflow"
|
url = "https://github.com/sartography/SpiffWorkflow"
|
||||||
reference = "main"
|
reference = "main"
|
||||||
resolved_reference = "be26100bcbef8026e26312c665dae42faf476485"
|
resolved_reference = "655e415e1522a8f4eb29c3e8531f74bf826b5ef4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "SQLAlchemy"
|
name = "SQLAlchemy"
|
||||||
|
|
|
@ -28,7 +28,7 @@ flask-migrate = "*"
|
||||||
flask-restful = "*"
|
flask-restful = "*"
|
||||||
werkzeug = "*"
|
werkzeug = "*"
|
||||||
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
|
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
|
||||||
#SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" }
|
# SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" }
|
||||||
sentry-sdk = "^1.10"
|
sentry-sdk = "^1.10"
|
||||||
sphinx-autoapi = "^2.0"
|
sphinx-autoapi = "^2.0"
|
||||||
flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"}
|
flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"}
|
||||||
|
|
|
@ -125,7 +125,11 @@ def create_app() -> flask.app.Flask:
|
||||||
|
|
||||||
app.json = MyJSONEncoder(app)
|
app.json = MyJSONEncoder(app)
|
||||||
|
|
||||||
if app.config["RUN_BACKGROUND_SCHEDULER"]:
|
# do not start the scheduler twice in flask debug mode
|
||||||
|
if (
|
||||||
|
app.config["RUN_BACKGROUND_SCHEDULER"]
|
||||||
|
and os.environ.get("WERKZEUG_RUN_MAIN") != "true"
|
||||||
|
):
|
||||||
start_scheduler(app)
|
start_scheduler(app)
|
||||||
|
|
||||||
configure_sentry(app)
|
configure_sentry(app)
|
||||||
|
|
|
@ -10,7 +10,7 @@ SPIFFWORKFLOW_BACKEND_LOG_LEVEL = environ.get(
|
||||||
)
|
)
|
||||||
|
|
||||||
RUN_BACKGROUND_SCHEDULER = (
|
RUN_BACKGROUND_SCHEDULER = (
|
||||||
environ.get("RUN_BACKGROUND_SCHEDULER", default="true") == "true"
|
environ.get("RUN_BACKGROUND_SCHEDULER", default="false") == "true"
|
||||||
)
|
)
|
||||||
GIT_CLONE_URL_FOR_PUBLISHING = environ.get(
|
GIT_CLONE_URL_FOR_PUBLISHING = environ.get(
|
||||||
"GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git"
|
"GIT_CLONE_URL", default="https://github.com/sartography/sample-process-models.git"
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||||
|
<bpmn:process id="ManualTaskToCallFromCallActivityToTestWaitingLogs" isExecutable="true">
|
||||||
|
<bpmn:startEvent id="StartEvent_1">
|
||||||
|
<bpmn:outgoing>Flow_1nxz6rd</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:sequenceFlow id="Flow_1nxz6rd" sourceRef="StartEvent_1" targetRef="the_manual_task" />
|
||||||
|
<bpmn:endEvent id="Event_19yodox">
|
||||||
|
<bpmn:incoming>Flow_1jtitb1</bpmn:incoming>
|
||||||
|
</bpmn:endEvent>
|
||||||
|
<bpmn:sequenceFlow id="Flow_1jtitb1" sourceRef="the_manual_task" targetRef="Event_19yodox" />
|
||||||
|
<bpmn:manualTask id="the_manual_task" name="The Manual Task">
|
||||||
|
<bpmn:extensionElements>
|
||||||
|
<spiffworkflow:instructionsForEndUser>NOOOOOOOOOOOOOOOOOO!!!!!!!!!!</spiffworkflow:instructionsForEndUser>
|
||||||
|
</bpmn:extensionElements>
|
||||||
|
<bpmn:incoming>Flow_1nxz6rd</bpmn:incoming>
|
||||||
|
<bpmn:outgoing>Flow_1jtitb1</bpmn:outgoing>
|
||||||
|
</bpmn:manualTask>
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ManualTaskToCallFromCallActivityToTestWaitingLogs">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||||
|
<dc:Bounds x="179" y="159" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Event_19yodox_di" bpmnElement="Event_19yodox">
|
||||||
|
<dc:Bounds x="432" y="159" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Activity_0tl8vo6_di" bpmnElement="the_manual_task">
|
||||||
|
<dc:Bounds x="270" y="137" width="100" height="80" />
|
||||||
|
<bpmndi:BPMNLabel />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="Flow_1nxz6rd_di" bpmnElement="Flow_1nxz6rd">
|
||||||
|
<di:waypoint x="215" y="177" />
|
||||||
|
<di:waypoint x="270" y="177" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="Flow_1jtitb1_di" bpmnElement="Flow_1jtitb1">
|
||||||
|
<di:waypoint x="370" y="177" />
|
||||||
|
<di:waypoint x="432" y="177" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||||
|
<bpmn:process id="Process_zywnms5" isExecutable="true">
|
||||||
|
<bpmn:startEvent id="StartEvent_1">
|
||||||
|
<bpmn:outgoing>Flow_0fdzi5f</bpmn:outgoing>
|
||||||
|
</bpmn:startEvent>
|
||||||
|
<bpmn:sequenceFlow id="Flow_0fdzi5f" sourceRef="StartEvent_1" targetRef="call_activity_to_human_task" />
|
||||||
|
<bpmn:endEvent id="Event_1dzrts2">
|
||||||
|
<bpmn:incoming>Flow_0ii0wgu</bpmn:incoming>
|
||||||
|
</bpmn:endEvent>
|
||||||
|
<bpmn:sequenceFlow id="Flow_0ii0wgu" sourceRef="call_activity_to_human_task" targetRef="Event_1dzrts2" />
|
||||||
|
<bpmn:callActivity id="call_activity_to_human_task" name="Call Activity To Human Task" calledElement="ManualTaskToCallFromCallActivityToTestWaitingLogs">
|
||||||
|
<bpmn:incoming>Flow_0fdzi5f</bpmn:incoming>
|
||||||
|
<bpmn:outgoing>Flow_0ii0wgu</bpmn:outgoing>
|
||||||
|
</bpmn:callActivity>
|
||||||
|
</bpmn:process>
|
||||||
|
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||||
|
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_zywnms5">
|
||||||
|
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||||
|
<dc:Bounds x="179" y="159" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Event_1dzrts2_di" bpmnElement="Event_1dzrts2">
|
||||||
|
<dc:Bounds x="432" y="159" width="36" height="36" />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape id="Activity_0qb9821_di" bpmnElement="call_activity_to_human_task">
|
||||||
|
<dc:Bounds x="270" y="137" width="100" height="80" />
|
||||||
|
<bpmndi:BPMNLabel />
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge id="Flow_0fdzi5f_di" bpmnElement="Flow_0fdzi5f">
|
||||||
|
<di:waypoint x="215" y="177" />
|
||||||
|
<di:waypoint x="270" y="177" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge id="Flow_0ii0wgu_di" bpmnElement="Flow_0ii0wgu">
|
||||||
|
<di:waypoint x="370" y="177" />
|
||||||
|
<di:waypoint x="432" y="177" />
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</bpmn:definitions>
|
|
@ -0,0 +1,46 @@
|
||||||
|
"""Test_process_instance_processor."""
|
||||||
|
import os
|
||||||
|
from flask.app import Flask
|
||||||
|
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
||||||
|
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
|
||||||
|
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
|
||||||
|
|
||||||
|
from spiffworkflow_backend.models.user import UserModel
|
||||||
|
from spiffworkflow_backend.services.process_instance_processor import (
|
||||||
|
ProcessInstanceProcessor,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class TestProcessInstanceService(BaseTest):
|
||||||
|
"""TestProcessInstanceService."""
|
||||||
|
|
||||||
|
def test_does_not_log_set_data_when_calling_engine_steps_on_waiting_call_activity(
|
||||||
|
self,
|
||||||
|
app: Flask,
|
||||||
|
with_db_and_bpmn_file_cleanup: None,
|
||||||
|
with_super_admin_user: UserModel,
|
||||||
|
) -> None:
|
||||||
|
"""Test_does_not_log_set_data_when_calling_engine_steps_on_waiting_call_activity."""
|
||||||
|
tmp_file = '/tmp/testfile.txt'
|
||||||
|
if os.path.isfile(tmp_file):
|
||||||
|
os.remove(tmp_file)
|
||||||
|
process_model = load_test_spec(
|
||||||
|
process_model_id="test_group/call-activity-to-human-task",
|
||||||
|
process_model_source_directory="call-activity-to-human-task",
|
||||||
|
)
|
||||||
|
process_instance = self.create_process_instance_from_process_model(
|
||||||
|
process_model=process_model, user=with_super_admin_user
|
||||||
|
)
|
||||||
|
processor = ProcessInstanceProcessor(process_instance)
|
||||||
|
processor.do_engine_steps(save=True)
|
||||||
|
|
||||||
|
process_instance_logs = SpiffLoggingModel.query.filter_by(process_instance_id=process_instance.id).all()
|
||||||
|
initial_length = len(process_instance_logs)
|
||||||
|
|
||||||
|
# logs should NOT increase after running this a second time since it's just waiting on a human task
|
||||||
|
print("HEY NOW")
|
||||||
|
with open(tmp_file, 'w') as f:
|
||||||
|
f.write("HEY")
|
||||||
|
processor.do_engine_steps(save=True)
|
||||||
|
process_instance_logs = SpiffLoggingModel.query.filter_by(process_instance_id=process_instance.id).all()
|
||||||
|
assert len(process_instance_logs) == initial_length
|
Loading…
Reference in New Issue