410_container_control_test.sh 1.2 KB

123456789101112131415161718192021222324252627282930
  1. #! /bin/bash
  2. # shellcheck disable=SC1091
  3. . ./config.sh
  4. start_suite "Test container controls"
  5. weave_on "$HOST1" launch
  6. scope_on "$HOST1" launch
  7. CID=$(weave_proxy_on "$HOST1" run -dti --name alpine -e PATH=/home:/usr/bin alpine /bin/sh)
  8. wait_for_containers "$HOST1" 60 alpine
  9. assert "docker_on $HOST1 inspect --format='{{.State.Running}}' alpine" "true"
  10. PROBEID=$(docker_on "$HOST1" logs weavescope 2>&1 | grep "probe starting" | sed -n 's/^.*ID \([0-9a-f]*\)$/\1/p')
  11. # Execute 'echo $PATH' in a container tty and check its output - as
  12. # well as checking basic operation, this also checks that the
  13. # container's PATH settings are respected, which isn't the case for
  14. # login shells.
  15. PIPEID=$(curl -s -f -X POST "http://$HOST1:4040/api/control/$PROBEID/$CID;<container>/docker_exec_container" | jq -r '.pipe')
  16. assert "(sleep 1 && echo 'echo \$PATH' && sleep 1) | wscat -b 'ws://$HOST1:4040/api/pipe/$PIPEID' | col -pb" "/ # 6necho \$PATH\\n/home:/usr/bin\\n/ # 6n"
  17. assert_raises "curl -f -X POST 'http://$HOST1:4040/api/control/$PROBEID/$CID;<container>/docker_stop_container'"
  18. sleep 5
  19. assert "docker_on $HOST1 inspect --format='{{.State.Running}}' alpine" "false"
  20. scope_end_suite