2020-07-28 01:57:33 +00:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
DASHBOARD_FRONTEND_DIR=${SCRIPT_DIR}/../../../src/pybind/mgr/dashboard/frontend
|
|
|
|
|
|
|
|
[ -z "$SUDO" ] && SUDO=sudo
|
|
|
|
|
|
|
|
install_common () {
|
2022-01-13 16:21:12 +00:00
|
|
|
NODEJS_VERSION="16"
|
2020-07-28 01:57:33 +00:00
|
|
|
if grep -q debian /etc/*-release; then
|
|
|
|
$SUDO apt-get update
|
2022-01-13 16:21:12 +00:00
|
|
|
# https://github.com/nodesource/distributions#manual-installation
|
|
|
|
$SUDO apt-get install curl gpg
|
|
|
|
KEYRING=/usr/share/keyrings/nodesource.gpg
|
|
|
|
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | $SUDO tee "$KEYRING" >/dev/null
|
|
|
|
DISTRO="$(source /etc/lsb-release; echo $DISTRIB_CODENAME)"
|
|
|
|
VERSION="node_$NODEJS_VERSION.x"
|
|
|
|
echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | $SUDO tee /etc/apt/sources.list.d/nodesource.list
|
|
|
|
echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | $SUDO tee -a /etc/apt/sources.list.d/nodesource.list
|
|
|
|
$SUDO apt-get update
|
|
|
|
$SUDO apt-get install nodejs
|
2020-07-28 01:57:33 +00:00
|
|
|
elif grep -q rhel /etc/*-release; then
|
2024-01-22 20:52:58 +00:00
|
|
|
if grep -q "CentOS Stream 9" /etc/*-release; then
|
|
|
|
NODEJS_VERSION="18"
|
|
|
|
fi
|
2022-01-13 16:21:12 +00:00
|
|
|
$SUDO yum module -y enable nodejs:$NODEJS_VERSION
|
2020-07-28 01:57:33 +00:00
|
|
|
$SUDO yum install -y jq npm
|
|
|
|
else
|
|
|
|
echo "Unsupported distribution."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_chrome () {
|
|
|
|
if grep -q debian /etc/*-release; then
|
|
|
|
$SUDO bash -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
|
|
|
|
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | $SUDO apt-key add -
|
|
|
|
$SUDO apt-get update
|
|
|
|
$SUDO apt-get install -y google-chrome-stable
|
|
|
|
$SUDO apt-get install -y xvfb
|
|
|
|
$SUDO rm /etc/apt/sources.list.d/google-chrome.list
|
|
|
|
elif grep -q rhel /etc/*-release; then
|
|
|
|
$SUDO dd of=/etc/yum.repos.d/google-chrome.repo status=none <<EOF
|
|
|
|
[google-chrome]
|
|
|
|
name=google-chrome
|
|
|
|
baseurl=https://dl.google.com/linux/chrome/rpm/stable/\$basearch
|
|
|
|
enabled=1
|
|
|
|
gpgcheck=1
|
|
|
|
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
|
|
|
|
EOF
|
|
|
|
$SUDO yum install -y google-chrome-stable
|
|
|
|
$SUDO rm /etc/yum.repos.d/google-chrome.repo
|
|
|
|
# Cypress dependencies
|
|
|
|
$SUDO yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss.x86_64 libXScrnSaver alsa-lib
|
|
|
|
else
|
|
|
|
echo "Unsupported distribution."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
cypress_run () {
|
|
|
|
local specs="$1"
|
|
|
|
local timeout="$2"
|
2023-05-31 05:39:25 +00:00
|
|
|
local override_config="excludeSpecPattern=*.po.ts,retries=0,specPattern=${specs}"
|
2020-07-28 01:57:33 +00:00
|
|
|
|
|
|
|
if [ x"$timeout" != "x" ]; then
|
|
|
|
override_config="${override_config},defaultCommandTimeout=${timeout}"
|
|
|
|
fi
|
|
|
|
npx cypress run --browser chrome --headless --config "$override_config"
|
|
|
|
}
|
|
|
|
|
|
|
|
install_common
|
|
|
|
install_chrome
|
|
|
|
|
|
|
|
CYPRESS_BASE_URL=$(ceph mgr services | jq -r .dashboard)
|
|
|
|
export CYPRESS_BASE_URL
|
|
|
|
|
|
|
|
cd $DASHBOARD_FRONTEND_DIR
|
|
|
|
|
|
|
|
# This is required for Cypress to understand typescript
|
|
|
|
npm ci --unsafe-perm
|
|
|
|
npx cypress verify
|
|
|
|
npx cypress info
|
|
|
|
|
2021-03-26 07:57:40 +00:00
|
|
|
# Take `orch device ls` and `orch ps` as ground truth.
|
2020-07-28 01:57:33 +00:00
|
|
|
ceph orch device ls --refresh
|
2021-03-26 07:57:40 +00:00
|
|
|
ceph orch ps --refresh
|
2020-07-28 01:57:33 +00:00
|
|
|
sleep 10 # the previous call is asynchronous
|
|
|
|
ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json
|
2021-03-26 07:57:40 +00:00
|
|
|
ceph orch ps --format=json | tee cypress/fixtures/orchestrator/services.json
|
2020-07-28 01:57:33 +00:00
|
|
|
|
2020-12-15 08:28:46 +00:00
|
|
|
DASHBOARD_ADMIN_SECRET_FILE="/tmp/dashboard-admin-secret.txt"
|
|
|
|
printf 'admin' > "${DASHBOARD_ADMIN_SECRET_FILE}"
|
|
|
|
ceph dashboard ac-user-set-password admin -i "${DASHBOARD_ADMIN_SECRET_FILE}" --force-password
|
2020-07-28 01:57:33 +00:00
|
|
|
|
|
|
|
# Run Dashboard e2e tests.
|
|
|
|
# These tests are designed with execution order in mind, since orchestrator operations
|
|
|
|
# are likely to change cluster state, we can't just run tests in arbitrarily order.
|
|
|
|
# See /ceph/src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/ folder.
|
|
|
|
find cypress # List all specs
|
|
|
|
|
2023-06-07 08:34:33 +00:00
|
|
|
cypress_run "cypress/e2e/orchestrator/01-hosts.e2e-spec.ts"
|
2020-07-28 01:57:33 +00:00
|
|
|
|
|
|
|
# Hosts are removed and added in the previous step. Do a refresh again.
|
|
|
|
ceph orch device ls --refresh
|
|
|
|
sleep 10
|
|
|
|
ceph orch device ls --format=json | tee cypress/fixtures/orchestrator/inventory.json
|
|
|
|
|
2023-06-07 08:34:33 +00:00
|
|
|
cypress_run "cypress/e2e/orchestrator/03-inventory.e2e-spec.ts"
|
|
|
|
cypress_run "cypress/e2e/orchestrator/04-osds.e2e-spec.ts" 300000
|