From 220db7656aac607c68ba23064ee59ed6802e073f Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Mon, 29 Feb 2016 18:01:07 +0000 Subject: [PATCH 1/2] Try to figure out the most suitable shell to use --- probe/docker/controls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probe/docker/controls.go b/probe/docker/controls.go index cb3303eb4..8977523e9 100644 --- a/probe/docker/controls.go +++ b/probe/docker/controls.go @@ -99,7 +99,7 @@ func (r *registry) execContainer(containerID string, req xfer.Request) xfer.Resp AttachStdout: true, AttachStderr: true, Tty: true, - Cmd: []string{"/bin/sh", "-c", "TERM=xterm exec /bin/sh"}, + Cmd: []string{"/bin/sh", "-c", "TERM=xterm exec $( (type getent > /dev/null 2>&1 && getent passwd root | cut -d: -f7 2>/dev/null) || echo /bin/sh)"}, Container: containerID, }) if err != nil { From 46b4fa39ec0002cfe5e3dcb4991808d74dae89e7 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Tue, 1 Mar 2016 13:22:50 +0000 Subject: [PATCH 2/2] Integration test --- Makefile | 3 ++- integration/410_container_control_test.sh | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8a8ea7a24..39b3da44d 100644 --- a/Makefile +++ b/Makefile @@ -152,4 +152,5 @@ deps: $(GO) get -u -f -tags $(GO_BUILD_TAGS) \ github.com/FiloSottile/gvt \ github.com/mattn/goveralls \ - github.com/weaveworks/github-release + github.com/weaveworks/github-release \ + github.com/2opremio/trifles/wscat diff --git a/integration/410_container_control_test.sh b/integration/410_container_control_test.sh index fa28a33cd..483c18622 100755 --- a/integration/410_container_control_test.sh +++ b/integration/410_container_control_test.sh @@ -14,6 +14,12 @@ wait_for_containers $HOST1 60 alpine assert "docker_on $HOST1 inspect --format='{{.State.Running}}' alpine" "true" PROBEID=$(docker_on $HOST1 logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p') HOSTID=$(echo $HOST1 | cut -d"." -f1) + + +# Execute 'echo foo' in a container tty and check its output +PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_exec_container" | jq -r '.pipe' ) +assert "(sleep 1 && echo 'echo foo' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "/ # 6necho foo\nfoo\n/ # 6n" + assert_raises "curl -f -X POST 'http://$HOST1:4040/api/control/$PROBEID/$CID;/docker_stop_container'" sleep 5