Skip to content

AmenB/mtv-tests

Repository files navigation

MTV Tests

Test suite for MTV (Migration Toolkit for Virtualization) commands.

Setup

Install dependencies using uv:

uv sync

Or if you prefer to install in the current environment:

uv pip install -e .

Configuration

Configuration can be provided in two ways (in order of precedence):

  1. Environment variables (highest priority)
  2. providers.json file (fallback)

Using providers.json (Recommended for GitHub)

  1. Copy the example file:

    cp providers.json.example providers.json
  2. Edit providers.json with 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.

Using Environment Variables

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.

Project Structure

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

Running Tests

Run all tests:

uv run pytest -v -s

Run only migration workflow tests:

uv run pytest test_migration.py -v -s

Run a specific test:

uv run pytest test_migration.py::test_full_migration_workflow -v -s

Run example tests (if enabled):

# First rename _example.py to test_example.py to enable it
uv run pytest test_example.py -v -s

Creating New Tests

To create new test files:

  1. Copy test_example.py as a template
  2. Import helpers and fixtures:
    from helpers import run_oc_command, wait_for_provider_ready
  3. Use the config fixture for configuration:
    def test_my_test(config):
        namespace = config.get("MTV_NAMESPACE")
        # Your test code here
  4. Use the migration_test fixture 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.

Prerequisites

  • oc (OpenShift CLI) must be installed and configured
  • You must be logged into an OpenShift cluster
  • The namespace specified in MTV_NAMESPACE must exist or be creatable
  • Configuration must be provided via providers.json or environment variables

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages