Test suite for MTV (Migration Toolkit for Virtualization) commands.
Install dependencies using uv:
uv syncOr if you prefer to install in the current environment:
uv pip install -e .Configuration can be provided in two ways (in order of precedence):
- Environment variables (highest priority)
providers.jsonfile (fallback)
-
Copy the example file:
cp providers.json.example providers.json
-
Edit
providers.jsonwith your configuration:{ "MTV_NAMESPACE": "mtv-test", "VSPHERE_URL": "https://vsphere.example.com/sdk", "VSPHERE_USERNAME": "administrator@vsphere.local", "VSPHERE_PASSWORD": "YOUR_PASSWORD", "VSPHERE_HOST": "vsphere.example.com", "VDDK_IMAGE": "vddk:VERSION", "PLAN_NAME": "plan-example", "SOURCE_PROVIDER": "vmware-provider", "VM_NAME": "example-vm" }
Note: providers.json is in .gitignore and will not be committed to GitHub, keeping your credentials safe.
Alternatively, export the following required environment variables:
export MTV_NAMESPACE="mtv-test"
export VSPHERE_URL="https://vsphere.example.com/sdk"
export VSPHERE_USERNAME="administrator@vsphere.local"
export VSPHERE_PASSWORD="YOUR_PASSWORD"
export VSPHERE_HOST="vsphere.example.com"
export VDDK_IMAGE="quay.io/libvirt_v2v_cnv/vddk:VERSION"
export PLAN_NAME="plan-example"
export SOURCE_PROVIDER="vmware-provider"
export VM_NAME="example-vm"Note: Environment variables take precedence over providers.json if both are set.
mtv-tests/
├── config.py # Configuration loading from providers.json
├── helpers.py # Helper functions (run_oc_command, wait_for_*, etc.)
├── conftest.py # Pytest fixtures and configuration
├── test_migration.py # Main migration workflow tests
├── _example.py # Example test file (template for new tests, disabled)
├── providers.json # Your configuration (not in git)
├── providers.json.example # Example configuration template
└── README.md # This file
Run all tests:
uv run pytest -v -sRun only migration workflow tests:
uv run pytest test_migration.py -v -sRun a specific test:
uv run pytest test_migration.py::test_full_migration_workflow -v -sRun example tests (if enabled):
# First rename _example.py to test_example.py to enable it
uv run pytest test_example.py -v -sTo create new test files:
- Copy
test_example.pyas a template - Import helpers and fixtures:
from helpers import run_oc_command, wait_for_provider_ready
- Use the
configfixture for configuration:def test_my_test(config): namespace = config.get("MTV_NAMESPACE") # Your test code here
- Use the
migration_testfixture if you need the TestMTVMigration class:def test_my_test(migration_test): migration_test.create_openshift_provider()
All test files starting with test_*.py will be automatically discovered by pytest.
oc(OpenShift CLI) must be installed and configured- You must be logged into an OpenShift cluster
- The namespace specified in
MTV_NAMESPACEmust exist or be creatable - Configuration must be provided via
providers.jsonor environment variables