Files
windmill/backend/windmill-queue/tests/custom_query_flow_requeue_test.rs
T
e061d11826 fix: hand flow previews on an agent's tag to a flow worker (#12563)
* fix: hand flow previews on an agent's tag to a flow worker

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say which flow previews the pull requeue now covers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update ee-repo-ref to 57c9ae5b1b5c594fcdd9b398052a24006a367117

This commit updates the EE repository reference after PR #1000 was merged in windmill-ee-private.

Previous ee-repo-ref: 5b81b24e5fca5933b23a830fef0c5ae6f36de11a

New ee-repo-ref: 57c9ae5b1b5c594fcdd9b398052a24006a367117

Automated by sync-ee-ref workflow.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-11-20 12:10:52 +01:00

82 lines
2.4 KiB
Rust

//! A flow job pulled through a caller's own query (an agent worker's) is handed to the generic
//! flow tag, flow previews under the preview tag override included: an agent cannot drive a flow.
//!
//! Run with:
//! cargo test -p windmill-queue --test custom_query_flow_requeue_test
use std::collections::HashMap;
use std::sync::atomic::Ordering;
use sqlx::{Pool, Postgres};
use windmill_common::jobs::JobPayload;
use windmill_common::worker::{make_pull_query, PREVIEW_TAGS_OVERRIDE};
use windmill_queue::{pull, push, PushArgs, PushIsolationLevel};
#[sqlx::test(migrations = "../migrations", fixtures("base"))]
async fn flow_preview_on_an_agent_tag_goes_to_the_flow_tag(db: Pool<Postgres>) {
PREVIEW_TAGS_OVERRIDE.store(true, Ordering::Relaxed);
let payload = JobPayload::RawFlow {
value: serde_json::from_value(serde_json::json!({ "modules": [] })).unwrap(),
path: None,
restarted_from: None,
};
let args = HashMap::new();
let (id, tx) = push(
&db,
PushIsolationLevel::IsolatedRoot(db.clone()),
"test-workspace",
payload,
PushArgs { extra: None, args: &args },
"test-user",
"test@windmill.dev",
"u/test-user".to_string(),
None,
None,
None,
None,
None,
None,
None,
None,
false,
false,
None,
true,
Some("agentx".to_string()),
None,
None,
None,
None,
false,
None,
None,
None,
None,
)
.await
.expect("push");
tx.commit().await.expect("commit push");
let query = (String::new(), make_pull_query(&["agentx".to_string()]));
let pulled = pull(&db, false, "ag-test", Some(&query))
.await
.expect("pull");
assert!(pulled.job.is_none(), "an agent must not receive a flow job");
let (queue_tag, running): (String, bool) =
sqlx::query_as("SELECT tag, running FROM v2_job_queue WHERE id = $1")
.bind(id)
.fetch_one(&db)
.await
.unwrap();
assert_eq!((queue_tag.as_str(), running), ("flow", false));
// Its steps inherit this one.
let job_tag: String = sqlx::query_scalar("SELECT tag FROM v2_job WHERE id = $1")
.bind(id)
.fetch_one(&db)
.await
.unwrap();
assert_eq!(job_tag, "agentx");
}