-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor integration test core into a new 'obs-commander-tests' crate #60
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
base: main
Are you sure you want to change the base?
Conversation
2fa48b7
to
4ced142
Compare
@refi64 as a first pass can you fix CI and the conflicts? |
4ced142
to
cb034e3
Compare
@sjoerdsimons conflicts fixed, I don't think |
fe73a54
to
fb9b128
Compare
fb9b128
to
44c397f
Compare
2e43c59
to
0a098a8
Compare
Passing around `self` risks confusing the borrow checker if we need to invoke a method on a field, and it's rather confusing to begin with.
All the generic command handling is now part of an `actions` module, and logging happens through a rather cursed magic bridge in the new `logging` module to remove the widespread use of outputln.
This is largely just a rename, as well as the slightly-silly `obs-commander-test-support` crate that exists to avoid making the primary `obs-commander` crate depend on testing dependencies.
Most of this logic is rather intricate and shareable between multiple implementations, so it makes sense for them to be in a separate crate. This necessitates quite a bit of refactoring of the test structure so that the shared test code can actually run commands and inspect the logs + artifacts. Since there are various somewhat strange requirements around command execution (i.e. needing to use timeouts but still get the result), that API was redone around a builder trait, which also makes it easy for implementation-specific tests to have their own methods on it.
0a098a8
to
0f81984
Compare
resolver = "3" | ||
members = [ | ||
"obs-commander", | ||
"obs-commander-tests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooi why both tests and test-support?
|
||
pub const MONITOR_TEST_OLD_STATUS_SLEEP_DURATION: Duration = Duration::from_millis(100); | ||
|
||
pub const MONITOR_TEST_LOG_TAIL: u64 = 50; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newline here but not between the other consts?
let srcmd5_prefix = format!( | ||
"srcmd5 '{}' ", | ||
if log_test == MonitorLogTest::Unavailable { | ||
ZERO_REV_SRCMD5.to_owned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick; why converting to an owned value if it's being formatting anyway?
let prune = context.run().command("prune").go().await; | ||
assert!(!prune.ok()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you use unwrap_err()
instead when it fails it will dump what Ok value got returned. If that's not useful at least assert on
is_err()`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same pattern in other places)
pub const EXECUTION_DEFAULT_TIMEOUT: Duration = Duration::from_secs(30); | ||
|
||
#[async_trait] | ||
pub trait RunBuilder<'context>: Send + Sync + Sized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would really help if these traits had documentation wrt. to what their meant to do (both overall and the functions)
As usual, only the last commit is new, depends on #58.