runconfig: update fixtures for TestDecodeContainerConfig

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a401c0c046)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-07-23 15:34:46 +02:00
parent 596404f3aa
commit 7d6a75b342
5 changed files with 248 additions and 122 deletions

View File

@@ -14,6 +14,33 @@ import (
is "gotest.tools/v3/assert/cmp"
)
/*
TestDecodeContainerConfig validates unmarshaling a container config fixture.
Fixture created using;
docker run -it \
--cap-add=NET_ADMIN \
--cap-drop=MKNOD \
--cpu-shares=512 \
--cpuset-cpus=0,1 \
--dns=8.8.8.8 \
--entrypoint bash \
--label com.example.license=GPL \
--label com.example.vendor=Acme \
--label com.example.version=1.0 \
--link=redis3:redis \
--log-driver=json-file \
--mac-address="12:34:56:78:9a:bc" \
--memory=4M \
--network=bridge \
--volumes-from=other:ro \
--volumes-from=parent \
-p=11022:22/tcp \
-v /tmp \
-v /tmp:/tmp \
ubuntu date
*/
func TestDecodeContainerConfig(t *testing.T) {
type testCase struct {
doc string
@@ -22,18 +49,17 @@ func TestDecodeContainerConfig(t *testing.T) {
entrypoint []string
}
// FIXME (thaJeztah): update fixtures for more current versions.
tests := []testCase{
{
doc: "API 1.19 windows",
doc: "API 1.24 windows",
imgName: "windows",
fixture: "fixtures/windows/container_config_1_19.json",
fixture: "fixtures/windows/container_config_1_24.json",
entrypoint: []string{"cmd"},
},
{
doc: "API 1.19 unix",
doc: "API 1.24 unix",
imgName: "ubuntu",
fixture: "fixtures/unix/container_config_1_19.json",
fixture: "fixtures/unix/container_config_1_24.json",
entrypoint: []string{"bash"},
},
}
@@ -49,7 +75,7 @@ func TestDecodeContainerConfig(t *testing.T) {
assert.Check(t, is.Equal(c.Image, tc.imgName))
assert.Check(t, is.DeepEqual([]string(c.Entrypoint), tc.entrypoint))
var expected int64 = 1000
var expected int64 = 4194304
assert.Check(t, is.Equal(h.Memory, expected))
})
}

View File

@@ -1,58 +0,0 @@
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Entrypoint": "bash",
"Image": "ubuntu",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"Volumes": {
"/tmp": {}
},
"WorkingDir": "",
"NetworkDisabled": false,
"MacAddress": "12:34:56:78:9a:bc",
"ExposedPorts": {
"22/tcp": {}
},
"HostConfig": {
"Binds": ["/tmp:/tmp"],
"Links": ["redis3:redis"],
"LxcConf": {"lxc.utsname":"docker"},
"Memory": 1000,
"MemorySwap": 0,
"CpuShares": 512,
"CpusetCpus": "0,1",
"PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
"PublishAllPorts": false,
"Privileged": false,
"ReadonlyRootfs": false,
"Dns": ["8.8.8.8"],
"DnsSearch": [""],
"DnsOptions": [""],
"ExtraHosts": null,
"VolumesFrom": ["parent", "other:ro"],
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
"NetworkMode": "bridge",
"Devices": [],
"Ulimits": [{}],
"LogConfig": { "Type": "json-file", "Config": {} },
"SecurityOpt": [""],
"CgroupParent": ""
}
}

View File

@@ -0,0 +1,108 @@
{
"AttachStderr": true,
"AttachStdin": true,
"AttachStdout": true,
"Cmd": ["date"],
"Domainname": "",
"Entrypoint": ["bash"],
"Env": [],
"ExposedPorts": {
"22/tcp": {}
},
"HostConfig": {
"AutoRemove": false,
"Binds": ["/tmp:/tmp"],
"BlkioDeviceReadBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceWriteIOps": null,
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"Cgroup": "",
"CgroupParent": "",
"ConsoleSize": [0,0],
"ContainerIDFile": "",
"CpuCount": 0,
"CpuPercent": 0,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuShares": 512,
"CpusetCpus": "0,1",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"Dns": ["8.8.8.8"],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IOMaximumBandwidth": 0,
"IOMaximumIOps": 0,
"IpcMode": "",
"Isolation": "",
"KernelMemory": 0,
"Links": [
"redis3:redis"
],
"LogConfig": {
"Config": {},
"Type": "json-file"
},
"Memory": 4194304,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"NetworkMode": "bridge",
"OomKillDisable": false,
"OomScoreAdj": 0,
"PidMode": "",
"PidsLimit": 0,
"PortBindings": {
"22/tcp": [
{
"HostIp": "",
"HostPort": "11022"
}
]
},
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": "no"
},
"SecurityOpt": null,
"ShmSize": 0,
"UTSMode": "",
"Ulimits": null,
"UsernsMode": "",
"VolumeDriver": "",
"VolumesFrom": [
"parent",
"other:ro"
]
},
"Hostname": "",
"Image": "ubuntu",
"Labels": {
"com.example.license": "GPL",
"com.example.vendor": "Acme",
"com.example.version": "1.0"
},
"MacAddress": "12:34:56:78:9a:bc",
"NetworkingConfig": {
"EndpointsConfig": {}
},
"OnBuild": null,
"OpenStdin": true,
"StdinOnce": true,
"Tty": true,
"User": "",
"Volumes": {
"/tmp": {}
},
"WorkingDir": ""
}

View File

@@ -1,58 +0,0 @@
{
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": null,
"Cmd": [
"date"
],
"Entrypoint": "cmd",
"Image": "windows",
"Labels": {
"com.example.vendor": "Acme",
"com.example.license": "GPL",
"com.example.version": "1.0"
},
"Volumes": {
"c:/windows": {}
},
"WorkingDir": "",
"NetworkDisabled": false,
"MacAddress": "12:34:56:78:9a:bc",
"ExposedPorts": {
"22/tcp": {}
},
"HostConfig": {
"Binds": ["c:/windows:d:/tmp"],
"Links": ["redis3:redis"],
"LxcConf": {"lxc.utsname":"docker"},
"Memory": 1000,
"MemorySwap": 0,
"CpuShares": 512,
"CpusetCpus": "0,1",
"PortBindings": { "22/tcp": [{ "HostPort": "11022" }] },
"PublishAllPorts": false,
"Privileged": false,
"ReadonlyRootfs": false,
"Dns": ["8.8.8.8"],
"DnsSearch": [""],
"DnsOptions": [""],
"ExtraHosts": null,
"VolumesFrom": ["parent", "other:ro"],
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"RestartPolicy": { "Name": "", "MaximumRetryCount": 0 },
"NetworkMode": "default",
"Devices": [],
"Ulimits": [{}],
"LogConfig": { "Type": "json-file", "Config": {} },
"SecurityOpt": [""],
"CgroupParent": ""
}
}

View File

@@ -0,0 +1,108 @@
{
"AttachStderr": true,
"AttachStdin": true,
"AttachStdout": true,
"Cmd": ["date"],
"Domainname": "",
"Entrypoint": ["cmd"],
"Env": [],
"ExposedPorts": {
"22/tcp": {}
},
"HostConfig": {
"AutoRemove": false,
"Binds": ["c:/windows:/tmp"],
"BlkioDeviceReadBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceWriteIOps": null,
"BlkioWeight": 0,
"BlkioWeightDevice": null,
"CapAdd": ["NET_ADMIN"],
"CapDrop": ["MKNOD"],
"Cgroup": "",
"CgroupParent": "",
"ConsoleSize": [0,0],
"ContainerIDFile": "",
"CpuCount": 0,
"CpuPercent": 0,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuShares": 512,
"CpusetCpus": "0,1",
"CpusetMems": "",
"Devices": [],
"DiskQuota": 0,
"Dns": ["8.8.8.8"],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IOMaximumBandwidth": 0,
"IOMaximumIOps": 0,
"IpcMode": "",
"Isolation": "",
"KernelMemory": 0,
"Links": [
"redis3:redis"
],
"LogConfig": {
"Config": {},
"Type": "json-file"
},
"Memory": 4194304,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": -1,
"NetworkMode": "bridge",
"OomKillDisable": false,
"OomScoreAdj": 0,
"PidMode": "",
"PidsLimit": 0,
"PortBindings": {
"22/tcp": [
{
"HostIp": "",
"HostPort": "11022"
}
]
},
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": "no"
},
"SecurityOpt": null,
"ShmSize": 0,
"UTSMode": "",
"Ulimits": null,
"UsernsMode": "",
"VolumeDriver": "",
"VolumesFrom": [
"parent",
"other:ro"
]
},
"Hostname": "",
"Image": "windows",
"Labels": {
"com.example.license": "GPL",
"com.example.vendor": "Acme",
"com.example.version": "1.0"
},
"MacAddress": "12:34:56:78:9a:bc",
"NetworkingConfig": {
"EndpointsConfig": {}
},
"OnBuild": null,
"OpenStdin": true,
"StdinOnce": true,
"Tty": true,
"User": "",
"Volumes": {
"c:/windows": {}
},
"WorkingDir": ""
}