Skip to main content

Library for testing network virtual appliances using Docker

Project description

Alpy

Test network virtual appliance using Docker containers

This project is a Python library for testing network virtual appliances.

The appliance being tested is referred to as a device under test or DUT.

This repository includes scripts and modules to build a simple appliance called Rabbit. Rabbit is Alpine Linux with a few packages pre-installed. Having this simple DUT allows to quickly test the alpy library and to demonstrate its features.

The tests for the Rabbit device share a lot of code so the code is organized as a library. The library is called carrot.

Author

Alexey Bogdanenko

License

Alpy is licensed under:

SPDX-License-Identifier: GPL-3.0-or-later

See COPYING for more details.

Network design

The DUT communicates with containers attached to each of its network links.

Guest network adapters are connected to the host via tap devices (Figure 1).

+-----QEMU hypervisor------+
|                          |   +-------------+
| +-----Guest OS-----+     |   |             |
| |                  |     |   |  docker     |
| | +--------------+ |     |   |  container  |
| | |              | |     |   |  network    |
| | |  NIC driver  | |     |   |  namespace  |
| | |              | |     |   |             |
| +------------------+     |   |   +-----+   |
|   |              |       |   |   |     |   |
|   | NIC hardware +---+-----------+ tap |   |
|   |              |   |   |   |   |     |   |
|   +--------------+   |   |   |   +-----+   |
|                      |   |   |             |
+--------------------------+   +-------------+
                       |
                       |
                       v
                 +-----------+
                 |           |
                 | pcap file |
                 |           |
                 +-----------+

Figure 1. Network link between QEMU guest and a docker container.

Each tap device lives in its network namespace. This namespace belongs to a dedicated container - a node. The node's purpose is to keep the namespace alive during the lifetime of a test.

For an application to be able to communicate with the DUT the application is containerized. The application container must be created in a special way: it must share network namespace with one of the nodes.

Figure 2 shows an example where application containers app0 and app1 share network namespace with node container node0. Application container app2 shares another network namespace with node2.

This sharing is supported by Docker. All we have to do is to create the application container with the --network=container:NODE_NAME Docker option. For example, if we want to send traffic to the DUT via its first link, we create a traffic generator container with Docker option --network=container:node0.

+----QEMU---+   +------shared network namespace-----+
|           |   |                                   |
|           |   |    eth0                           |
|   +---+   |   |   +---+   +-----+ +----+ +----+   |
|   |NIC+-----------+tap|   |node0| |app0| |app1|   |
|   +---+   |   |   +---+   +-----+ +----+ +----+   |
|           |   |                                   |
|           |   +-----------------------------------+
|           |
|           |
|           |
|           |   +------shared network namespace-----+
|           |   |                                   |
|           |   |    eth0                           |
|   +---+   |   |   +---+   +-----+                 |
|   |NIC+-----------+tap|   |node1|                 |
|   +---+   |   |   +---+   +-----+                 |
|           |   |                                   |
|           |   +-----------------------------------+
|           |
|           |
|           |
|           |   +------shared network namespace-----+
|           |   |                                   |
|           |   |    eth0                           |
|   +---+   |   |   +---+   +-----+ +----+          |
|   |NIC+-----------+tap|   |node2| |app2|          |
|   +---+   |   |   +---+   +-----+ +----+          |
|           |   |                                   |
+-----------+   +-----------------------------------+

Figure 2. Application containers attached to the DUT links.

A note about GitLab Container Registry

Many CI jobs use one of the custom images built on the "build-docker-images" stage. The images are stored in the GitLab Container Registry.

The images are pulled from locations specified by GitLab variables. By default, the variables point to the registry of the current GitLab project.

If you forked this project and GitLab Container Registry is disabled in your project, override the variables on a project level so that the images are pulled from some other registry.

For example, set

IMAGE_PYTHON_CODE_QUALITY=registry.gitlab.com/abogdanenko/alpy/python-code-quality

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

alpy-0.16.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

alpy-0.16.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file alpy-0.16.0.tar.gz.

File metadata

  • Download URL: alpy-0.16.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for alpy-0.16.0.tar.gz
Algorithm Hash digest
SHA256 6e987ce6c0351a16a0e30c83119029c1081a34899354eea784fecf966b2b2022
MD5 dda9050dabfa26943322e21e9fce0612
BLAKE2b-256 cf0eaeb4d26c560878c4a7c1930e6148c36bf6c9ae1773f39d96afcf55a12ba2

See more details on using hashes here.

File details

Details for the file alpy-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: alpy-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for alpy-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3388ea386ee7992f720d7346a6794315f4a835a3c32a084eadd995f16ec5198
MD5 9a830d97856e8c06edc7de4252bb3653
BLAKE2b-256 62ca34a2713c6d1bd3b462e1b83a18bdc9eb2a91a28f921b254c5b445fcad723

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