v0.3.7-pre.011
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-backfill-desk/unit_tests/backfill_run.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
#[test]
|
||||
fn generated_run_ids_are_backend_owned_bounded_and_unique_in_session() {
|
||||
@@ -23,7 +23,9 @@ fn generated_run_ids_are_backend_owned_bounded_and_unique_in_session() {
|
||||
assert!(second.as_str().len() <= ksp_job_api::MAX_JOB_ID_BYTES);
|
||||
}
|
||||
|
||||
fn cancellable_runtime(job_id: &str) -> std::option::Option<(ksp_job_api::JobId, ksp_job_backfill_lib::BackfillJobRuntime)> {
|
||||
fn cancellable_runtime(
|
||||
job_id: &str,
|
||||
) -> std::option::Option<(ksp_job_api::JobId, ksp_job_backfill_lib::BackfillRequest, ksp_job_backfill_lib::BackfillJobRuntime)> {
|
||||
let job_id = match ksp_job_api::JobId::new(job_id) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return std::option::Option::None,
|
||||
@@ -48,11 +50,12 @@ fn cancellable_runtime(job_id: &str) -> std::option::Option<(ksp_job_api::JobId,
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return std::option::Option::None,
|
||||
};
|
||||
let retained_request = request.clone();
|
||||
let runtime = match ksp_job_backfill_lib::BackfillJobRuntime::new(request) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return std::option::Option::None,
|
||||
};
|
||||
return std::option::Option::Some((job_id, runtime));
|
||||
return std::option::Option::Some((job_id, retained_request, runtime));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -60,11 +63,11 @@ fn targeted_cancel_is_idempotent_and_rejects_stale_job_identity() {
|
||||
let state = crate::BackfillRunState::new();
|
||||
let runtime = cancellable_runtime("backfill-desk-41");
|
||||
assert!(runtime.is_some());
|
||||
let (job_id, runtime) = match runtime {
|
||||
let (job_id, request, runtime) = match runtime {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
let installed = state.install(job_id.clone(), runtime.handle());
|
||||
let installed = state.install(job_id.clone(), runtime.handle(), request);
|
||||
assert!(installed.is_ok());
|
||||
let first = state.cancel(job_id.as_str());
|
||||
assert!(first.is_ok());
|
||||
@@ -85,3 +88,30 @@ fn targeted_cancel_is_idempotent_and_rejects_stale_job_identity() {
|
||||
assert_eq!(error.code().code(), crate::ERROR_CODE_BACKFILL_RUN_MISMATCH.code());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resume_requires_terminal_checkpoint_and_rejects_active_run() {
|
||||
let state = crate::BackfillRunState::new();
|
||||
let next = match ksp_job_api::JobId::new("backfill-desk-50") {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(_) => return,
|
||||
};
|
||||
let unavailable = state.resume_request(next.clone());
|
||||
assert!(unavailable.is_err());
|
||||
if let std::result::Result::Err(error) = unavailable {
|
||||
assert_eq!(error.code(), crate::ERROR_CODE_BACKFILL_RESUME_UNAVAILABLE);
|
||||
}
|
||||
let runtime = cancellable_runtime("backfill-desk-49");
|
||||
assert!(runtime.is_some());
|
||||
let (job_id, request, runtime) = match runtime {
|
||||
std::option::Option::Some(value) => value,
|
||||
std::option::Option::None => return,
|
||||
};
|
||||
let installed = state.install(job_id, runtime.handle(), request);
|
||||
assert!(installed.is_ok());
|
||||
let active = state.resume_request(next);
|
||||
assert!(active.is_err());
|
||||
if let std::result::Result::Err(error) = active {
|
||||
assert_eq!(error.code(), crate::ERROR_CODE_BACKFILL_RUN_ACTIVE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-backfill-desk/unit_tests/dto_backfill.rs
|
||||
// version: 3
|
||||
// version: 4
|
||||
|
||||
#[test]
|
||||
fn request_limits_are_derived_from_job_owned_public_bounds() {
|
||||
@@ -58,3 +58,18 @@ fn cancel_acknowledgement_contains_only_backend_job_identity_acceptance_and_stat
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resume_acknowledgement_contains_only_new_backend_job_identity_acceptance_and_state() {
|
||||
let response = crate::BackfillResumeResponseDto { accepted: true, job_id: "backfill-desk-2".to_owned(), state: "created".to_owned() };
|
||||
let serialized = serde_json::to_string(&response);
|
||||
assert!(serialized.is_ok());
|
||||
if let std::result::Result::Ok(serialized) = serialized {
|
||||
assert!(serialized.contains("backfill-desk-2"));
|
||||
assert!(serialized.contains("created"));
|
||||
assert!(serialized.contains("accepted"));
|
||||
for forbidden in ["address", "signature", "provider", "endpoint", "credential", "token", "checkpoint", "payload"] {
|
||||
assert!(!serialized.contains(forbidden));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user