forked from ManageIQ/integration_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfme_test.sh
executable file
·78 lines (64 loc) · 2.28 KB
/
cfme_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Exit on error
set -e
# Load from YAML
PYTHON_ENV_PATH=\
$(readlink -f "$(shyaml get-value tmux.PYTHON_ENV_PATH < ./conf/env.local.yaml)")
CFME_TEST_PATH=\
$(readlink -f "$(shyaml get-value tmux.CFME_TEST_PATH < ./conf/env.local.yaml)")
if [ -n "$PYTHON_ENV_PATH" ] && [ -d "$PYTHON_ENV_PATH" ] \
&& [ -n "$CFME_TEST_PATH" ] && [ -d "$CFME_TEST_PATH" ]
then
echo "cfme_test: $CFME_TEST_PATH"
echo "virtualenv: $PYTHON_ENV_PATH"
else
echo "Missing or invalid YAML data!" >&2
echo "Please ensure the 'tmux' section exist and is properly configured." >&2
exit 1
fi
# More information on DockerBot can be found
# https://github.com/RedHatQE/cfme_tests/blob/master/scripts/dockerbot/README.md
if [ "$(systemctl is-active docker)" != "active" ]
then
echo "Starting Docker..."
systemctl start docker
else
echo "Docker already running"
fi
# check for latest
BASE_IMAGE="cfmeqe/sel_ff_chrome"
REGISTRY="docker.io"
IMAGE="$REGISTRY/$BASE_IMAGE"
CID="$(docker ps | grep "$BASE_IMAGE" | { read id _; echo "$id"; })"
docker pull $IMAGE > /dev/null
# tmux the rest of the things
VEN_ACTIVATE="source $PYTHON_ENV_PATH/activate"
USER_SHELL="$(getent passwd "$(id -u)")"
USER_SHELL="${USER_SHELL##*:}"
if [ -z "$CID" ]
then
echo "Starting CFME container..."
tmux new-session -s cfme_tests -n container -d \
"$VEN_ACTIVATE; \
cd $CFME_TEST_PATH; \
python cfme/utils/dockerbot/sel_container.py --watch --webdriver 4444; \
exec $USER_SHELL"
sleep 20s
tmux new-window -t cfme_tests "$VEN_ACTIVATE; exec $USER_SHELL"
window=1
else
tmux new-session -s cfme_tests -d "$VEN_ACTIVATE; exec $USER_SHELL"
window=0
fi
tmux select-layout -t cfme_tests even-vertical
tmux split-window -v -t cfme_tests -c "$CFME_TEST_PATH" "$VEN_ACTIVATE; exec $USER_SHELL"
tmux select-layout -t cfme_tests even-vertical
tmux split-window -v -t cfme_tests "$VEN_ACTIVATE; exec $USER_SHELL"
# let the shells start before sending any input
sleep 0.5
# tail CFME log
tmux send-keys -t cfme_tests:$window.0 "tail -f $CFME_TEST_PATH/log/cfme.log" C-m
# you'll need to change to the test pane and hit enter to execute test
tmux send-keys -t cfme_tests:$window.1 "py.test -k test_bad_password cfme/tests/test_login.py"
# attach to tmux cfme_tests window
tmux attach-session -t cfme_tests