Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ceph-plugin-automation

Selenium tests against the vSphere Client IBM Storage / Datastore Snapshots plugin (shadow DOM + sandbox iframe), plus a dashboard that creates private-lab VMs, deploys or registers a Ceph cluster, and runs those tests.

Run the dashboard

The dashboard is two processes: the API on port 8000 and the UI on port 3000. Use two terminals. The API process is the one that clones VMs and SSHes to the lab, so the lab passwords have to be exported in that shell.

Tools

On the machine that runs the API:

python3 --version
node --version
npm --version
govc version
sshpass -V

govc clones the guests. sshpass is used for every SSH to cephprireg and the Ceph nodes. On macOS, brew install govc installs govc. Install sshpass as well and confirm both commands are on PATH.

Backend

From the repo root:

cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env

Skip venv and pip when backend/venv already exists. backend/.env holds API settings such as CORS. It does not supply the lab passwords. Export those in the same terminal before starting the server:

export GOVC_PASSWORD='the vCenter password'
export SSHPASS="$GOVC_PASSWORD"
export REGISTRY_PASSWORD='the cephprireg registry password'
export IBM_ENTITLEMENT_KEY='the IBM entitlement key'

GOVC_PASSWORD or SSHPASS is required to create VMs. Deploy also needs REGISTRY_PASSWORD, and IBM_ENTITLEMENT_KEY when the images are copied from cp.icr.io. GOVC_USERNAME defaults to administrator@vsphere.local.

When vCenter 10.64.0.252 has disconnected hosts, clone on the ESXi host instead:

export ESXI_URL='https://<esxi-host>/sdk'
export ESXI_USERNAME='root'

cephprireg defaults to 10.64.0.248. Set CEPHPRIREG_HOST when that address is different.

Start the API and leave this terminal open:

uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload

Wait for Uvicorn running on http://127.0.0.1:8000. The SQLite file is created at storage/ceph_automation.db. From another terminal:

curl http://127.0.0.1:8000/health

A healthy API returns {"status":"healthy"}. Interactive API docs are at http://127.0.0.1:8000/docs.

Frontend

In a second terminal, from the repo root:

cd frontend
npm install
npm run dev

Open http://localhost:3000. The UI proxies /api to http://localhost:8000. Live logs connect directly to port 8000 on the same host, so leave the API on 8000. If a port is already taken, stop the old process before starting again.

What each page does

  • Infrastructure clones the named template onto PG-Private-Lab and waits for a 172.16.200.51–.200 address. Enter a vCenter, then pick a datastore from the list that shows capacity and free space. A 10.64 address on that port group fails the batch.
  • Clusters deploys standalone, mirrored, cg_mirrored, or stretch from the YUM repo and images you enter, or registers a cluster that is already running. Register checks ceph -s and does not create VMs.
  • Tests and Test Runs run the checked tests or a marker expression against any cluster whose status is ready.
  • Test Runs — Mode 1: pick a standalone (or other) cluster, select one or more catalog tests, then start the run. When exactly one test is selected, the UI shows a case config form seeded from that module’s sibling YAML; edits are sent as run-scoped overrides (see CASE_CONFIG_OVERRIDE below). Sibling YAML on disk is never rewritten.
  • Test Runs — Mode 2 (Run plugin lifecycle): after a standalone cluster is selected, use Refresh storage systems to scrape the live IBM Storage plugin, multi-select systems that have replica pools, set how many datastores to create, then queue create → snapshot → protect → clone in order (add/delete datastore modules are not part of this flow). The run stops on the first failure.
  • Results shows pass and fail counts, the selection, and each test’s log and screenshots.

/data/ceph-mirror or /var/www/html/repo must already be mounted on cephprireg. The deploy job does not format a disk. Passwords stay in the shell environment and are redacted from logs.

Setup

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with VSPHERE_URL, credentials, host label, default datacenter

This root .env is what the Selenium tests read. The dashboard API does not load these vSphere values. Export GOVC_PASSWORD, SSHPASS, REGISTRY_PASSWORD, and IBM_ENTITLEMENT_KEY in the API terminal, as described above, before creating VMs or deploying Ceph.

For tests/storage_system/test_add_storage_system.py, also set PLUGIN_CLUSTER_USERNAME and PLUGIN_CLUSTER_PASSWORD (Ceph cluster credentials used in the plugin’s Add Storage System wizard). See .env.example.

Per-test YAML configuration

Each test module test_<name>.py has a sibling test_<name>.yaml with the same basename. That file is loaded automatically when the test runs:

  • An autouse fixture fails fast if the YAML is missing.
  • Tests receive the parsed dict via the case_config fixture (add case_config to the test function parameters).

Secrets and shared URLs stay in .env (src/config.py). Case-specific values (datastore name, snapshot index ranges, clone targets, etc.) belong in the YAML next to the test.

Module Config file
tests/storage_system/test_add_storage_system.py test_add_storage_system.yaml
tests/datastore/test_create_datastore.py test_create_datastore.yaml
tests/snapshot/test_snapshot_lifecycle.py test_snapshot_lifecycle.yaml
tests/snapshot/test_protect_snapshot.py test_protect_snapshot.yaml
tests/clone/test_thin_clone.py test_thin_clone.yaml
tests/delete_datastore/test_delete_datastore.py test_delete_datastore.yaml
tests/snapshot_scale/test_snapshot_scale.py test_snapshot_scale.yaml
tests/clone_scale/test_thin_clone_scale.py test_thin_clone_scale.yaml
tests/snap_protect_scale/test_snap_protect_scale.py test_snap_protect_scale.yaml
tests/datastore_scale/test_datastore_delete_scale.py test_datastore_delete_scale.yaml

Helpers for common keys live in src/case_fields.py.

Standalone plugin lifecycle modules

Five modules cover the standalone plugin flow (@pytest.mark.plugin, @pytest.mark.topology("standalone")). They share navigation via tests/plugin_nav.py and XPath constants in tests/plugin_selectors.py, captured from the live plugin on vCenter 10.64.0.250.

Step Module Notes
Add storage system tests/storage_system/test_add_storage_system.py Mode 1 only; needs PLUGIN_CLUSTER_*
Create VMFS datastore tests/datastore/test_create_datastore.py
Snapshot lifecycle tests/snapshot/test_snapshot_lifecycle.py create → revert → delete
Protect snapshot tests/snapshot/test_protect_snapshot.py
Thin clone tests/clone/test_thin_clone.py

Run-scoped overrides (CASE_CONFIG_OVERRIDE)

The dashboard can pass per-test overrides without changing YAML on disk. When a test run starts, the API may write a JSON file under storage/case_overrides/<run-id>/ and set CASE_CONFIG_OVERRIDE to that path. src/test_case_config.py deep-merges the file on top of the sibling YAML before tests see case_config. Use this from Test Runs Mode 1 (single-test form) or Mode 2 (lifecycle planner). Override files are removed when the run finishes.

Snapshot indices

Under snapshot, use either:

  • index_start and index_end — same semantics as Python range(index_start, index_end) (end exclusive), with names "{name_prefix}{i}", or
  • count with optional index_start (default 1) — creates count snapshots starting at that index.

Run

pytest tests/delete_datastore/test_delete_datastore.py -v
pytest tests/snapshot_scale/test_snapshot_scale.py -v -m headless
  • Set VSPHERE_HEADLESS=1 in .env to run all tests headless, or use -m headless on modules that declare the marker.

Layout

Path Purpose
src/config.py Environment-backed settings
src/case_fields.py Read/validate keys from case YAML
src/test_case_config.py Load sibling YAML for a test module
src/auth.py vSphere login
src/source.py Developer mode URL + plugin iframe switching
tests/conftest.py Chrome, vsphere_driver, case_config, YAML autouse check
tests/plugin_nav.py IBM Storage tree → datastore → Snapshots nav (lifecycle modules)
tests/plugin_selectors.py XPath constants from lab vCenter 10.64.0.250
conf/sample_vmware_config.yaml Sample infra (not wired into tests)

Plugin iframe contexts

src/source.py defines PluginIframeContext for different plugin-iframe locations. Legacy switchToIframe(driver, True) uses the modal dialog host; False uses the Datastore Snapshots class selector. If a flow breaks after UI changes, try switch_to_plugin_iframe(..., context=PluginIframeContext.GENERIC).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages