Skip to content

Adding global config for Shuttle#218

Closed
dylanjwolff wants to merge 1 commit intoawslabs:mainfrom
dylanjwolff:global-config
Closed

Adding global config for Shuttle#218
dylanjwolff wants to merge 1 commit intoawslabs:mainfrom
dylanjwolff:global-config

Conversation

@dylanjwolff
Copy link
Contributor

This PR adds a global config for Shuttle, utilizing the config crate to make Shuttle tests configurable via a TOML file and/or environment variables. This allows users to swap scheduling algorithms, configuration parameters, or (in the future #217) time models declaratively without editing or recompiling their test code.

The public check function now uses this global config when running Shuttle tests. All other entrypoints to Shuttle (check_random, building a Runner manually, etc.) are unchanged.

Currently, the global config is the same for all tests using check, but it is easy to extend this in a future PR to store "sub-configs" in the global config objects, which can be accessed in subsets of tests via a key check(fn, key) API.

To run a scheduler via the global config, that scheduler must register a "factory" function that can create instances of that scheduler with the scheduler "registry". The scheduler "registry" is a global static that maps the name of the scheduler used in the config (scheduler.type) to the factory function. All basic schedulers in the Shuttle repository are registered by default, but additional custom schedulers can also be registered dynamically so that they can be run via the global config / check function.

Documentation

shuttle/shuttle_config_example.toml -- provides an example config with most configuration options for the included Shuttle schedulers
fn check -- the doc comment explains the configuration precedence and environment variable naming convention


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

/// Factory function type for creating schedulers from configuration
pub type SchedulerFactory = Arc<dyn Fn(&config::Config) -> Box<dyn Scheduler + Send> + Send + Sync>;

static REGISTRY: OnceLock<Mutex<HashMap<String, SchedulerFactory>>> = OnceLock::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a registry?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a request for a comment on the registry

} else {
Self::new(depth, iterations)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these shouldn't exist and that constructing a scheduler from a config should be done via the regular scheduler creation apis and live with the config

let mut map = HashMap::new();

// Register built-in schedulers
map.insert(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we insert instead of calling register_scheduler?

File(Option<std::path::PathBuf>),
}

impl FailurePersistence {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things might be easier with https://docs.rs/strum/latest/strum/


fn should_enable_metrics(global_config: &config::Config) -> bool {
global_config.get_bool("enable_metrics").unwrap()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These things should be impled on &self where self is the config and live somewhere else

@sarsko
Copy link
Contributor

sarsko commented Oct 13, 2025

Thanks!

I hate to be a hater, but I'm generally not a fan of how this has been structured. I'd like for the config stuff to be as far as possible "its own thing", meaning it really should be just changes in one file.

@sarsko
Copy link
Contributor

sarsko commented Oct 21, 2025

I think this is the least important PR to get merged this week. If you don't get to it, then I'll take on the work to drive it to merged.

@sarsko sarsko closed this Jan 12, 2026
@sarsko
Copy link
Contributor

sarsko commented Jan 12, 2026

Cancelling in favor of reopening or creating a new PR in the future.

I think this should be structured a bit differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants