]> git.proxmox.com Git - ceph.git/blob - ceph/qa/workunits/cephadm/test_dashboard_e2e.sh
5764ecb5d43c25b248babb9bfd25af60a288f597
[ceph.git] / ceph / qa / workunits / cephadm / test_dashboard_e2e.sh
1 #!/bin/bash -ex
2
3 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4 DASHBOARD_FRONTEND_DIR=${SCRIPT_DIR}/../../../src/pybind/mgr/dashboard/frontend
5
6 [ -z "$SUDO" ] && SUDO=sudo
7
8 install_common () {
9 if grep -q debian /etc/*-release; then
10 $SUDO apt-get update
11 $SUDO apt-get install -y jq npm
12 elif grep -q rhel /etc/*-release; then
13 $SUDO yum install -y jq npm
14 else
15 echo "Unsupported distribution."
16 exit 1
17 fi
18 }
19
20 install_chrome () {
21 if grep -q debian /etc/*-release; then
22 $SUDO bash -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
23 curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | $SUDO apt-key add -
24 $SUDO apt-get update
25 $SUDO apt-get install -y google-chrome-stable
26 $SUDO apt-get install -y xvfb
27 $SUDO rm /etc/apt/sources.list.d/google-chrome.list
28 elif grep -q rhel /etc/*-release; then
29 $SUDO dd of=/etc/yum.repos.d/google-chrome.repo status=none <<EOF
30 [google-chrome]
31 name=google-chrome
32 baseurl=https://dl.google.com/linux/chrome/rpm/stable/\$basearch
33 enabled=1
34 gpgcheck=1
35 gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
36 EOF
37 $SUDO yum install -y google-chrome-stable
38 $SUDO rm /etc/yum.repos.d/google-chrome.repo
39 # Cypress dependencies
40 $SUDO yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss.x86_64 libXScrnSaver alsa-lib
41 else
42 echo "Unsupported distribution."
43 exit 1
44 fi
45 }
46
47 cypress_run () {
48 local specs="$1"
49 local timeout="$2"
50 local override_config="ignoreTestFiles=*.po.ts,retries=0,testFiles=${specs}"
51
52 if [ x"$timeout" != "x" ]; then
53 override_config="${override_config},defaultCommandTimeout=${timeout}"
54 fi
55 npx cypress run --browser chrome --headless --config "$override_config"
56 }
57
58 install_common
59 install_chrome
60
61 CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard)
62 export CYPRESS_BASE_URL
63
64 cd $DASHBOARD_FRONTEND_DIR
65
66 # This is required for Cypress to understand typescript
67 npm ci --unsafe-perm
68 npx cypress verify
69 npx cypress info
70
71 # Remove device_health_metrics pool
72 # Low pg count causes OSD removal failure.
73 ceph device monitoring off
74 ceph tell mon.\* injectargs '--mon-allow-pool-delete=true'
75 ceph osd pool rm device_health_metrics device_health_metrics --yes-i-really-really-mean-it
76
77 # Take `orch device ls` as ground truth.
78 ceph orch device ls --refresh
79 sleep 10 # the previous call is asynchronous
80 ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json
81
82 DASHBOARD_ADMIN_SECRET_FILE="/tmp/dashboard-admin-secret.txt"
83 printf 'admin' > "${DASHBOARD_ADMIN_SECRET_FILE}"
84 ceph dashboard ac-user-set-password admin -i "${DASHBOARD_ADMIN_SECRET_FILE}" --force-password
85
86 # Run Dashboard e2e tests.
87 # These tests are designed with execution order in mind, since orchestrator operations
88 # are likely to change cluster state, we can't just run tests in arbitrarily order.
89 # See /ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/ folder.
90 find cypress # List all specs
91
92 cypress_run "orchestrator/01-hosts.e2e-spec.ts"
93
94 # Hosts are removed and added in the previous step. Do a refresh again.
95 ceph orch device ls --refresh
96 sleep 10
97 ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json
98
99 cypress_run "orchestrator/02-hosts-inventory.e2e-spec.ts"
100 cypress_run "orchestrator/03-inventory.e2e-spec.ts"
101 cypress_run "orchestrator/04-osds.e2e-spec.ts" 300000