mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
API v1.20 (Docker Engine v1.11.0) and older allowed a HostConfig to be passed when starting a container. This feature was deprecated in API v1.21 (Docker Engine v1.10.0) in3e7405aea8, and removed in API v1.23 (Docker Engine v1.12.0) in commit0a8386c8be. API v1.23 and older are deprecated, and this patch removes the feature. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
65 lines
1.8 KiB
Go
65 lines
1.8 KiB
Go
//go:build !windows
|
|
|
|
package runconfig // import "github.com/docker/docker/runconfig"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/docker/docker/api/types/container"
|
|
"github.com/docker/docker/pkg/sysinfo"
|
|
)
|
|
|
|
func TestValidateResources(t *testing.T) {
|
|
type resourceTest struct {
|
|
ConfigCPURealtimePeriod int64
|
|
ConfigCPURealtimeRuntime int64
|
|
SysInfoCPURealtime bool
|
|
ErrorExpected bool
|
|
FailureMsg string
|
|
}
|
|
|
|
tests := []resourceTest{
|
|
{
|
|
ConfigCPURealtimePeriod: 1000,
|
|
ConfigCPURealtimeRuntime: 1000,
|
|
SysInfoCPURealtime: true,
|
|
ErrorExpected: false,
|
|
FailureMsg: "Expected valid configuration",
|
|
},
|
|
{
|
|
ConfigCPURealtimePeriod: 5000,
|
|
ConfigCPURealtimeRuntime: 5000,
|
|
SysInfoCPURealtime: false,
|
|
ErrorExpected: true,
|
|
FailureMsg: "Expected failure when cpu-rt-period is set but kernel doesn't support it",
|
|
},
|
|
{
|
|
ConfigCPURealtimePeriod: 5000,
|
|
ConfigCPURealtimeRuntime: 5000,
|
|
SysInfoCPURealtime: false,
|
|
ErrorExpected: true,
|
|
FailureMsg: "Expected failure when cpu-rt-runtime is set but kernel doesn't support it",
|
|
},
|
|
{
|
|
ConfigCPURealtimePeriod: 5000,
|
|
ConfigCPURealtimeRuntime: 10000,
|
|
SysInfoCPURealtime: true,
|
|
ErrorExpected: true,
|
|
FailureMsg: "Expected failure when cpu-rt-runtime is greater than cpu-rt-period",
|
|
},
|
|
}
|
|
|
|
for _, rt := range tests {
|
|
var hc container.HostConfig
|
|
hc.Resources.CPURealtimePeriod = rt.ConfigCPURealtimePeriod
|
|
hc.Resources.CPURealtimeRuntime = rt.ConfigCPURealtimeRuntime
|
|
|
|
var si sysinfo.SysInfo
|
|
si.CPURealtime = rt.SysInfoCPURealtime
|
|
|
|
if err := validateResources(&hc, &si); (err != nil) != rt.ErrorExpected {
|
|
t.Fatal(rt.FailureMsg, err)
|
|
}
|
|
}
|
|
}
|