-
Notifications
You must be signed in to change notification settings - Fork 44
test: expand core and CLI coverage #454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 4 commits into
NVIDIA:main
from
willkill07:wkk_test/core-cli-coverage
Jul 16, 2026
+503
−59
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use serde_json::json; | ||
|
|
||
| use super::AgentKind; | ||
| use super::json_path::{string_at, string_at_any, value_at, value_at_any}; | ||
|
|
||
| #[test] | ||
| fn agent_kinds_use_stable_runtime_metadata_names() { | ||
| assert_eq!(AgentKind::Codex.as_str(), "codex"); | ||
| assert_eq!(AgentKind::ClaudeCode.as_str(), "claude-code"); | ||
| assert_eq!(AgentKind::Hermes.as_str(), "hermes"); | ||
| assert_eq!(AgentKind::Gateway.as_str(), "gateway"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn values_follow_nested_paths_and_return_owned_data() { | ||
| let payload = json!({"request": {"id": "request-1", "enabled": true}}); | ||
|
|
||
| let extracted = value_at(&payload, &["request", "id"]); | ||
| assert_eq!(extracted, Some(json!("request-1"))); | ||
| assert_eq!(value_at(&payload, &["request", "missing"]), None); | ||
| assert_eq!( | ||
| value_at_any(&payload, &[&["missing"], &["request", "enabled"]]), | ||
| Some(json!(true)) | ||
| ); | ||
| assert_eq!( | ||
| value_at_any(&payload, &[&["request", "id"], &["request", "enabled"]]), | ||
| Some(json!("request-1")) | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn string_helpers_accept_scalars_and_skip_empty_or_structured_values() { | ||
| let payload = json!({ | ||
| "empty": "", | ||
| "number": 42, | ||
| "enabled": false, | ||
| "object": {"id": "nested"} | ||
| }); | ||
|
|
||
| assert_eq!(string_at(&payload, &["number"]), Some("42".into())); | ||
| assert_eq!(string_at(&payload, &["enabled"]), Some("false".into())); | ||
| assert_eq!(string_at(&payload, &["empty"]), None); | ||
| assert_eq!(string_at(&payload, &["object"]), None); | ||
| assert_eq!( | ||
| string_at_any(&payload, &[&["empty"], &["object"], &["object", "id"]]), | ||
| Some("nested".into()) | ||
| ); | ||
| assert_eq!( | ||
| string_at_any(&payload, &[&["object", "id"], &["number"]]), | ||
| Some("nested".into()) | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| use super::*; | ||
| use crate::plugin::{PLUGIN_HANDLERS, PLUGIN_MUTATION_OWNER, PluginMutationOwner}; | ||
| use serde_json::{Map, Value as Json}; | ||
|
|
||
| struct PoisonedRegistryCleanup; | ||
|
|
||
| impl Drop for PoisonedRegistryCleanup { | ||
| fn drop(&mut self) { | ||
| PLUGIN_HANDLERS.clear_poison(); | ||
| if let Ok(mut owner) = PLUGIN_MUTATION_OWNER.lock() { | ||
| *owner = PluginMutationOwner::Idle; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn unsafe_kind_deregistration_retains_runtime_and_owner() { | ||
| let _guard = crate::shared_runtime::runtime_owner_test_mutex() | ||
| .lock() | ||
| .unwrap_or_else(|error| error.into_inner()); | ||
| let _cleanup = PoisonedRegistryCleanup; | ||
| let claim = acquire_plugin_host_lease().expect("fixture host should acquire the owner"); | ||
| let owner_id = claim.owner_id(); | ||
| let mut activation = PluginHostActivation { | ||
| active: true, | ||
| native: Some(NativePluginActivation::with_plugin_kind_for_test( | ||
| "fixture.poisoned", | ||
| )), | ||
| #[cfg(feature = "worker-grpc")] | ||
| worker: None, | ||
| claim: Some(claim), | ||
| }; | ||
|
|
||
| std::thread::spawn(|| { | ||
| let _registry = PLUGIN_HANDLERS.write().unwrap(); | ||
| panic!("poison plugin registry for teardown test"); | ||
| }) | ||
| .join() | ||
| .expect_err("fixture registry writer should panic"); | ||
|
|
||
| let error = activation | ||
| .clear_inner() | ||
| .expect_err("an uncertain kind deregistration must retain the activation") | ||
| .to_string(); | ||
| assert!(error.contains("plugin registry lock poisoned"), "{error}"); | ||
| assert!(error.contains("activation owner were retained"), "{error}"); | ||
| assert!(!activation.is_active()); | ||
| assert_eq!( | ||
| *PLUGIN_MUTATION_OWNER.lock().unwrap(), | ||
| PluginMutationOwner::Host(owner_id) | ||
| ); | ||
| assert!(matches!( | ||
| acquire_plugin_host_lease(), | ||
| Err(crate::plugin::PluginError::Conflict(_)) | ||
| )); | ||
| } | ||
|
|
||
| #[test] | ||
| fn dynamic_plugin_specs_require_unique_nonempty_input() { | ||
| let empty = validate_dynamic_plugin_specs(&[]).unwrap_err().to_string(); | ||
| assert!( | ||
| empty.contains("requires at least one dynamic plugin"), | ||
| "{empty}" | ||
| ); | ||
|
|
||
| let duplicate = DynamicPluginActivationSpec { | ||
| plugin_id: "fixture.duplicate".into(), | ||
| kind: DynamicPluginKind::RustDynamic, | ||
| manifest_ref: "relay-plugin.toml".into(), | ||
| environment_ref: None, | ||
| config: Map::new(), | ||
| }; | ||
| let error = validate_dynamic_plugin_specs(&[duplicate.clone(), duplicate]) | ||
| .unwrap_err() | ||
| .to_string(); | ||
| assert!(error.contains("duplicate dynamic plugin id"), "{error}"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn plugin_error_context_preserves_each_error_class() { | ||
| use crate::plugin::PluginError; | ||
|
|
||
| let serialization = serde_json::from_str::<Json>("{").unwrap_err(); | ||
| let errors = [ | ||
| PluginError::InvalidConfig("invalid".into()), | ||
| PluginError::Conflict("conflict".into()), | ||
| PluginError::NotFound("missing".into()), | ||
| PluginError::Serialization(serialization), | ||
| PluginError::Internal("internal".into()), | ||
| PluginError::RegistrationFailed("registration".into()), | ||
| ]; | ||
|
|
||
| for error in errors { | ||
| let message = plugin_error_context("dynamic load", error).to_string(); | ||
| assert!(message.contains("dynamic load"), "{message}"); | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
| fn retained_runtime_errors_include_cleanup_details_when_available() { | ||
| let default_error = retained_runtime_error(Vec::new()).to_string(); | ||
| assert!( | ||
| default_error.contains("teardown was incomplete"), | ||
| "{default_error}" | ||
| ); | ||
|
|
||
| let detailed_error = | ||
| retained_runtime_error(vec!["registry remained active".into()]).to_string(); | ||
| assert!( | ||
| detailed_error.contains("registry remained active"), | ||
| "{detailed_error}" | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.