Skip to content

Migrate image, volume and miscellaneous system tests. - #1868

Merged
jglogan merged 2 commits into
apple:mainfrom
jglogan:testmigrate-otherresources
Jun 30, 2026
Merged

Migrate image, volume and miscellaneous system tests.#1868
jglogan merged 2 commits into
apple:mainfrom
jglogan:testmigrate-otherresources

Conversation

@jglogan

@jglogan jglogan commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Improve integration test reliability.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@jglogan jglogan changed the title Migrate other integration tests. Migrate image, volume and miscellaneous system tests. Jun 29, 2026
@jglogan
jglogan requested a review from JaewonHur June 29, 2026 21:32
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Code Coverage

Tier Line Coverage
Unit 31.22%
Integration 15.19%
Combined 46.01%

@jglogan
jglogan force-pushed the testmigrate-otherresources branch from 00e8d17 to 02ae508 Compare June 30, 2026 02:05
- Part of apple#1833.
- Distributes fixture extensions for images and containers
  added as part of previous builder PR to more sensible
  locations.
@jglogan
jglogan force-pushed the testmigrate-otherresources branch from 02ae508 to b09f662 Compare June 30, 2026 04:44
Comment thread Tests/IntegrationTests/System/TestCLIKernelSetSerial.swift Outdated
/// then removes it when `body` exits (cleanup handled by the fixture scope).
func withTempDir<T>(_ body: (URL) async throws -> T) async throws -> T {
let dir = URL(filePath: testDir.appending(UUID().uuidString).string)
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should delete the directory on exit?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

According to the docc, yes.

It exists in the fixture scratch directory which gets deleted on exit from the fixture scope though (unless you specify the environment variable for preserving the scratch directories).

Let me review the use cases for this helper and figure out what makes the most sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This pattern resulted from literally translating the old tests to the new fixtures.

The new fixtures automatically run in a temp directory, so we can just get rid of the helper and have the tests operate directly in the scratch directory.

I noticed the same thing on the build tests but decided to leave those as is until we merged everything. Then, I've got a whole list of cleanups that remove unnecessary code like this.

#expect(list.contains(v1) && list.contains(v2))

let result = try f.run(["volume", "prune"]).check()
#expect(result.output.contains(v1) || !result.output.contains("No volumes to prune"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't it check result.output.contains(v1) only?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Prune should delete both v1 and v2. Checking for those should suffice.

The "no volumes" thing is weird. I'm not sure why the absence of "No volumes" passes the test if the output doesn't contain `v1. Let's remove those.

}
}

@Test func testAnonymousVolumeDetachedMode() async throws {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not critical, but the original test was setting autoRemote: true so that container is deleted on stop. New version slightly changes the test semantics.

@jglogan jglogan Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch...updated to match the old test.

.relativePath

try await ContainerFixture.with { f in
f.addCleanup { _ = try? f.run(["system", "kernel", "set", "--recommended", "--force"]) }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should catch and log if this fails? because it affects following tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree. Changed to record test issues on non-zero status or throw.

let c1 = "\(f.testID)-c1"
let c2 = "\(f.testID)-c2"
try f.doPull(alpine)
let image = try f.copyWarmupImage(alpine)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need to make copies of the alpine image for these tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't. Claude got a little overexuberant I think. We only need to make a copy if we intend to delete the image as part of the test.

@jglogan
jglogan merged commit 88ab319 into apple:main Jun 30, 2026
5 of 6 checks passed
@jglogan
jglogan deleted the testmigrate-otherresources branch June 30, 2026 22:25
saehejkang pushed a commit to saehejkang/container that referenced this pull request Jul 16, 2026
- Part of apple#1833.
- Distributes fixture extensions for images and containers added as part
of previous builder PR to more sensible locations.
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.

3 participants