mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-14 22:24:14 +00:00
runtime: fix missing context argument in mocked sandbox APIs
Missing context.Context in several APIs. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
parent
8ff62beeb4
commit
8e71c4fc7a
@ -7,6 +7,7 @@
|
||||
package containerdshim
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/containerd/cgroups"
|
||||
@ -50,7 +51,7 @@ func TestStatNetworkMetric(t *testing.T) {
|
||||
sandbox.StatsContainerFunc = nil
|
||||
}()
|
||||
|
||||
resp, err := sandbox.StatsContainer(testContainerID)
|
||||
resp, err := sandbox.StatsContainer(context.Background(), testContainerID)
|
||||
assert.NoError(err)
|
||||
|
||||
metrics := statsToMetrics(&resp)
|
||||
|
@ -6,6 +6,7 @@
|
||||
package containerdshim
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
@ -83,7 +84,7 @@ func TestStatsSandbox(t *testing.T) {
|
||||
containers: make(map[string]*container),
|
||||
}
|
||||
|
||||
initialSandboxStats, initialContainerStats, err := s.statsSandbox()
|
||||
initialSandboxStats, initialContainerStats, err := s.statsSandbox(context.Background())
|
||||
assert.Nil(err)
|
||||
assert.Equal(uint64(1000*1e9), initialSandboxStats.CgroupStats.CPUStats.CPUUsage.TotalUsage)
|
||||
assert.Equal(2, len(initialContainerStats))
|
||||
@ -96,7 +97,7 @@ func TestStatsSandbox(t *testing.T) {
|
||||
sandbox.StatsFunc = getSandboxCPUFunc(2000, 110000)
|
||||
sandbox.StatsContainerFunc = getStatsContainerCPUFunc(200, 400, 20000, 40000)
|
||||
|
||||
finishSandboxStats, finishContainersStats, err := s.statsSandbox()
|
||||
finishSandboxStats, finishContainersStats, err := s.statsSandbox(context.Background())
|
||||
|
||||
// calc overhead
|
||||
mem, cpu := calcOverhead(initialSandboxStats, finishSandboxStats, initialContainerStats, finishContainersStats, 1e9)
|
||||
|
@ -71,12 +71,12 @@ func (s *Sandbox) Release(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// Start implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) Start() error {
|
||||
func (s *Sandbox) Start(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stop implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) Stop(force bool) error {
|
||||
func (s *Sandbox) Stop(ctx context.Context, force bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ func (s *Sandbox) StartContainer(ctx context.Context, contID string) (vc.VCConta
|
||||
}
|
||||
|
||||
// StopContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) StopContainer(contID string, force bool) (vc.VCContainer, error) {
|
||||
func (s *Sandbox) StopContainer(ctx context.Context, contID string, force bool) (vc.VCContainer, error) {
|
||||
return &Container{}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user