functional_tests: Allow provisioning VM for functional tests

It's now possible to run the tests in the VM more easily
without copy-pasting too much from HACKING.md.
`vagrant provision --provisiion-with tests` will take care of the dependencies.

freedombox/plinth#1521 - Provision VM to run function functional tests

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
LoveIsGrief 2019-03-22 15:48:09 +01:00 committed by James Valleroy
parent 5c2a8c0b40
commit d31b0ee3c7
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
3 changed files with 43 additions and 1 deletions

View File

@ -169,6 +169,9 @@ executed (red).
### Install Dependencies ### Install Dependencies
**For running tests in the VM** run `vagrant provision --provision-with tests`.
Otherwise follow the instructions below.
``` ```
$ pip3 install splinter $ pip3 install splinter
$ pip3 install pytest-splinter $ pip3 install pytest-splinter
@ -209,7 +212,13 @@ tests will create the required user using FreedomBox's first boot process.
### Run Functional Tests ### Run Functional Tests
Run **When inside a VM you will need to target the guest VM**
```bash
export FREEDOMBOX_URL=https://localhost
```
You will be running `py.test-3`.
``` ```
$ py.test-3 --include-functional $ py.test-3 --include-functional

1
Vagrantfile vendored
View File

@ -44,6 +44,7 @@ Vagrant.configure(2) do |config|
# Install ncurses-term # Install ncurses-term
DEBIAN_FRONTEND=noninteractive apt-get install -y ncurses-term DEBIAN_FRONTEND=noninteractive apt-get install -y ncurses-term
SHELL SHELL
config.vm.provision "tests", run: "never", type: "shell", path: "functional_tests/install.sh"
config.vm.post_up_message = "FreedomBox virtual machine is ready config.vm.post_up_message = "FreedomBox virtual machine is ready
for development. You can run the development version of Plinth using for development. You can run the development version of Plinth using
the following command. the following command.

32
functional_tests/install.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
echo "Installing requirements"
sudo apt-get install -yq --no-install-recommends \
python3-pytest \
python3-pip firefox \
xvfb
pip3 install splinter pytest-splinter pytest-bdd pytest-xvfb
echo "Installing geckodriver"
(
DL_DIR=/tmp/gecko
GECKO_VERSION="v0.24.0"
FILENAME="geckodriver-${GECKO_VERSION}-linux64.tar.gz"
GECKO_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKO_VERSION/$FILENAME"
test -e /usr/local/bin/geckodriver && echo "geckodriver already installed" && exit 0
mkdir -p $DL_DIR
cd $DL_DIR
if ! [[ -e $FILENAME ]] ; then
wget --no-clobber \
--continue \
--no-verbose \
"$GECKO_URL"
fi
tar xf $FILENAME
sudo mv geckodriver /usr/local/bin/geckodriver
echo "Done"
)