mirror of https://github.com/docker/docs.git
Merge pull request #1059 from vieux/add_env_support_in_mesos
add env support in mesos
This commit is contained in:
commit
2037540728
|
@ -44,6 +44,13 @@ func (t *task) build(slaveID string) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.config.Hostname != "" {
|
||||||
|
t.Container.Hostname = proto.String(t.config.Hostname)
|
||||||
|
if t.config.Domainname != "" {
|
||||||
|
t.Container.Hostname = proto.String(t.config.Hostname + "." + t.config.Domainname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch t.config.HostConfig.NetworkMode {
|
switch t.config.HostConfig.NetworkMode {
|
||||||
case "none":
|
case "none":
|
||||||
t.Container.Docker.Network = mesosproto.ContainerInfo_DockerInfo_NONE.Enum()
|
t.Container.Docker.Network = mesosproto.ContainerInfo_DockerInfo_NONE.Enum()
|
||||||
|
@ -104,6 +111,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))})
|
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}
|
t.SlaveId = &mesosproto.SlaveID{Value: &slaveID}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ function teardown() {
|
||||||
start_docker_with_busybox 2
|
start_docker_with_busybox 2
|
||||||
swarm_manage
|
swarm_manage
|
||||||
# run container
|
# run container
|
||||||
docker_swarm run -d --name test_container busybox sleep 500
|
docker_swarm run -d -e TEST=true -h hostname.test --name test_container busybox sleep 500
|
||||||
|
|
||||||
# make sure container exsists
|
# make sure container exsists
|
||||||
run docker_swarm ps -l
|
run docker_swarm ps -l
|
||||||
|
@ -22,6 +22,9 @@ function teardown() {
|
||||||
run docker_swarm inspect test_container
|
run docker_swarm inspect test_container
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "${output}" == *"NetworkSettings"* ]]
|
[[ "${output}" == *"NetworkSettings"* ]]
|
||||||
|
[[ "${output}" == *"TEST=true"* ]]
|
||||||
|
[[ "${output}" == *'"Hostname": "hostname"'* ]]
|
||||||
|
[[ "${output}" == *'"Domainname": "test"'* ]]
|
||||||
# the specific information of swarm node
|
# the specific information of swarm node
|
||||||
[[ "${output}" == *'"Node": {'* ]]
|
[[ "${output}" == *'"Node": {'* ]]
|
||||||
[[ "${output}" == *'"Name": "node-'* ]]
|
[[ "${output}" == *'"Name": "node-'* ]]
|
||||||
|
|
|
@ -8,7 +8,7 @@ function teardown() {
|
||||||
stop_docker
|
stop_docker
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "docker events" {
|
@test "mesos - docker events" {
|
||||||
start_docker_with_busybox 2
|
start_docker_with_busybox 2
|
||||||
start_mesos
|
start_mesos
|
||||||
swarm_manage_mesos
|
swarm_manage_mesos
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load ../mesos_helpers
|
||||||
|
|
||||||
|
function teardown() {
|
||||||
|
swarm_manage_cleanup
|
||||||
|
stop_mesos
|
||||||
|
stop_docker
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "mesos - docker inspect" {
|
||||||
|
start_docker_with_busybox 2
|
||||||
|
start_mesos
|
||||||
|
swarm_manage_mesos
|
||||||
|
# run container
|
||||||
|
docker_swarm run -d -m 20m -e TEST=true -h hostname.test --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"* ]]
|
||||||
|
[[ "${output}" == *'"Hostname": "hostname"'* ]]
|
||||||
|
[[ "${output}" == *'"Domainname": "test"'* ]]
|
||||||
|
# the specific information of swarm node
|
||||||
|
[[ "${output}" == *'"Node": {'* ]]
|
||||||
|
[[ "${output}" == *'"Name": "node-'* ]]
|
||||||
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ function execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tests to run. Defaults to all.
|
# Tests to run. Defaults to all.
|
||||||
TESTS=${@:-. discovery api mesos}
|
TESTS=${@:-. discovery api mesos/api}
|
||||||
|
|
||||||
# Generate a temporary binary for the tests.
|
# Generate a temporary binary for the tests.
|
||||||
export SWARM_BINARY=`mktemp`
|
export SWARM_BINARY=`mktemp`
|
||||||
|
|
Loading…
Reference in New Issue