Skip to content
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

[sled-agent] Create an "Executor", which intercepts requests through std::process::Command #3442

Open
wants to merge 94 commits into
base: main
Choose a base branch
from

Conversation

smklein
Copy link
Collaborator

@smklein smklein commented Jun 28, 2023

Goal

  • Make it possible to test the Sled Agent's interface with the underlying Host OS
    • In particular, make it possible to test the commands in illumos-utils, which largely rely on std::process::Command.
    • Eventually, I'd like to expand the Executor introduced in this PR to emulate "all aspects of the host we expect Sled Agent to manipulate", which may include abstraction around FFI calls as well.

Implementation

  • Replaces illumos_utils::execute with illumos_utils::host::Executor, which provides an interface to take a std::process::Command as input, execute it, and provide some output. This provides the following advantages:
    • All invocations made through this interface are logged consistently, for both input and output, clearly showing the equivalent command that could be made through a shell.
    • All invocations made through this interface have the opportunity to be intercepted by a FakeExecutor, so they can be explicitly tested. This allows us to reduce our usage on mocks, and also create tests that more clearly align to our system interface.
  • Additional tests using these facilities exist in...
    • illumos_utils/src/dladm.rs
    • illumos_utils/src/zone.rs
    • sled-agent/src/services.rs
  • Removes mockall dependency, as well as testing feature flag for illumos-utils.

Follow-up work:

Fixes #2422

smklein added 30 commits June 16, 2023 09:16
Copy link
Collaborator Author

@smklein smklein left a comment

Choose a reason for hiding this comment

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

Thanks for the excellent feedback, @jgallagher and @gjcolombo !

illumos-utils/src/zone.rs Outdated Show resolved Hide resolved
illumos-utils/src/zone.rs Show resolved Hide resolved
installinator/src/write.rs Outdated Show resolved Hide resolved
installinator/src/write.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/executor.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/byte_queue.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/error.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/executor.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/executor.rs Outdated Show resolved Hide resolved
illumos-utils/src/host/executor.rs Outdated Show resolved Hide resolved
@smklein
Copy link
Collaborator Author

smklein commented Aug 21, 2023

I went ahead and split this implementation into different crates, according to the following diagram:

image

These crates exist in the top level helios directory, under helios/fusion, helios/tokamak, and helios/protostar. All callers depending on helios/tokamak currently only do so via a dev-dependency.

@jordanhendricks
Copy link
Contributor

jordanhendricks commented Aug 28, 2023

We chatted some about this PR offline. After some reflection, I have a few higher-level concerns about the broader goal of doing host-level emulation as an abstraction to enable testing in sled agent. Since this is such a big re-architecture of the sled agent, and I am going to be taking on more work in this area shortly, I would really like a chance to get to understand these changes (and maybe discuss more the goals here).

I would appreciate getting some time to chat more about this when I am back from PTO (after Labor Day). And I am also happy to write down my thoughts here as well, and ideas for other designs I would consider.

@smklein
Copy link
Collaborator Author

smklein commented Sep 11, 2023

We chatted some about this PR offline. After some reflection, I have a few higher-level concerns about the broader goal of doing host-level emulation as an abstraction to enable testing in sled agent. Since this is such a big re-architecture of the sled agent, and I am going to be taking on more work in this area shortly, I would really like a chance to get to understand these changes (and maybe discuss more the goals here).

I would appreciate getting some time to chat more about this when I am back from PTO (after Labor Day). And I am also happy to write down my thoughts here as well, and ideas for other designs I would consider.

I would really like to move forward on this PR if I'm allowed to. Please let me know what I can do to unblock this.

@jordanhendricks
Copy link
Contributor

jordanhendricks commented Sep 11, 2023

For posterity: I had some questions about the design and goals of the PR and was not attempting to allow or disallow anything; as I said before, I wanted to understand the approach and goals better. @smklein and I chatted offline and have some concrete action items to take to address my concerns, but I don't have any objections to merging this PR.

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.

[sled agent] Fakes are better than mocks; get rid of mocks
4 participants