Skip to content

Commit 5dd5f8a

Browse files
Merge branch 'test-manager-fixes-misc'
2 parents fce09af + c29f619 commit 5dd5f8a

24 files changed

+703
-403
lines changed

.github/workflows/desktop-e2e.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
shell: bash -ieo pipefail {0}
152152
run: |
153153
git fetch --tags --force
154-
./test/ci-runtests.sh ${{ matrix.os }}
154+
./test/scripts/ci-runtests.sh ${{ matrix.os }}
155155
- uses: actions/upload-artifact@v3
156156
if: '!cancelled()'
157157
with:
@@ -226,7 +226,7 @@ jobs:
226226
shell: bash -ieo pipefail {0}
227227
run: |
228228
git fetch --tags --force
229-
./test/ci-runtests.sh ${{ matrix.os }}
229+
./test/scripts/ci-runtests.sh ${{ matrix.os }}
230230
- uses: actions/upload-artifact@v3
231231
if: '!cancelled()'
232232
with:
@@ -297,7 +297,7 @@ jobs:
297297
shell: bash -ieo pipefail {0}
298298
run: |
299299
git fetch --tags --force
300-
./test/ci-runtests.sh ${{ matrix.os }}
300+
./test/scripts/ci-runtests.sh ${{ matrix.os }}
301301
- uses: actions/upload-artifact@v3
302302
if: '!cancelled()'
303303
with:

test/README.md

+74-56
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
1-
# Project structure
1+
# Mullvad VPN end to end test framework
22

3-
## test-manager
3+
## Project structure
4+
5+
### test-manager
46

57
The client part of the testing environment. This program runs on the host and connects over a
68
virtual serial port to the `test-runner`.
79

810
The tests themselves are defined in this package, using the interface provided by `test-runner`.
911

10-
## test-runner
12+
### test-runner
1113

1214
The server part of the testing environment. This program runs in guest VMs and provides the
1315
`test-manager` with the building blocks (RPCs) needed to create tests.
1416

15-
## test-rpc
17+
### test-rpc
1618

1719
A support library for the other two packages. Defines an RPC interface, transports, shared types,
1820
etc.
1921

20-
# Prerequisities
22+
23+
## Prerequisites
2124

2225
For macOS, the host machine must be macOS. All other platforms assume that the host is Linux.
2326

24-
## All platforms
27+
### All platforms
2528

2629
* Get the latest stable Rust from https://rustup.rs/.
2730

28-
## macOS
31+
### macOS
2932

3033
Normally, you would use Tart here. It can be installed with Homebrew. You'll also need
3134
`wireguard-tools`, a protobuf compiler, and OpenSSL:
@@ -34,7 +37,7 @@ Normally, you would use Tart here. It can be installed with Homebrew. You'll als
3437
brew install cirruslabs/cli/tart wireguard-tools pkg-config openssl protobuf
3538
```
3639

37-
### Wireshark
40+
#### Wireshark
3841

3942
Wireshark is also required. More specifically, you'll need `wireshark-chmodbpf`, which can be found
4043
in the Wireshark installer here: https://www.wireshark.org/download.html
@@ -47,7 +50,7 @@ dseditgroup -o edit -a THISUSER -t user access_bpf
4750

4851
This lets us monitor traffic on network interfaces without root access.
4952

50-
## Linux
53+
### Linux
5154

5255
For running tests on Linux and Windows guests, you will need these tools and libraries:
5356

@@ -58,94 +61,109 @@ dnf install git gcc protobuf-devel libpcap-devel qemu \
5861
wireguard-tools
5962
```
6063

61-
# Building the test runner
64+
## Setting up testing environment
65+
66+
First you need to build the images for running tests on, see [`BUILD_OS_IMAGE.md`](./docs/BUILD_OS_IMAGE.md). The `test-manager` then needs to be configured to use the image.
67+
68+
Here is an example of how to create a new OS configuration for Linux and macOS:
69+
70+
### Linux
71+
72+
```bash
73+
# Create or edit configuration
74+
# The image is assumed to contain a test runner service set up as described in ./docs/BUILD_OS_IMAGE.md
75+
cargo run --bin test-manager set debian11 qemu ./os-images/debian11.qcow2 linux \
76+
--package-type deb --architecture x64 \
77+
--provisioner ssh --ssh-user test --ssh-password test
78+
79+
# Try it out to see if it works - you should reach the VM's graphical desktop environment
80+
cargo run --bin test-manager run-vm debian11
81+
```
82+
83+
### macOS
84+
85+
86+
```bash
87+
# Download some VM image
88+
tart clone ghcr.io/cirruslabs/macos-ventura-base:latest ventura-base
89+
90+
# Create or edit configuration
91+
# Use SSH to deploy the test runner since the image doesn't contain a runner
92+
cargo run --bin test-manager set macos-ventura tart ventura-base macos \
93+
--architecture aarch64 \
94+
--provisioner ssh --ssh-user admin --ssh-password admin
95+
96+
# Try it out to see if it works
97+
cargo run -p test-manager run-vm macos-ventura
98+
```
99+
100+
## Testing the app
101+
102+
To automatically download and test a pre-built version of the app, use the `test-by-version.sh` script, see `test-by-version.sh --help` for instructions.
103+
104+
To manually invoke `test-manager`, start by checking out the desired git version of this repo. Next, [build the app](../BuildInstructions.md) for the target platform then build the GUI test binary using `$(cd ../gui && npm run build-test-executable)`. The newly built packages will be located in the `../dist` folder by default.
105+
106+
Next: build the `test-runner`
107+
108+
### Building the test runner
62109

63110
Building the `test-runner` binary is done with the `build-runner.sh` script.
64111
Currently, only `x86_64` platforms are supported for Windows/Linux and `ARM64` (Apple Silicon) for macOS.
65112

66113
For example, building `test-runner` for Windows would look like this:
67114

68115
``` bash
69-
./container-run.sh ./build-runner.sh windows
116+
./scripts/container-run.sh ./scripts/build-runner.sh windows
70117
```
71118

72-
## Linux
73-
Using `podman` is the recommended way to build the `test-runner`. See the [Linux section under Prerequisities](#Prerequisities) for more details.
119+
#### Linux
120+
Using `podman` is the recommended way to build the `test-runner`. See the [Linux section under Prerequisities](#prerequisites) for more details.
74121

75122
``` bash
76-
./container-run.sh ./build-runner.sh linux
123+
./scripts/container-run.sh ./scripts/build-runner.sh linux
77124
```
78125

79-
## macOS
126+
#### macOS
80127

81128
``` bash
82-
./build-runner.sh macos
129+
./scripts/build-runner.sh macos
83130
```
84131

85-
## Windows
132+
#### Windows
86133
The `test-runner` binary for Windows may be cross-compiled from a Linux host.
87134

88135
``` bash
89-
./container-run.sh ./build-runner.sh windows
136+
./scripts/container-run.sh ./scripts/build-runner.sh windows
90137
```
91138

92-
# Building base images
93-
94-
See [`BUILD_OS_IMAGE.md`](./docs/BUILD_OS_IMAGE.md) for how to build images for running tests on.
95-
96-
# Running tests
139+
### Running the tests
97140

98-
See `cargo run --bin test-manager` for details.
141+
After configuring the VM image using `test-manager set` and building the required packages (see [previous step](#setting-up-testing-environment)), `test-manager run-tests` is used to launch the tests. See `cargo run --bin test-manager -- run-tests --help` for details.
99142

100-
## Linux
143+
Here is an example of how to run all tests using the Linux/macOS VM we set up earlier:
101144

102-
Here is an example of how to create a new OS configuration and then run all tests:
145+
#### Linux
103146

104147
```bash
105-
# Create or edit configuration
106-
# The image is assumed to contain a test runner service set up as described in ./docs/BUILD_OS_IMAGE.md
107-
cargo run --bin test-manager set debian11 qemu ./os-images/debian11.qcow2 linux \
108-
--package-type deb --architecture x64 \
109-
--provisioner ssh --ssh-user test --ssh-password test
110-
111-
# Try it out to see if it works - you should reach the VM's graphical desktop environment
112-
cargo run --bin test-manager run-vm debian11
113-
114148
# Run all tests
115-
cargo run --bin test-manager run-tests debian11 \
149+
cargo run --bin test-manager run-tests --vm debian11 \
116150
--display \
117151
--account 0123456789 \
118152
--app-package <git hash or tag> \
119153
--app-package-to-upgrade-from 2023.2
120154
```
121155

122-
## macOS
123-
124-
Here is an example of how to create a new OS configuration (on Apple Silicon) and then run all
125-
tests:
156+
#### macOS
126157

127158
```bash
128-
# Download some VM image
129-
tart clone ghcr.io/cirruslabs/macos-ventura-base:latest ventura-base
130-
131-
# Create or edit configuration
132-
# Use SSH to deploy the test runner since the image doesn't contain a runner
133-
cargo run --bin test-manager set macos-ventura tart ventura-base macos \
134-
--architecture aarch64 \
135-
--provisioner ssh --ssh-user admin --ssh-password admin
136-
137-
# Try it out to see if it works
138-
#cargo run -p test-manager run-vm macos-ventura
139-
140159
# Run all tests
141-
cargo run --bin test-manager run-tests macos-ventura \
160+
cargo run --bin test-manager run-tests --vm macos-ventura \
142161
--display \
143162
--account 0123456789 \
144163
--app-package <git hash or tag> \
145164
--app-package-to-upgrade-from 2023.2
146165
```
147166

148-
## Note on `ci-runtests.sh`
167+
## Note on `scripts/ci-runtests.sh`
149168

150-
Account tokens are read (newline-delimited) from the path specified by the environment variable
151-
`ACCOUNT_TOKENS`. Round robin is used to select an account for each VM.
169+
`scripts/ci-runtests.sh` is the script that GitHub actions uses to invokes the `test-manager`, with similar functionality as `test-by-version.sh`. Note that account tokens are read (newline-delimited) from the path specified by the environment variable `ACCOUNT_TOKENS`. Round robin is used to select an account for each VM.

0 commit comments

Comments
 (0)