From 4443fa9e0e896104391c7b5b99bdf92875f8a694 Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Wed, 25 Feb 2026 16:01:31 +1000 Subject: [PATCH] chore: update full-spec test to include latest implemented Compose attributes --- pkg/client/compose/service_test.go | 48 ++++++++++++++++++- .../compose/testdata/compose-full-spec.yaml | 30 ++++++++++++ pkg/client/deploy/container_test.go | 2 +- 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/pkg/client/compose/service_test.go b/pkg/client/compose/service_test.go index a476b33c..3abbe6ad 100644 --- a/pkg/client/compose/service_test.go +++ b/pkg/client/compose/service_test.go @@ -94,7 +94,7 @@ func TestServiceSpecFromCompose(t *testing.T) { }, }, { - name: "full-spec", + name: "full spec", filename: "compose-full-spec.yaml", want: map[string]api.ServiceSpec{ "test": { @@ -133,6 +133,17 @@ func TestServiceSpecFromCompose(t *testing.T) { CPU: 0.5 * api.Core, Memory: 100 * units.MiB, MemoryReservation: 50 * units.MiB, + Ulimits: map[string]api.Ulimit{ + "nofile": {Soft: 20000, Hard: 40000}, + "nproc": {Soft: 65535, Hard: 65535}, + }, + Devices: []api.DeviceMapping{ + {HostPath: "/dev/ttyUSB0", ContainerPath: "/dev/ttyUSB0", CgroupPermissions: "rw"}, + {HostPath: "/dev/sda", ContainerPath: "/dev/xvda", CgroupPermissions: "rwm"}, + }, + DeviceReservations: []container.DeviceRequest{ + {Count: -1, Capabilities: [][]string{{"gpu"}}}, + }, }, Sysctls: map[string]string{ "net.ipv4.ip_forward": "1", @@ -148,6 +159,15 @@ func TestServiceSpecFromCompose(t *testing.T) { VolumeName: "data1", ContainerPath: "/data1", }, + { + VolumeName: "bind-53f1acbf1de61e9e608c93effca23791674e463d02bb7aaca7c625804aef1926", + ContainerPath: "/path/in/container", + ReadOnly: true, + }, + { + VolumeName: "data3-labeled", + ContainerPath: "/data3", + }, { VolumeName: "data2-alias", ContainerPath: "/data2/long/syntax", @@ -182,8 +202,23 @@ func TestServiceSpecFromCompose(t *testing.T) { Mode: api.PortModeHost, }, }, + Placement: api.Placement{ + Machines: []string{"machine-1", "machine-2"}, + }, Replicas: 3, + UpdateConfig: api.UpdateConfig{ + Order: api.UpdateOrderStopFirst, + }, Volumes: []api.VolumeSpec{ + { + Name: "bind-53f1acbf1de61e9e608c93effca23791674e463d02bb7aaca7c625804aef1926", + Type: api.VolumeTypeBind, + BindOptions: &api.BindOptions{ + HostPath: "/path/on/host", + CreateHostPath: true, + Propagation: mount.Propagation("rprivate"), + }, + }, { Name: "bind-bb6aed1683cea1e0a1ae5cd227aacd0734f2f87f7a78fcf1baeff978ce300b90", Type: api.VolumeTypeBind, @@ -216,11 +251,22 @@ func TestServiceSpecFromCompose(t *testing.T) { }, }, }, + { + Name: "data3-labeled", + Type: api.VolumeTypeVolume, + VolumeOptions: &api.VolumeOptions{ + Name: "data3-labeled", + NoCopy: true, + SubPath: "app/data", + Labels: map[string]string{"env": "test"}, + }, + }, { Name: "tmpfs-efa57ba8b6a1779674ac438de3af8729e2d55900b79eb929431cf9c5b0179542", Type: api.VolumeTypeTmpfs, TmpfsOptions: &mount.TmpfsOptions{ SizeBytes: 10 * units.MiB, + Mode: os.FileMode(1777), }, }, }, diff --git a/pkg/client/compose/testdata/compose-full-spec.yaml b/pkg/client/compose/testdata/compose-full-spec.yaml index 9f024f98..c61749c2 100644 --- a/pkg/client/compose/testdata/compose-full-spec.yaml +++ b/pkg/client/compose/testdata/compose-full-spec.yaml @@ -6,11 +6,18 @@ services: - ALL command: ["nginx", "updated", "command"] cpus: 0.5 + deploy: + update_config: + order: stop-first + devices: + - /dev/ttyUSB0:/dev/ttyUSB0:rw + - /dev/sda:/dev/xvda entrypoint: ["/updated-docker-entrypoint.sh"] environment: BOOL: "true" EMPTY: "" VAR: value + gpus: all healthcheck: test: ["CMD", "curl", "-f", "http://localhost"] interval: 1m30s @@ -32,10 +39,28 @@ services: scale: 3 sysctls: - net.ipv4.ip_forward=1 + ulimits: + nofile: + soft: 20000 + hard: 40000 + nproc: 65535 user: nginx:nginx volumes: - /etc/passwd:/host/etc/passwd:ro - data1:/data1 + - type: bind + source: /path/on/host + target: /path/in/container + read_only: true + bind: + create_host_path: true + propagation: rprivate + - type: volume + source: data3-labeled + target: /data3 + volume: + nocopy: true + subpath: app/data - type: volume source: data2-alias target: /data2/long/syntax @@ -44,6 +69,8 @@ services: target: /tmpfs tmpfs: size: 10485760 + mode: 1777 + x-machines: ["machine-1", "machine-2"] x-ports: - test.example.com:80/https - 8000/http @@ -62,5 +89,8 @@ volumes: data2-alias: name: data2 driver: local + data3-labeled: + labels: + env: test data-external: external: true diff --git a/pkg/client/deploy/container_test.go b/pkg/client/deploy/container_test.go index cc99c933..bf819fbb 100644 --- a/pkg/client/deploy/container_test.go +++ b/pkg/client/deploy/container_test.go @@ -1410,7 +1410,7 @@ func TestEvalContainerSpecChange_Volumes(t *testing.T) { } } -func TestEvalContainerSpecChange_DeviceMappings(t *testing.T) { +func TestEvalContainerSpecChange_Devices(t *testing.T) { t.Parallel() tests := []struct {