Skip to main content
This tutorial demonstrates how Vers transforms traditional testing workflows by enabling parallel test execution from branched VM states. We’ll showcase the core value of Vers: eliminating repetitive setup work through VM branching.

What You’ll Learn

  • The power of branching VM states at decision points
  • Parallel test execution across different scenarios
  • How to save time compared to traditional testing workflows

Prerequisites

  • Vers CLI installed and authenticated
  • Basic familiarity with command-line tools

Project Overview

We’ll demonstrate parallel testing workflows using VM branching. Instead of repeating setup steps for each test scenario, we’ll:
  1. Set up once: Create a VM and install dependencies
  2. Branch at decision points: Capture the state right before testing
  3. Test in parallel: Run different test scenarios simultaneously
This approach saves significant time as your test suite grows.

Step 1: Project Setup

Initialize the Project

mkdir parallel-testing
cd parallel-testing
vers init

Configure the Environment

Edit the generated vers.toml to allocate sufficient resources:
[machine]
mem_size_mib = 1024
vcpu_count = 1
fs_size_vm_mib = 2048

[rootfs]
name = "default"

[kernel]
name = "default.bin"

Step 2: Launch and Set Up the Environment

Start the VM

vers run --vm-alias root
This command:
  1. Creates the root VM
  2. Sets an alias “root” for easy reference

Connect and Set Up Dependencies

vers connect
Inside the VM, set up your testing environment:
# Test internet connectivity
curl -s https://httpbin.org/ip

# If no output, configure nameserver
echo 'nameserver 8.8.8.8' > /etc/resolv.conf

# Install any tools you need
apt-get update && apt-get install -y python3 python3-pip

# Create test scripts
mkdir -p /app
cd /app
Create a simple test script:
cat > /app/test-scenario.sh << 'EOF'
#!/bin/bash
SCENARIO=$1
echo "Running test scenario: $SCENARIO"
echo "Timestamp: $(date)"
echo "Hostname: $(hostname)"
# Simulate test work
sleep 2
echo "Test $SCENARIO completed successfully"
EOF
chmod +x /app/test-scenario.sh

Verify the Setup

/app/test-scenario.sh demo
You should see output confirming the script runs correctly.

Step 3: The Critical Branch Point

This is where Vers shines. Instead of repeating all this setup for each test scenario, we’ll branch the VM state.
# Exit the VM first
exit

Create Your First Branch

vers branch --alias scenario-a
This creates a new VM from the current state of your root VM. Both VMs are now running simultaneously.

Create Additional Branches

vers branch --alias scenario-b
vers branch --alias scenario-c
You now have four VMs (root + 3 branches), all with identical setup, ready for different test scenarios.

Step 4: Run Parallel Tests

View Your VMs

vers status
You’ll see output like:
HEAD status: root (State: Running)

Fetching list of VMs...
Available VMs:

VM: root
State: Running

VM: scenario-a
State: Running

VM: scenario-b
State: Running

VM: scenario-c
State: Running
This shows:
  • Root VM: Running parent with the base state
  • Scenario A/B/C VMs: Running children for different tests
All VMs are running simultaneously - when you branch, the parent is briefly paused to create a consistent snapshot, then automatically resumes.

Execute Tests Non-Interactively

# Run test on scenario-a
vers checkout scenario-a
vers execute "/app/test-scenario.sh A"

# Run test on scenario-b
vers checkout scenario-b
vers execute "/app/test-scenario.sh B"

# Run test on scenario-c
vers checkout scenario-c
vers execute "/app/test-scenario.sh C"

Parallel Testing Workflow

For true parallelism, open multiple terminals: Terminal 1:
cd parallel-testing
vers checkout scenario-a
vers connect
# Run interactive tests
/app/test-scenario.sh "interactive-A"
Terminal 2:
cd parallel-testing
vers checkout scenario-b
vers connect
# Run different tests simultaneously
/app/test-scenario.sh "interactive-B"
Terminal 3:
cd parallel-testing
vers checkout scenario-c
vers connect
# Run yet another test path
/app/test-scenario.sh "interactive-C"
All three test scenarios run simultaneously in completely isolated environments.

Step 5: The Time Savings

Traditional Approach (Without Vers)

Test Scenario A:
├── Environment setup: 5 minutes
├── Install dependencies: 3 minutes
├── Run test A: 2 minutes
└── Total: 10 minutes

Test Scenario B:
├── Environment setup: 5 minutes (repeated!)
├── Install dependencies: 3 minutes (repeated!)
├── Run test B: 2 minutes
└── Total: 10 minutes

Test Scenario C:
├── Environment setup: 5 minutes (repeated!)
├── Install dependencies: 3 minutes (repeated!)
├── Run test C: 2 minutes
└── Total: 10 minutes

Grand Total: 30 minutes (sequential)

Vers Approach

Initial Setup (once):
├── Environment setup: 5 minutes
├── Install dependencies: 3 minutes
└── Create branches: 30 seconds

Parallel Testing:
├── Test A: 2 minutes ─┐
├── Test B: 2 minutes ─┼── Run simultaneously
├── Test C: 2 minutes ─┘

Grand Total: ~10 minutes
Time Saved: ~20 minutes (67% reduction)
As test scenarios increase, the time savings compound dramatically.

Step 6: Cleanup

Delete Branches

vers checkout root
vers kill scenario-a
vers kill scenario-b
vers kill scenario-c

Or Delete Everything

vers kill root -r  # Recursive delete includes all children

Advanced Patterns

Checkpoint and Branch

Create checkpoints at different stages of your workflow:
# After initial setup
vers branch --alias checkpoint-setup

# After data seeding
vers connect
# ... seed test data ...
exit
vers branch --alias checkpoint-seeded

# Branch from seeded state for data-dependent tests
vers branch checkpoint-seeded --alias test-data-1
vers branch checkpoint-seeded --alias test-data-2

Nested Branching

Create branches of branches for complex test trees:
vers branch --alias feature-x
vers checkout feature-x
vers connect
# ... configure feature X ...
exit
vers branch --alias feature-x-variant-1
vers branch --alias feature-x-variant-2

Key Takeaways

  1. Branch Instead of Rebuild: Use vers branch to capture state at decision points
  2. Parallel Execution: Run tests simultaneously across multiple terminals
  3. State Inheritance: Branches inherit the exact memory and filesystem state
  4. Time Efficiency: Setup once, test many scenarios

Next Steps