From b3385caa4e0ca760279fc976bf1fb488bb2ba626 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 14 Jul 2015 14:47:47 -0700 Subject: [PATCH] add env support in mesos Signed-off-by: Victor Vieux --- cluster/mesos/task.go | 4 ++++ test/integration/api/inspect.bats | 3 ++- test/integration/mesos/api/inspect.bats | 32 +++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 test/integration/mesos/api/inspect.bats diff --git a/cluster/mesos/task.go b/cluster/mesos/task.go index 951d322cd5..da14ea46a3 100644 --- a/cluster/mesos/task.go +++ b/cluster/mesos/task.go @@ -104,6 +104,10 @@ func (t *task) build(slaveID string) { t.Container.Docker.Parameters = append(t.Container.Docker.Parameters, &mesosproto.Parameter{Key: proto.String("label"), Value: proto.String(fmt.Sprintf("%s=%s", key, value))}) } + for _, value := range t.config.Env { + t.Container.Docker.Parameters = append(t.Container.Docker.Parameters, &mesosproto.Parameter{Key: proto.String("env"), Value: proto.String(value)}) + } + t.SlaveId = &mesosproto.SlaveID{Value: &slaveID} } diff --git a/test/integration/api/inspect.bats b/test/integration/api/inspect.bats index 2e3d3adbd1..200732dea6 100644 --- a/test/integration/api/inspect.bats +++ b/test/integration/api/inspect.bats @@ -11,7 +11,7 @@ function teardown() { start_docker_with_busybox 2 swarm_manage # run container - docker_swarm run -d --name test_container busybox sleep 500 + docker_swarm run -d -e TEST=true --name test_container busybox sleep 500 # make sure container exsists run docker_swarm ps -l @@ -22,6 +22,7 @@ function teardown() { run docker_swarm inspect test_container [ "$status" -eq 0 ] [[ "${output}" == *"NetworkSettings"* ]] + [[ "${output}" == *"TEST=true"* ]] # the specific information of swarm node [[ "${output}" == *'"Node": {'* ]] [[ "${output}" == *'"Name": "node-'* ]] diff --git a/test/integration/mesos/api/inspect.bats b/test/integration/mesos/api/inspect.bats new file mode 100644 index 0000000000..08b4c60ede --- /dev/null +++ b/test/integration/mesos/api/inspect.bats @@ -0,0 +1,32 @@ +#!/usr/bin/env bats + +load ../mesos_helpers + +function teardown() { + swarm_manage_cleanup + stop_mesos + stop_docker +} + +@test "docker inspect" { + start_docker_with_busybox 2 + start_mesos + swarm_manage_mesos + # run container + docker_swarm run -d -m 20m -e TEST=true --name test_container busybox sleep 500 + + # make sure container exsists + run docker_swarm ps -l + [ "${#lines[@]}" -eq 2 ] + [[ "${lines[1]}" == *"test_container"* ]] + + # inspect and verify + run docker_swarm inspect test_container + [ "$status" -eq 0 ] + [[ "${output}" == *"NetworkSettings"* ]] + [[ "${output}" == *"TEST=true"* ]] + # the specific information of swarm node + [[ "${output}" == *'"Node": {'* ]] + [[ "${output}" == *'"Name": "node-'* ]] +} +