Skip to content

gha/ci: Add rootless integration test job#123

Draft
vvoland wants to merge 3 commits intocontainerd:mainfrom
vvoland:rootless-ci
Draft

gha/ci: Add rootless integration test job#123
vvoland wants to merge 3 commits intocontainerd:mainfrom
vvoland:rootless-ci

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Mar 19, 2026

gha/ci: Add rootless integration test job

Add an integration-rootless job that creates a non-root user
(testuser), adds it to the kvm group, and runs integration tests as that user.

integration: Simplify TestMain PATH setup

The previous logic prepended "../_output" and "." relative to the executable directory. This was fragile and only worked correctly when the binary was run from specific locations (test.sh from integration/). When run via "go test" the binary is in a temp dir where those relative paths are meaningless, and it only worked because PATH was already set externally via $GITHUB_PATH.

Simplify to just prepend the executable's own directory to PATH. Since all artifacts (libkrun.so, kernel, initrd) are built into _output/ alongside the test binary, this handles all execution methods:

  • test.sh (binary at ../_output/ relative to integration/)
  • go test (relies on PATH already containing _output/)
  • pre-compiled binary run directly from _output/

integration: Add test for shim start

Add TestShimStart that invokes the real containerd-shim-nerdbox-v1 binary with the "start" subcommand. This exercises the shim manager's Start() code path end-to-end, including mount namespace setup.

vvoland added 3 commits March 18, 2026 18:08
Add an `integration-rootless` job that creates a non-root user
(`testuser`), adds it to the kvm group, and runs integration tests
as that user.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
The previous logic prepended "../_output" and "." relative to the
executable directory. This was fragile and only worked correctly when
the binary was run from specific locations (test.sh from integration/).
When run via "go test" the binary is in a temp dir where those relative
paths are meaningless, and it only worked because PATH was already set
externally via $GITHUB_PATH.

Simplify to just prepend the executable's own directory to PATH. Since
all artifacts (libkrun.so, kernel, initrd) are built into _output/
alongside the test binary, this handles all execution methods:
- test.sh (binary at ../_output/ relative to integration/)
- go test (relies on PATH already containing _output/)
- pre-compiled binary run directly from _output/

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Add TestShimStart that invokes the real containerd-shim-nerdbox-v1
binary with the "start" subcommand. This exercises the shim manager's
Start() code path end-to-end, including mount namespace setup.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Copilot AI review requested due to automatic review settings March 19, 2026 11:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends CI and integration testing to better validate non-root execution and the shim startup path, while also making integration tests less dependent on how they’re invoked.

Changes:

  • Adds a new GitHub Actions job (integration-rootless) that runs integration tests as a non-root user with KVM group access.
  • Simplifies integration.TestMain PATH setup to prepend only the test binary’s directory.
  • Introduces a new integration test (TestShimStart) that invokes the real shim binary with the start subcommand to exercise the shim manager Start path end-to-end.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
integration/shim_start_test.go Adds an end-to-end shim start integration test using the real shim binary.
integration/main_test.go Simplifies PATH setup during integration test initialization.
.github/workflows/ci.yml Adds a rootless integration test job that runs the compiled integration test binary as a non-root user.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +65 to +72
out, err := cmd.Output()
if err != nil {
stderr := ""
if ee, ok := err.(*exec.ExitError); ok {
stderr = string(ee.Stderr)
}
t.Fatalf("shim start failed: %v\nstderr: %s", err, stderr)
}
Comment on lines +87 to +92
// Clean up the child shim process that Start() spawned.
pidData, err := os.ReadFile(filepath.Join(bundleDir, "shim.pid"))
if err == nil {
if pid, err := strconv.Atoi(strings.TrimSpace(string(pidData))); err == nil {
syscall.Kill(pid, syscall.SIGKILL)
}
Comment on lines +36 to +38
// Prepend the directory containing the test binary to PATH so that
// NewInstance can find libkrun.so, the kernel, and initrd located
// alongside the binary (the _output/ directory).
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