Skip to content

[Tigron]: revised Data interface #4081

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

Merged
merged 4 commits into from
Apr 18, 2025
Merged

Conversation

apostasie
Copy link
Contributor

@apostasie apostasie commented Apr 4, 2025

Blocked by #4111

From testing experience on nerdctl, many tests do require temporary resources (Dockerfiles, compose.yml, etc), and routinely redo the same thing over and over (create separate temp dir, write file, remove temp dir).
At best this adds a lot of boilerplate / helpers functions - at worst, the resources are not properly cleaned-up, or not well isolated from other tests.

The first commit changes the Data interface to allow temp files manipulation (Load, Save, Path, Dir, Exists), and more clearly separates labels and temporary resources.

The changes in tigron are minimal, but since the interface does change, the second commit does modify all current nerdctl tests that are making use of data labels.
Alongside this, some tests and helpers will now leverage the new temp file manipulation, along with some other minor cleanup in helpers and builder tests.

The PR looks big because of that ^.

Finally note that:

  • command cwd and temporary directory will no longer be the same
  • temporary dir generation has been altered so that basename is sha-ed after the test name to ensure better unicity (to be usable for compose)

@apostasie apostasie changed the title [STACKED] Tigron: [STACKED] Tigron: data assets Apr 4, 2025
@apostasie apostasie changed the title [STACKED] Tigron: data assets [STACKED] [Tigron]: data assets Apr 4, 2025
@apostasie apostasie force-pushed the tigron-5-data branch 3 times, most recently from 57578e8 to efbdc30 Compare April 4, 2025 20:39
@apostasie apostasie changed the title [STACKED] [Tigron]: data assets [STACKED] [WIP] [Tigron]: revised Data interface Apr 4, 2025
@apostasie apostasie changed the title [STACKED] [WIP] [Tigron]: revised Data interface [WIP] [Tigron]: revised Data interface Apr 15, 2025
@apostasie apostasie force-pushed the tigron-5-data branch 6 times, most recently from f736de3 to a6e5346 Compare April 15, 2025 22:07
- fix timeout showing 0s instead of default when no explicit timeout is provided
- add actual execution time
- fix long logs (stdout, stderr) that were showing only the beginning to also show the end
- fix formatting issue for "..."
- marginally better output for command contextual information

Signed-off-by: apostasie <[email protected]>
@apostasie apostasie force-pushed the tigron-5-data branch 8 times, most recently from e32781f to 7823694 Compare April 16, 2025 21:29
@@ -44,17 +44,17 @@ func TestBuildContextWithOCILayout(t *testing.T) {
),
Cleanup: func(data test.Data, helpers test.Helpers) {
if nerdtest.IsDocker() {
helpers.Anyhow("buildx", "stop", data.Identifier("-container"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leading dashes are unnecessary. Identifier does separate seed string with dash.

testCase := &test.Case{
Require: nerdtest.Build,
Cleanup: func(data test.Data, helpers test.Helpers) {
helpers.Anyhow("rmi", "-f", data.Identifier())
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These (and similar) were doing nothing, as there is no such image.

@apostasie apostasie changed the title [WIP] [Tigron]: revised Data interface [Tigron]: revised Data interface Apr 16, 2025
@apostasie apostasie marked this pull request as ready for review April 16, 2025 22:00
@apostasie
Copy link
Contributor Author

Failure is #4068

@apostasie apostasie marked this pull request as draft April 17, 2025 17:49
@apostasie
Copy link
Contributor Author

apostasie commented Apr 17, 2025

Momentarily reverting to draft.
Need to remove WithFile which is problematic and not helpful.
Forgot my security key today, so, cannot push right now.

Many tests require temporary resources (Dockerfiles, compose.yml, etc), and routinely
redo the same thing over and over (create separate temp dir, write file, remove temp dir).
At best this adds a lot of inconsistent boilerplate / helper functions to the test - at worst,
the resources are not properly cleaned-up, or not well isolated from other tests.

This PR does introduce a set of helpers to fasttrack temp files manipulation, and rejiggle the
Data interface to more clearly separate labels (shared with subtests) and temporary resources.

Signed-off-by: apostasie <[email protected]>
@apostasie apostasie marked this pull request as ready for review April 17, 2025 21:17
@AkihiroSuda AkihiroSuda added this to the v2.0.5 milestone Apr 18, 2025
@AkihiroSuda AkihiroSuda added the area/ci e.g., CI failure label Apr 18, 2025
data.Labels().Set("net1", data.Identifier("1"))
data.Labels().Set("net2", data.Identifier("2"))
data.Labels().Set("netID1", helpers.Capture("network", "create", "--label="+data.Labels().Get("label"), data.Labels().Get("net1")))
data.Labels().Set("netID2", helpers.Capture("network", "create", data.Labels().Get("net2")))
Copy link
Member

Choose a reason for hiding this comment

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

nit: Labels() could be just called once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wondering if the compiler manages to inline that?

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit e38cd0a into containerd:main Apr 18, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci e.g., CI failure
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants