]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/run-frontend-e2e-tests.sh
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / pybind / mgr / dashboard / run-frontend-e2e-tests.sh
1 #!/usr/bin/env bash
2
3 set -e
4
5 CLUSTERS=("1" "2")
6
7 ceph() {
8 ${FULL_PATH_BUILD_DIR}/../src/mrun 1 ceph $@
9 }
10
11 ceph2() {
12 ${FULL_PATH_BUILD_DIR}/../src/mrun 2 ceph $@
13 }
14
15 ceph_all() {
16 ceph $@
17 ceph2 $@
18 }
19
20 start_ceph() {
21 cd $FULL_PATH_BUILD_DIR
22
23 for cluster in ${CLUSTERS[@]}; do
24 export CEPH_OUT_CLIENT_DIR=${FULL_PATH_BUILD_DIR}/run/${cluster}/out/client
25 MGR=2 RGW=1 ../src/mstart.sh $cluster -n -d
26 done
27
28 set -x
29
30 # Create an Object Gateway User
31 ceph_all dashboard set-rgw-credentials
32
33 # Set SSL verify to False
34 ceph_all dashboard set-rgw-api-ssl-verify False
35
36 CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard)
37 CYPRESS_CEPH2_URL=$(ceph2 mgr services | jq -r .dashboard)
38
39 # start rbd-mirror daemon in the cluster
40 KEY=$(ceph auth get client.admin --format=json | jq -r .[0].key)
41 MON_CLUSTER_1=$(grep "mon host" ${FULL_PATH_BUILD_DIR}/run/1/ceph.conf | awk '{print $4}')
42 ${FULL_PATH_BUILD_DIR}/bin/rbd-mirror --mon_host $MON_CLUSTER_1 --key $KEY -c ${FULL_PATH_BUILD_DIR}/run/1/ceph.conf
43
44 set +x
45 }
46
47 stop() {
48 if [ "$REMOTE" == "false" ]; then
49 cd ${FULL_PATH_BUILD_DIR}
50 for cluster in ${CLUSTERS[@]}; do
51 ../src/mstop.sh $cluster
52 done
53 pids=$(pgrep rbd-mirror)
54 if [ -n "$pids" ]; then
55 echo Killing rbd-mirror processes: $pids
56 kill -9 $pids
57 fi
58 fi
59 exit $1
60 }
61
62 check_device_available() {
63 failed=false
64
65 if [ "$DEVICE" == "docker" ]; then
66 [ -x "$(command -v docker)" ] || failed=true
67 else
68 cd $DASH_DIR/frontend
69 npx cypress verify
70
71 case "$DEVICE" in
72 chrome)
73 [ -x "$(command -v chrome)" ] || [ -x "$(command -v google-chrome)" ] ||
74 [ -x "$(command -v google-chrome-stable)" ] || failed=true
75 ;;
76 chromium)
77 [ -x "$(command -v chromium)" ] || [ -x "$(command -v chromium-browser)" ] || failed=true
78 ;;
79 esac
80 fi
81
82 if [ "$failed" = "true" ]; then
83 echo "ERROR: $DEVICE not found. You need to install $DEVICE or \
84 use a different device. Supported devices: chrome (default), chromium, electron or docker."
85 stop 1
86 fi
87 }
88
89 : ${CYPRESS_BASE_URL:=''}
90 : ${CYPRESS_CEPH2_URL:=''}
91 : ${CYPRESS_LOGIN_PWD:=''}
92 : ${CYPRESS_LOGIN_USER:=''}
93 : ${DEVICE:="chrome"}
94 : ${NO_COLOR:=1}
95 : ${CYPRESS_ARGS:=''}
96 : ${REMOTE:='false'}
97
98 while getopts 'd:p:r:u:' flag; do
99 case "${flag}" in
100 d) DEVICE=$OPTARG;;
101 p) CYPRESS_LOGIN_PWD=$OPTARG;;
102 r) REMOTE='true'
103 CYPRESS_BASE_URL=$OPTARG;;
104 u) CYPRESS_LOGIN_USER=$OPTARG;;
105 esac
106 done
107
108 DASH_DIR=`pwd`
109 [ -z "$BUILD_DIR" ] && BUILD_DIR=build
110 cd ../../../../${BUILD_DIR}
111 FULL_PATH_BUILD_DIR=`pwd`
112
113 [[ "$(command -v npm)" == '' ]] && . ${FULL_PATH_BUILD_DIR}/src/pybind/mgr/dashboard/frontend/node-env/bin/activate
114
115 : ${CYPRESS_CACHE_FOLDER:="${FULL_PATH_BUILD_DIR}/src/pybind/mgr/dashboard/cypress"}
116
117 export CYPRESS_BASE_URL CYPRESS_CACHE_FOLDER CYPRESS_LOGIN_USER CYPRESS_LOGIN_PWD NO_COLOR CYPRESS_CEPH2_URL
118
119 check_device_available
120
121 if [ "$CYPRESS_BASE_URL" == "" ]; then
122 start_ceph
123 fi
124
125 cd $DASH_DIR/frontend
126
127 # Remove existing XML results
128 rm -f cypress/reports/results-*.xml || true
129
130 case "$DEVICE" in
131 docker)
132 failed=0
133 CYPRESS_VERSION=$(cat package.json | grep '"cypress"' | grep -o "[0-9]\.[0-9]\.[0-9]")
134 docker run \
135 -v $(pwd):/e2e \
136 -w /e2e \
137 --env CYPRESS_BASE_URL \
138 --env CYPRESS_LOGIN_USER \
139 --env CYPRESS_LOGIN_PWD \
140 --env CYPRESS_CEPH2_URL \
141 --name=e2e \
142 --network=host \
143 cypress/included:${CYPRESS_VERSION} || failed=1
144 stop $failed
145 ;;
146 *)
147 npx cypress run $CYPRESS_ARGS --browser $DEVICE --headless || stop 1
148 ;;
149 esac
150
151 stop 0