Skip to content
Multipass orchestrates virtual Ubuntu instances
C++ CMake Python Other
Branch: master
Clone or download

Latest commit

bors and ricab Merge #1467
1467: Mockable standard paths r=townsend2010 a=ricab

Adds a mockable `StandardPaths` singleton, as a thin wrapper around `QStandardPaths`. Implements the corresponding mock with the same approach as `MockSettings`, that is, via:
1. a test environment, to run custom code during test setup and tear down
2. a test event listener, to verify and clear mock expectations on the singleton at the end of each test
3. default operations delegating on the parent

To achieve that, this PR also extracts common stuff into a `MockSingletonHelper`.

This approach enforces accounting of mock expectations in the respective test. It also avoids singleton state leaking from test to test and affecting the results based on execution order. Finally, it ensures that tests only deal with the mock. They use only parent operations that are deemed safe for testing, indirectly, via the mock itself.

Co-authored-by: Ricardo Abreu <ricab@ricabhome.org>
1
Latest commit 8e085b5 Apr 7, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE [github] introduce issue templates Mar 11, 2020
3rd-party Merge #1392 Feb 28, 2020
completions/bash [bash] Autocomplete get/set commands Jun 3, 2019
data [data] move icon extension to the sed line Oct 2, 2019
debian Merge #1225 Dec 17, 2019
include/multipass [test] Forward QStandardPaths' enum values too Apr 2, 2020
snap-wrappers/bin [snap] Add client wrappers to place autostart link Sep 5, 2019
snap [snap] default to MULTIPASS_UPSTREAM="origin" Mar 4, 2020
src Merge #1467 Apr 7, 2020
tests Merge #1467 Apr 7, 2020
tools [tools] fix GetCommitComments query Mar 10, 2020
.clang-format Import tree Dec 6, 2017
.gitignore Have git ignore snapcraft build artifacts Mar 11, 2019
.gitmodules Merge #1392 Feb 28, 2020
.travis.yml [travis] skip RelWithDebInfo, too if we're not secure Mar 30, 2020
CMakeLists.txt Merge #1377 Feb 21, 2020
COPYING.GPL.txt Import tree Dec 6, 2017
README.md Tweak the `sudo` note on macOS Jan 7, 2020
bors.toml [bors] add `cut_body_after` config Aug 12, 2019

README.md

What is Multipass?

Multipass is a lightweight VM manager for Linux, Windows and macOS. It's designed for developers who want a fresh Ubuntu environment with a single command. It uses KVM on Linux, Hyper-V on Windows and HyperKit on macOS to run the VM with minimal overhead. It can also use VirtualBox on Windows and macOS. Multipass will fetch images for you and keep them up to date.

Since it supports metadata for cloud-init, you can simulate a small cloud deployment on your laptop or workstation.

Install Multipass

On Linux it's available as a snap:

sudo snap install multipass --classic

For macOS, you can download the installers from GitHub or use Homebrew:

# Note, this may require you to enter your password for some sudo operations during install
brew cask install multipass

On Windows, download the installer from GitHub.

Usage

Find available images

$ multipass find
Image                   Aliases           Version          Description
core                    core16            20190424         Ubuntu Core 16
core18                                    20190213         Ubuntu Core 18
16.04                   xenial            20190628         Ubuntu 16.04 LTS
18.04                   bionic,lts        20190627.1       Ubuntu 18.04 LTS
18.10                   cosmic            20190628         Ubuntu 18.10
19.04                   disco             20190628         Ubuntu 19.04
daily:19.10             devel,eoan        20190623         Ubuntu 19.10

Launch a fresh instance of the current Ubuntu LTS

$ multipass launch ubuntu
Launching dancing-chipmunk...
Downloading Ubuntu 18.04 LTS..........
Launched: dancing chipmunk

Check out the running instances

$ multipass list
Name                    State             IPv4             Release
dancing-chipmunk        RUNNING           10.125.174.247   Ubuntu 18.04 LTS
live-naiad              RUNNING           10.125.174.243   Ubuntu 18.04 LTS
snapcraft-asciinema     STOPPED           --               Ubuntu Snapcraft builder for Core 18

Learn more about the VM instance you just launched

$ multipass info dancing-chipmunk
Name:           dancing-chipmunk
State:          RUNNING
IPv4:           10.125.174.247
Release:        Ubuntu 18.04.1 LTS
Image hash:     19e9853d8267 (Ubuntu 18.04 LTS)
Load:           0.97 0.30 0.10
Disk usage:     1.1G out of 4.7G
Memory usage:   85.1M out of 985.4M

Connect to a running instance

$ multipass shell dancing-chipmunk
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-42-generic x86_64)

...

Don't forget to logout (or Ctrl-D) or you may find yourself heading all the way down the Inception levels... ;)

Run commands inside an instance from outside

$ multipass exec dancing-chipmunk -- lsb_release -a
No LSB modules are available.
Distributor ID:  Ubuntu
Description:     Ubuntu 18.04.1 LTS
Release:         18.04
Codename:        bionic

Stop an instance to save resources

$ multipass stop dancing-chipmunk

Delete the instance

$ multipass delete dancing-chipmunk

It will now show up as deleted:

Name                    State             IPv4             Release
snapcraft-asciinema     STOPPED           --               Ubuntu Snapcraft builder for Core 18
dancing-chipmunk        DELETED           --               Not Available

And when you want to completely get rid of it:

$ multipass purge

Get help


multipass help
multipass help <command>

Get involved!

Here's a set of steps to build and run your own build of Multipass:

Build Dependencies

cd <multipass>
apt install devscripts equivs
mk-build-deps -s sudo -i

Building

cd <multipass>
git submodule update --init --recursive
mkdir build
cd build
cmake ../
make

Running Multipass daemon and client

First, install multipass's runtime dependencies. On amd64 architecture, you can achieve that with:

sudo apt update
sudo apt install libgl1 libpng16-16 libqt5core5a libqt5gui5 \
    libqt5network5 libqt5widgets5 libxml2 libvirt0 dnsmasq-base \
    dnsmasq-utils qemu-system-x86 qemu-utils libslang2 iproute2 \
    iptables iputils-ping libatm1 libxtables12 xterm

Then run multipass's daemon:

sudo <multipass>/build/bin/multipassd &

Copy the desktop file multipass clients expect to find in your home:

mkdir -p ~/.local/share/multipass/
cp <multipass>/data/multipass.gui.autostart.desktop ~/.local/share/multipass/

Optionally, enable auto-complete in bash:

source <multipass>/completions/bash/multipass

Finally, use multipass's clients:

<multipass>/build/bin/multipass launch --name foo  # CLI client
<multipass>/build/bin/multipass.gui                # GUI client

More information

See the Multipass documentation.

You can’t perform that action at this time.