diff --git a/cluster/mesos/task.go b/cluster/mesos/task.go index 951d322cd5..6f9242138d 100644 --- a/cluster/mesos/task.go +++ b/cluster/mesos/task.go @@ -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 { case "none": 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))}) } + 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..e8dfbc334e 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 -h hostname.test --name test_container busybox sleep 500 # make sure container exsists run docker_swarm ps -l @@ -22,6 +22,9 @@ function teardown() { 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-'* ]] diff --git a/test/integration/mesos/api/events.bats b/test/integration/mesos/api/events.bats index 3f2671a426..3e8ad6aa45 100644 --- a/test/integration/mesos/api/events.bats +++ b/test/integration/mesos/api/events.bats @@ -8,7 +8,7 @@ function teardown() { stop_docker } -@test "docker events" { +@test "mesos - docker events" { start_docker_with_busybox 2 start_mesos swarm_manage_mesos diff --git a/test/integration/mesos/api/inspect.bats b/test/integration/mesos/api/inspect.bats new file mode 100644 index 0000000000..9c72589067 --- /dev/null +++ b/test/integration/mesos/api/inspect.bats @@ -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-'* ]] +} + diff --git a/test/integration/test_runner.sh b/test/integration/test_runner.sh index ebae66e481..faedb97a89 100755 --- a/test/integration/test_runner.sh +++ b/test/integration/test_runner.sh @@ -12,7 +12,7 @@ function execute() { } # Tests to run. Defaults to all. -TESTS=${@:-. discovery api mesos} +TESTS=${@:-. discovery api mesos/api} # Generate a temporary binary for the tests. export SWARM_BINARY=`mktemp`