Skip to main content

Test Fabric scripts on VirtualBox VMs

Project description

Fabtest is a set of utilities and base TestCases that aid testing Fabric scripts against VirtualBox VMs. License is MIT.

VM is rolled back to initial state before each test so tests can do anything with target system; Fabric commands can be run from Python.

Installation

pip install fabtest

VMs

In order to run tests you’ll need VirtualBox 4.x and an OS image. Image should have ssh server installed.

Example VMs (they can be imported to VirtualBox via File->Import Appliance):

Due to bugs in VirtualBox it is better to convert imported .vmdk disk images to .vdi images, e.g.:

VBoxManage clonehd Ubuntu-10.10-disk1.vmdk Ubuntu-10.10-disk.vdi --format VDI

Then detach (and remove) vmdk disk from the VM and attach the vdi image.

After you get the image, make sure it is not running and execute the fabtest-preparevm script (pass your VM name or uid to it):

fabtest-preparevm Lenny

This command configures port forwarding (127.0.0.1:2222 to guest 22 port, 127.0.0.1:8888 to guest 80 port) and takes ‘fabtest-initial’ snapshot used for test rollbacks (it is taken from booted machine in order to speedup tests).

Writing tests

Subclass fabtest.VirtualBoxTest or fabtest.FabTest and use fabtest.fab for fabric commands execution:

from fabric.api import run
from fabtest import FabTest, fab

def whoami():
    return run('whoami')

class MyTestCase(FabTest):
    def test_root_login(self):
        output = fab(whoami)
        self.assertEqual(output, 'root')

Look at source code (and example/runtests.py) for more.

CHANGES

0.1.1 (2012-03-02)

  • Better exception handling (the original traceback is preserved).

0.1 (2012-03-01)

  • Fabric >= 1.4 is supported (and required);

  • more reliable virtualbox snapshot handling;

  • fab function now wraps fabric’s execute and returns single value, not a list of values.

0.0.8 (2011-03-22)

  • Many tweaks & bug fixes.

0.0.1 (2011-02-16)

Initial experimental release (extracted from django-fab-deploy).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fabtest-0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

File details

Details for the file fabtest-0.1.1.tar.gz.

File metadata

  • Download URL: fabtest-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fabtest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1e0c4325639aa2ad54cca4087a0a530ae7395dc3fc6637a03388b7b96af83e44
MD5 23e093d3e3093c23e18e2c18ec24057a
BLAKE2b-256 e6d1642c66b8b4d5a739a7b0221966c8b4300a946ed7476317ba654b263bc81e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page