mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
feat: add metrics to clean message and workflow-run task (#33143)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hj24 <mambahj24@gmail.com>
This commit is contained in:
@ -80,7 +80,13 @@ class TestWorkflowRunCleanupInit:
|
||||
cfg.SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD = 0
|
||||
cfg.BILLING_ENABLED = False
|
||||
with pytest.raises(ValueError):
|
||||
WorkflowRunCleanup(days=30, batch_size=10, start_from=dt, end_before=dt, workflow_run_repo=mock_repo)
|
||||
WorkflowRunCleanup(
|
||||
days=30,
|
||||
batch_size=10,
|
||||
start_from=dt,
|
||||
end_before=dt,
|
||||
workflow_run_repo=mock_repo,
|
||||
)
|
||||
|
||||
def test_zero_batch_size_raises(self, mock_repo):
|
||||
with patch("services.retention.workflow_run.clear_free_plan_expired_workflow_run_logs.dify_config") as cfg:
|
||||
@ -102,10 +108,24 @@ class TestWorkflowRunCleanupInit:
|
||||
cfg.BILLING_ENABLED = False
|
||||
start = datetime.datetime(2024, 1, 1)
|
||||
end = datetime.datetime(2024, 6, 1)
|
||||
c = WorkflowRunCleanup(days=30, batch_size=5, start_from=start, end_before=end, workflow_run_repo=mock_repo)
|
||||
c = WorkflowRunCleanup(
|
||||
days=30,
|
||||
batch_size=5,
|
||||
start_from=start,
|
||||
end_before=end,
|
||||
workflow_run_repo=mock_repo,
|
||||
)
|
||||
assert c.window_start == start
|
||||
assert c.window_end == end
|
||||
|
||||
def test_default_task_label_is_custom(self, mock_repo):
|
||||
with patch("services.retention.workflow_run.clear_free_plan_expired_workflow_run_logs.dify_config") as cfg:
|
||||
cfg.SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD = 0
|
||||
cfg.BILLING_ENABLED = False
|
||||
c = WorkflowRunCleanup(days=30, batch_size=10, workflow_run_repo=mock_repo)
|
||||
|
||||
assert c._metrics._base_attributes["task_label"] == "custom"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# _empty_related_counts / _format_related_counts
|
||||
@ -393,7 +413,12 @@ class TestRunDryRunMode:
|
||||
with patch("services.retention.workflow_run.clear_free_plan_expired_workflow_run_logs.dify_config") as cfg:
|
||||
cfg.SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD = 0
|
||||
cfg.BILLING_ENABLED = False
|
||||
return WorkflowRunCleanup(days=30, batch_size=10, workflow_run_repo=mock_repo, dry_run=True)
|
||||
return WorkflowRunCleanup(
|
||||
days=30,
|
||||
batch_size=10,
|
||||
workflow_run_repo=mock_repo,
|
||||
dry_run=True,
|
||||
)
|
||||
|
||||
def test_dry_run_no_delete_called(self, mock_repo):
|
||||
run = make_run("t1")
|
||||
|
||||
Reference in New Issue
Block a user