mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
chore: update full-spec test to include latest implemented Compose attributes
This commit is contained in:
@@ -94,7 +94,7 @@ func TestServiceSpecFromCompose(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "full-spec",
|
name: "full spec",
|
||||||
filename: "compose-full-spec.yaml",
|
filename: "compose-full-spec.yaml",
|
||||||
want: map[string]api.ServiceSpec{
|
want: map[string]api.ServiceSpec{
|
||||||
"test": {
|
"test": {
|
||||||
@@ -133,6 +133,17 @@ func TestServiceSpecFromCompose(t *testing.T) {
|
|||||||
CPU: 0.5 * api.Core,
|
CPU: 0.5 * api.Core,
|
||||||
Memory: 100 * units.MiB,
|
Memory: 100 * units.MiB,
|
||||||
MemoryReservation: 50 * 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{
|
Sysctls: map[string]string{
|
||||||
"net.ipv4.ip_forward": "1",
|
"net.ipv4.ip_forward": "1",
|
||||||
@@ -148,6 +159,15 @@ func TestServiceSpecFromCompose(t *testing.T) {
|
|||||||
VolumeName: "data1",
|
VolumeName: "data1",
|
||||||
ContainerPath: "/data1",
|
ContainerPath: "/data1",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
VolumeName: "bind-53f1acbf1de61e9e608c93effca23791674e463d02bb7aaca7c625804aef1926",
|
||||||
|
ContainerPath: "/path/in/container",
|
||||||
|
ReadOnly: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
VolumeName: "data3-labeled",
|
||||||
|
ContainerPath: "/data3",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
VolumeName: "data2-alias",
|
VolumeName: "data2-alias",
|
||||||
ContainerPath: "/data2/long/syntax",
|
ContainerPath: "/data2/long/syntax",
|
||||||
@@ -182,8 +202,23 @@ func TestServiceSpecFromCompose(t *testing.T) {
|
|||||||
Mode: api.PortModeHost,
|
Mode: api.PortModeHost,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Placement: api.Placement{
|
||||||
|
Machines: []string{"machine-1", "machine-2"},
|
||||||
|
},
|
||||||
Replicas: 3,
|
Replicas: 3,
|
||||||
|
UpdateConfig: api.UpdateConfig{
|
||||||
|
Order: api.UpdateOrderStopFirst,
|
||||||
|
},
|
||||||
Volumes: []api.VolumeSpec{
|
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",
|
Name: "bind-bb6aed1683cea1e0a1ae5cd227aacd0734f2f87f7a78fcf1baeff978ce300b90",
|
||||||
Type: api.VolumeTypeBind,
|
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",
|
Name: "tmpfs-efa57ba8b6a1779674ac438de3af8729e2d55900b79eb929431cf9c5b0179542",
|
||||||
Type: api.VolumeTypeTmpfs,
|
Type: api.VolumeTypeTmpfs,
|
||||||
TmpfsOptions: &mount.TmpfsOptions{
|
TmpfsOptions: &mount.TmpfsOptions{
|
||||||
SizeBytes: 10 * units.MiB,
|
SizeBytes: 10 * units.MiB,
|
||||||
|
Mode: os.FileMode(1777),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ services:
|
|||||||
- ALL
|
- ALL
|
||||||
command: ["nginx", "updated", "command"]
|
command: ["nginx", "updated", "command"]
|
||||||
cpus: 0.5
|
cpus: 0.5
|
||||||
|
deploy:
|
||||||
|
update_config:
|
||||||
|
order: stop-first
|
||||||
|
devices:
|
||||||
|
- /dev/ttyUSB0:/dev/ttyUSB0:rw
|
||||||
|
- /dev/sda:/dev/xvda
|
||||||
entrypoint: ["/updated-docker-entrypoint.sh"]
|
entrypoint: ["/updated-docker-entrypoint.sh"]
|
||||||
environment:
|
environment:
|
||||||
BOOL: "true"
|
BOOL: "true"
|
||||||
EMPTY: ""
|
EMPTY: ""
|
||||||
VAR: value
|
VAR: value
|
||||||
|
gpus: all
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
test: ["CMD", "curl", "-f", "http://localhost"]
|
||||||
interval: 1m30s
|
interval: 1m30s
|
||||||
@@ -32,10 +39,28 @@ services:
|
|||||||
scale: 3
|
scale: 3
|
||||||
sysctls:
|
sysctls:
|
||||||
- net.ipv4.ip_forward=1
|
- net.ipv4.ip_forward=1
|
||||||
|
ulimits:
|
||||||
|
nofile:
|
||||||
|
soft: 20000
|
||||||
|
hard: 40000
|
||||||
|
nproc: 65535
|
||||||
user: nginx:nginx
|
user: nginx:nginx
|
||||||
volumes:
|
volumes:
|
||||||
- /etc/passwd:/host/etc/passwd:ro
|
- /etc/passwd:/host/etc/passwd:ro
|
||||||
- data1:/data1
|
- 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
|
- type: volume
|
||||||
source: data2-alias
|
source: data2-alias
|
||||||
target: /data2/long/syntax
|
target: /data2/long/syntax
|
||||||
@@ -44,6 +69,8 @@ services:
|
|||||||
target: /tmpfs
|
target: /tmpfs
|
||||||
tmpfs:
|
tmpfs:
|
||||||
size: 10485760
|
size: 10485760
|
||||||
|
mode: 1777
|
||||||
|
x-machines: ["machine-1", "machine-2"]
|
||||||
x-ports:
|
x-ports:
|
||||||
- test.example.com:80/https
|
- test.example.com:80/https
|
||||||
- 8000/http
|
- 8000/http
|
||||||
@@ -62,5 +89,8 @@ volumes:
|
|||||||
data2-alias:
|
data2-alias:
|
||||||
name: data2
|
name: data2
|
||||||
driver: local
|
driver: local
|
||||||
|
data3-labeled:
|
||||||
|
labels:
|
||||||
|
env: test
|
||||||
data-external:
|
data-external:
|
||||||
external: true
|
external: true
|
||||||
|
|||||||
@@ -1410,7 +1410,7 @@ func TestEvalContainerSpecChange_Volumes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEvalContainerSpecChange_DeviceMappings(t *testing.T) {
|
func TestEvalContainerSpecChange_Devices(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user