Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cmd/nerdctl/container/container_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ func TestCommit(t *testing.T) {
helpers.Anyhow("rmi", "-f", data.Identifier())
},
Setup: func(data test.Data, helpers test.Helpers) {
// FIXME: short of pulling first, docker will fail to start the container.
// Debugging shows container exited immediately. Nothing in the container logs. Not much in journalctl.
// It is not clear what is happening.
if nerdtest.IsDocker() {
helpers.Ensure("pull", testutil.CommonImage)
}
Comment thread
apostasie marked this conversation as resolved.
helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", "infinity")
nerdtest.EnsureContainerStarted(helpers, data.Identifier())
helpers.Ensure("exec", data.Identifier(), "sh", "-euxc", `echo hello-test-commit > /foo`)
},
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
Expand Down
92 changes: 92 additions & 0 deletions cmd/nerdctl/container/container_top_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
Copyright The containerd Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package container

import (
"runtime"
"testing"

"github.com/containerd/nerdctl/v2/pkg/testutil"
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
"github.com/containerd/nerdctl/v2/pkg/testutil/test"
)

func TestTop(t *testing.T) {
testCase := nerdtest.Setup()

//more details https://github.com/containerd/nerdctl/pull/223#issuecomment-851395178
if runtime.GOOS == "linux" {
testCase.Require = nerdtest.CgroupsAccessible
}

testCase.Setup = func(data test.Data, helpers test.Helpers) {
// FIXME: busybox 1.36 on windows still appears to not support sleep inf. Unclear why.
helpers.Ensure("run", "-d", "--name", data.Identifier(), testutil.CommonImage, "sleep", "10")
data.Set("cID", data.Identifier())
}

testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
helpers.Anyhow("rm", "-f", data.Identifier())
}

testCase.SubTests = []*test.Case{
{
Description: "with o pid,user,cmd",
// Docker does not support top -o
Require: test.Not(nerdtest.Docker),
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("top", data.Get("cID"), "-o", "pid,user,cmd")
},

Expected: test.Expects(0, nil, nil),
},
{
Description: "simple",
Command: func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("top", data.Get("cID"))
},

Expected: test.Expects(0, nil, nil),
},
}

testCase.Run(t)
}

func TestTopHyperVContainer(t *testing.T) {

testCase := nerdtest.Setup()

testCase.Require = nerdtest.HyperV

testCase.Setup = func(data test.Data, helpers test.Helpers) {
// FIXME: busybox 1.36 on windows still appears to not support sleep inf. Unclear why.
helpers.Ensure("run", "--isolation", "hyperv", "-d", "--name", data.Identifier("container"), testutil.CommonImage, "sleep", "10")
}

testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
helpers.Anyhow("rm", "-f", data.Identifier("container"))
}

testCase.Command = func(data test.Data, helpers test.Helpers) test.TestableCommand {
return helpers.Command("top", data.Identifier("container"))
}

testCase.Expected = test.Expects(0, nil, nil)

testCase.Run(t)
}
43 changes: 0 additions & 43 deletions cmd/nerdctl/container/container_top_unix_test.go

This file was deleted.

47 changes: 0 additions & 47 deletions cmd/nerdctl/container/container_top_windows_test.go

This file was deleted.