]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
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 () { | |
20effc67 | 9 | NODEJS_VERSION="16" |
f67539c2 TL |
10 | if grep -q debian /etc/*-release; then |
11 | $SUDO apt-get update | |
20effc67 TL |
12 | # https://github.com/nodesource/distributions#manual-installation |
13 | $SUDO apt-get install curl gpg | |
14 | KEYRING=/usr/share/keyrings/nodesource.gpg | |
15 | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | $SUDO tee "$KEYRING" >/dev/null | |
16 | DISTRO="$(source /etc/lsb-release; echo $DISTRIB_CODENAME)" | |
17 | VERSION="node_$NODEJS_VERSION.x" | |
18 | echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | $SUDO tee /etc/apt/sources.list.d/nodesource.list | |
19 | echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | $SUDO tee -a /etc/apt/sources.list.d/nodesource.list | |
20 | $SUDO apt-get update | |
21 | $SUDO apt-get install nodejs | |
f67539c2 | 22 | elif grep -q rhel /etc/*-release; then |
f38dd50b TL |
23 | if grep -q "CentOS Stream 9" /etc/*-release; then |
24 | NODEJS_VERSION="18" | |
25 | fi | |
20effc67 | 26 | $SUDO yum module -y enable nodejs:$NODEJS_VERSION |
f67539c2 TL |
27 | $SUDO yum install -y jq npm |
28 | else | |
29 | echo "Unsupported distribution." | |
30 | exit 1 | |
31 | fi | |
32 | } | |
33 | ||
34 | install_chrome () { | |
35 | if grep -q debian /etc/*-release; then | |
36 | $SUDO bash -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list' | |
37 | curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | $SUDO apt-key add - | |
38 | $SUDO apt-get update | |
39 | $SUDO apt-get install -y google-chrome-stable | |
40 | $SUDO apt-get install -y xvfb | |
41 | $SUDO rm /etc/apt/sources.list.d/google-chrome.list | |
42 | elif grep -q rhel /etc/*-release; then | |
43 | $SUDO dd of=/etc/yum.repos.d/google-chrome.repo status=none <<EOF | |
44 | [google-chrome] | |
45 | name=google-chrome | |
46 | baseurl=https://dl.google.com/linux/chrome/rpm/stable/\$basearch | |
47 | enabled=1 | |
48 | gpgcheck=1 | |
49 | gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub | |
50 | EOF | |
51 | $SUDO yum install -y google-chrome-stable | |
52 | $SUDO rm /etc/yum.repos.d/google-chrome.repo | |
53 | # Cypress dependencies | |
54 | $SUDO yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss.x86_64 libXScrnSaver alsa-lib | |
55 | else | |
56 | echo "Unsupported distribution." | |
57 | exit 1 | |
58 | fi | |
59 | } | |
60 | ||
61 | cypress_run () { | |
62 | local specs="$1" | |
63 | local timeout="$2" | |
1e59de90 | 64 | local override_config="excludeSpecPattern=*.po.ts,retries=0,specPattern=${specs}" |
f67539c2 TL |
65 | |
66 | if [ x"$timeout" != "x" ]; then | |
67 | override_config="${override_config},defaultCommandTimeout=${timeout}" | |
68 | fi | |
69 | npx cypress run --browser chrome --headless --config "$override_config" | |
70 | } | |
71 | ||
72 | install_common | |
73 | install_chrome | |
74 | ||
75 | CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard) | |
76 | export CYPRESS_BASE_URL | |
77 | ||
78 | cd $DASHBOARD_FRONTEND_DIR | |
79 | ||
80 | # This is required for Cypress to understand typescript | |
81 | npm ci --unsafe-perm | |
82 | npx cypress verify | |
83 | npx cypress info | |
84 | ||
b3b6e05e | 85 | # Take `orch device ls` and `orch ps` as ground truth. |
f67539c2 | 86 | ceph orch device ls --refresh |
b3b6e05e | 87 | ceph orch ps --refresh |
f67539c2 TL |
88 | sleep 10 # the previous call is asynchronous |
89 | ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json | |
b3b6e05e | 90 | ceph orch ps --format=json | tee cypress/fixtures/orchestrator/services.json |
f67539c2 TL |
91 | |
92 | DASHBOARD_ADMIN_SECRET_FILE="/tmp/dashboard-admin-secret.txt" | |
93 | printf 'admin' > "${DASHBOARD_ADMIN_SECRET_FILE}" | |
94 | ceph dashboard ac-user-set-password admin -i "${DASHBOARD_ADMIN_SECRET_FILE}" --force-password | |
95 | ||
96 | # Run Dashboard e2e tests. | |
97 | # These tests are designed with execution order in mind, since orchestrator operations | |
98 | # are likely to change cluster state, we can't just run tests in arbitrarily order. | |
99 | # See /ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/ folder. | |
100 | find cypress # List all specs | |
101 | ||
1e59de90 | 102 | cypress_run "cypress/e2e/orchestrator/01-hosts.e2e-spec.ts" |
f67539c2 TL |
103 | |
104 | # Hosts are removed and added in the previous step. Do a refresh again. | |
105 | ceph orch device ls --refresh | |
106 | sleep 10 | |
107 | ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json | |
108 | ||
1e59de90 TL |
109 | cypress_run "cypress/e2e/orchestrator/03-inventory.e2e-spec.ts" |
110 | cypress_run "cypress/e2e/orchestrator/04-osds.e2e-spec.ts" 300000 |