summaryrefslogtreecommitdiffhomepage
path: root/test/test-by-version.sh
blob: 3b97d45461ff0f5859c388023264e2a041e03f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash

set -eu

usage() {
    echo "This script downloads and tests the given app version from the build repositories."
    echo
    echo "Required environment variables:"
    echo "  - ACCOUNT_TOKEN: Valid MullvadVPN account number"
    echo "  - TEST_OS: Name of the VM configuration to use. List available configurations with 'cargo run --bin test-manager config vm list'"
    echo "Optional environment variables:"
    echo "  - APP_VERSION: The version of the app to test (defaults to the latest stable release)"
    echo "  - APP_PACKAGE_TO_UPGRADE_FROM: The package version to upgrade from (defaults to none)"
    echo "  - OPENVPN_CERTIFICATE: Path to an OpenVPN CA certificate the app should use during test (defaults to assets/openvpn.ca.crt)"
    echo "  - MULLVAD_HOST: Conncheck and API environment to use, eg stagemole.eu (defaults to mullvad.net, or the config file if set)"
    echo "  - TEST_DIST_DIR: Relative path to a directory with prebuilt binaries as produced by scripts/build.sh."
    echo "  - TEST_FILTERS: specifies which tests to run (defaults to all)"
    echo "  - TEST_REPORT : path to save the test results in a structured format"
}

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

# shellcheck source=test/scripts/utils/lib.sh
source "scripts/utils/lib.sh"

if [[ ("$*" == "--help") || "$*" == "-h" ]]; then
    usage
    exit 0
fi

if [[ -z "${ACCOUNT_TOKEN+x}" ]]; then
    echo "'ACCOUNT_TOKEN' must be specified" 1>&2
    echo
    usage
    exit 1
fi

if [[ -z "${TEST_OS+x}" ]]; then
    echo "'TEST_OS' must be specified" 1>&2
    echo
    usage
    exit 1
fi

if [[ -z "${APP_VERSION+x}" ]]; then
    echo "'APP_VERSION' not set, using latest build from the list of GitHub releases:"
    print_available_releases
    echo "For a full list of available releases you can choose from, see the stable build repository: $BUILD_RELEASE_REPOSITORY"
    echo "and the dev build repository: $BUILD_DEV_REPOSITORY"
    APP_VERSION=$LATEST_STABLE_RELEASE
fi

echo "**********************************"
echo "* Version to test: $APP_VERSION"
echo "**********************************"

echo "**********************************"
echo "* Downloading app packages"
echo "**********************************"

download_app_package "$APP_VERSION" "$TEST_OS"
download_e2e_executable "$APP_VERSION" "$TEST_OS"

if [[ -n "${APP_PACKAGE_TO_UPGRADE_FROM+x}" ]]; then
    download_app_package "$APP_PACKAGE_TO_UPGRADE_FROM" "$TEST_OS"
fi

set -o pipefail
APP_PACKAGE=$(get_app_filename "$APP_VERSION" "$TEST_OS")
export APP_PACKAGE
run_tests_for_os "${TEST_OS}"