Git Product home page Git Product logo

django-box's Introduction

django-box: A virtual machine for running the Django core test suite

Forked from djangocore-box (https://github.com/jphalip/djangocore-box)

Django Version Support: 2.1

Release: https://app.vagrantup.com/djangoproject/boxes/django-box-2.1

The django-box is a virtual machine (VM), based on Ubuntu 16.04, containing all the programs and libraries required for running the Django core test suite in multiple different environments.

Every supported version of Python is pre-installed, along with all supported database backends, except for Oracle. Third party libraries like Memcached, Sphinx, and Pillow are also provided.

This is particularly useful to anybody interested in contributing to Django core without having to go through the trouble of installing and configuring all the software required to run the tests in all these environments.

Preparation

Software installation

First of all, you need to install the latest versions of Vagrant (at version 2.0.1 as of now) and VirtualBox (currently at version 5.2.4) on your host machine.

If you use Linux, you'll need to ensure proper support for NFS installed so the Vagrant shared folders feature works. On Debian/ubuntu systems this can be achieved with:

$ sudo apt-get install nfs-kernel-server

On Fedora/CentOS systems you'll need to execute something like:

$ sudo dnf install nfs-utils && sudo systemctl enable nfs-server

If you use a version of VirtualBox that isn't 5.2.4 you may run into problems creating the NFS mount. You can either

  • Upgrade to VirtualBox 5.2.4

  • Or you can try to install the vagrant-vbguest plugin, which will attempt to install your local version of GuestAdditions into the VM:

    vagrant plugin install vagrant-share
    vagrant plugin install vagrant-vbguest
    

Booting the VM

Legend: (host) is for commands to run on the host machine, and (vm) is for commands to run inside the VM.

Setup the initial directory layout:

(host) $ cd projects
(host) $ git clone [email protected]:django/django.git
(host) $ git clone [email protected]:django/django-box.git

It's important that django is cloned to a directory called django directly beside the django-box directory. This is because the virtual machine will mount ../django/.

Then, either:

  • If you have not already downloaded the box file separately, then run the following commands to boot the machine.

      (host) $ cd django-box
      (host) $ vagrant up
    

    This will automatically download the VM, which is about 1.2GB in size (be warned if you have a low bandwitdh Internet connection) and then boot it up. The download will only occur the first time you run vagrant up, as the image is saved.

  • Or, if you have already downloaded the box file separately, then run the following command in order to import the box into vagrant and boot up the VM:

      (host) $ vagrant box add path/to/django-box-2.1.box --name djangoproject/django-box-2.1
      (host) $ cd django-box
      (host) $ vagrant up
    

    vagrant box add will copy the box file to ~/.vagrant.d/boxes, so you may delete the file you've dowloaded if you'd like to save some space on your hard drive.

    You can download the box file directly from (make sure you update the version component): https://app.vagrantup.com/djangoproject/boxes/django-box-2.1/versions/1.0.0/providers/

    You can check what the latest released version is here: https://app.vagrantup.com/djangoproject/boxes/django-box-2.1/

As the VM boots up, it will prompt you to enter your host machine's administrator password (the same that you use for logging into your host machine). This is required so that Vagrant can setup the NFS shared folders.

Once the VM is up and running, type the following command to SSH into the VM (still from inside the django-box/ folder):

(host) $ vagrant ssh

Once inside the VM, you can run the tests by typing any of the pre-defined aliases. For example:

(vm) $ runtests36-mysql
(vm) $ runtests35-spatialite gis_tests
(vm) $ runtests35-postgres admin_widgets --selenium chrome

Supported commands

runtests-isort    runtests35-sqlite3        runtests36-sqlite3
runtests-flake8   runtests35-spatialite     runtests36-spatialite
runtests-docs     runtests35-mysql          runtests36-mysql
                  runtests35-mysql_gis      runtests36-mysql_gis
                  runtests35-postgres       runtests36-postgres
                  runtests35-postgis        runtests36-postgis

Some of these names have changed in version 2.1 of django-box. Now they mirror the naming convention used in our Jenkins CI setup. i.e. runtests3x-sqlite3-gis is now runtests3x-spatialite, runtest3x-postgres-gis is now runtests3x-postgis and runtest3x-mysql-gis is now runtests3x-mysql_gis.

Examples

The commands above that target databases all accept arguments and flags consistent with the unit-tests documentation: https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/unit-tests/ What this means is that you can still run these tests with --keepdb to improve testing performance, and target specific test modules.

# Run test modules related to expressions
runtests35-postgres --keepdb -v 2 queries expressions lookup aggregation annotations

# Run GIS tests
runtests35-postgis gis_tests

# Run selenium tests against chrome driver (no firefox available yet)
runtests36-sqlite3 admin_widgets --selenium chrome --parallel 1

Notes about the VM configuration

Inside the VM, the /django folder is shared with the host and points to the git clone that was created in the steps above. This way you can edit Django's code using your favorite editor from your host machine and run the tests from inside the VM. The repository clone for the django-box itself is also in a shared folder at /vagrant.

The test settings are available in /home/vagrant/djangodata/test_*.py. These files are put onto the PYTHONPATH when running the tests.

Chrome is pre-installed so that Django's selenium tests can be run in headless mode with a virtual display (id :99). For example, you may run a specific test like so:

(vm) $ runtests36-sqlite3 admin_widgets --selenium chrome --parallel 1

The test suite will sometimes hang when running selenium tests in parallel mode.

Troubleshooting

Strange errors when running tests

The tox.ini configuration file shipped with the Django source code directs tox to create the virtual environments it uses for every test matrix configuration below a .tox directory it creates on the Django source code top directory.

django-box reuses Django's tox configuration, but executes tox inside the VM, so that .tox/ tree gets persisted between test runs and shared between a tox copy you could use on the host and the django-box tox.

So it might happen than when faced with a mismatch between the version of Python used to create a virtual environment and the version currently in use to run the tests (e.g. Python micro version gets upgraded from 3.6.3 to 3.6.4 and this upgrade reaches your Linux host and/or the repositories used by the django-box VM), weird errors happen.

You can solve this by removing the virtualenv tree, e.g.:

(host) $ rm -rf <Django souce code top dir>/.tox/py36-mysql
(vm) $ rm -rf /django/.tox/py36-mysql

or more drastically, removing the .tox directory:

(host) $ rm -rf <Django souce code top dir>/.tox
(vm) $ rm -rf /django/.tox

This way the next time you run the tests, tox will rebuild the virtual environment anew with the correct version of Python.

Building the documentation

To build the documentation, change to the docs directory and call a make task:

(vm) $ cd /django/docs
(vm) $ make html

You can then view the docs in your browser on the host:

`(host) $ open django/docs/_build/html/index.html`

Vagrant command tips

  • To exit the VM and return to your host machine, simple type:

    (vm) $ exit

  • To shutdown the VM, type:

    (host) $ vagrant halt

  • To suspend the VM (i.e. freeze the VM's state), type:

    (host) $ vagrant suspend

  • Once shutdown or suspended, a VM can be restarted with:

    (host) $ vagrant up

  • To destroy the VM, simply type:

    (host) $ vagrant destroy

  • To check if the VM is currently running, type:

    (host) $ vagrant status

  • To re-run the provisioning after the VM has been started (if you have built the VM from scratch):

    (host) $ vagrant provision

  • More information is available in the Vagrant documentation.

Building a new version

To upgrade or alter the original box, you'll need to recreate it. You'll need to have Ansible 2.1 or greater installed, and django >= 2.1 in a folder beside the django-box project as described above. You should also have the vagrant-vbguest plugin installed to ensure the correct GuestAdditions are configured within the image.

Make any required changes to the Ansible roles, and then create the box with:

(host) $ VAGRANT_VAGRANTFILE=Vagrantfile-build vagrant up

The automatic build process will take about 20 minutes. If the new build should be saved, then you can package the output:

(host) $ VAGRANT_VAGRANTFILE=Vagrantfile-build vagrant package \
        --output django-box-2.1.box

(host) $ vagrant box add django-box-2.1.box --name djangoproject/django-box-2.1 # optional - for testing

Note that compiling a new version should only be required when releasing a new build to app.vagrantup.com.

To upload the new image, logon to the djangoproject account on vagrantup here: https://app.vagrantup.com/djangoproject.

  • Click through to the box you're updating
  • Create a new version, bumping the release version, and adding release notes
  • Create a new virtualbox provider for the new version
  • Upload the .box file generated from the packaging command above

Credits

django-box was originally authored by Julien Phalip and other contributors as djangocore-box.

django-box's People

Contributors

ashchristopher avatar grue avatar jarshwah avatar jdunck avatar jphalip avatar myszon avatar ramiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-box's Issues

root password

Hello,
i need to create a mysql database but I didn't put a root password (the install did not ask). now when i do mysql -u root -p where can i find this paswword.

Thanks

Figure out a better way of generating runtest aliases

As of 500668c the ansible provisioner will now rely on tox from /django to provide virtualenvironments and requirements files for each environment. In an effort to avoid repetition I've generated each alias using nested variables:

tox -c /django/tox.ini -e py{{ (10 * item.0)|round|int }}{{ ("-" + item.1)|replace("-sqlite3", "") }} --

The problem with this is that it's extremely brittle, particularly the replace() filter that removes -sqlite3 from the tox environment name if it exists. This is currently necessary because the py{2,3} environments are natively sqlite anyway. The tox file hasn't been designed with this vagrant image in mind.

I've tried to match up the database names with the aliases and settings module names with as little processing required. I don't think we can just reuse the sqlite name, because those settings already exist within the test/ directory. Perhaps the explicit PYTHONPATH will take precedence though?

Tests don't work on 1.9.x branch it's still officially supported

Hi !

Thanks to your help, I'm currently able to test my patches for django master.

However, I can't make the tests work properly for the 1.9.x branch (probably the same for older versions). I think while we're at providing a box to make testing easy, it should support not only the master branch, but all supported releases. I guess any work about bug fixing (where the fix has to be backported) has to be tested on all the supported versions as well, and any work on new features that the dev wants to roll out to his current projects has also to be tested on the current project's versions.

My naive approach was to checkout 1.9.x, and do runtests35-sqlite. Here are the problems:
`

First problem :

1.9.x has no tox.ini file.

Solution

This is easily solved by copying master's tox.ini file.

Second problem :

The runtestsXX-yyyy aliases use the --selenium=firefox argument which doesn't work with 1.9.x's tests (where --selenium must be used).

Solution

Activate the virtualenv manually (if it has been created by tox previously when we used the runtestsXX-yyyy alias) : source /django/.tox/py35/bin/activate
And run the tests manually : python /django/tests/runtests.py --selenium

Third problem

I get some failing tests (while there shouldn't be, as it's the release branch I was testing). With this command python /django/tests/runtests.py admin_inlines --selenium, the selenium tests still skip. I'm not really sure what's happening, but it seems it doesn't find the executables for chrome, firefox and IE. Verbose output gives

Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f9c9859b828>>
Traceback (most recent call last):
  File "/django/.tox/py35/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 173, in __del__
    self.stop()
  File "/django/.tox/py35/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 145, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
skipped 'Selenium webdriver "selenium.webdriver.firefox.webdriver.WebDriver" not installed or not operational: Message: \'geckodriver\' executable needs to be in PATH. \n'
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.ie.service.Service object at 0x7f9c9859b080>>
Traceback (most recent call last):
  File "/django/.tox/py35/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 173, in __del__
    self.stop()
  File "/django/.tox/py35/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 145, in stop
    if self.process is None:
AttributeError: 'Service' object has no attribute 'process'
skipped 'Selenium webdriver "selenium.webdriver.ie.webdriver.WebDriver" not installed or not operational: Message: \'IEDriverServer.exe\' executable needs to be in PATH. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver\n'

This one I didn't know how to fix.

Thanks !

Rename the runtest aliases to be consistent with the jenkins test runners

Current runtest aliases are inconsistent with jenkins CI configuration matrix.

Current:

runtests35-sqlite3     
runtests35-sqlite3-gis 
runtests35-mysql       
runtests35-mysql-gis   
runtests35-postgres    
runtests35-postgres-gis

Change to:

runtests35-sqlite3     
runtests35-spatialite 
runtests35-mysql       
runtests35-mysql_gis   
runtests35-postgres    
runtests35-postgis

From #26 (comment)

FileNotFoundError: [Errno 2] No such file or directory: '/django/tox.ini'

vagrant@djangobox:~$ runtests36-mysql
Traceback (most recent call last):
File "/usr/local/bin/tox", line 11, in
sys.exit(cmdline())
File "/usr/local/lib/python3.5/dist-packages/tox/session.py", line 38, in main
config = prepare(args)
File "/usr/local/lib/python3.5/dist-packages/tox/session.py", line 26, in prepare
config = parseconfig(args)
File "/usr/local/lib/python3.5/dist-packages/tox/config.py", line 229, in parseconfig
parseini(config, inipath)
File "/usr/local/lib/python3.5/dist-packages/tox/config.py", line 644, in init
self._cfg = py.iniconfig.IniConfig(config.toxinipath)
File "/usr/local/lib/python3.5/dist-packages/py/_iniconfig.py", line 50, in init
f = open(self.path)
FileNotFoundError: [Errno 2] No such file or directory: '/django/tox.ini'

dd error when building box

Using b7765b6 I hit the same problem as #12 and am trying to build a box using

VAGRANT_VAGRANTFILE=Vagrantfile-build vagrant up

Everything goes well all the way through ansible provisioning, but I then get:

PLAY RECAP *********************************************************************
default                    : ok=56   changed=51   unreachable=0    failed=0

==> default: Running provisioner: shell...
    default: Running: inline script
==> default: mesg: ttyname failed: Inappropriate ioctl for device
==> default: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: W
==> default: :
==> default: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list:1 and /etc/apt/sources.list.d/google-chrome.list:3
==> default: W
==> default: :
==> default: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list:1 and /etc/apt/sources.list.d/google-chrome.list:3
==> default: W
==> default: :
==> default: Target Translations (main/i18n/Translation-en_US) is configured multiple times in /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list:1 and /etc/apt/sources.list.d/google-chrome.list:3
==> default: W
==> default: :
==> default: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list:1 and /etc/apt/sources.list.d/google-chrome.list:3
==> default: W
==> default: :
==> default: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list.d/dl_google_com_linux_chrome_deb.list:1 and /etc/apt/sources.list.d/google-chrome.list:3
==> default: 35165107+0 records in
==> default: 35165107+0 records out
==> default: 36009069568 bytes (36 GB, 34 GiB) copied, 93.241 s, 386 MB/s
==> default: 404196+0 records in
==> default: 404196+0 records out
==> default: 413896704 bytes (414 MB, 395 MiB) copied, 1.48731 s, 278 MB/s
==> default: dd:
==> default: writing to '/dev/dm-1'
==> default: : No space left on device
==> default: 1048577+0 records in
==> default: 1048576+0 records out
==> default: 536870912 bytes (537 MB, 512 MiB) copied, 14.2287 s, 37.7 MB/s
==> default: Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
==> default: no label, UUID=393fe33a-8094-49f4-8f28-e69ff6ff9a93

This is using Vagrant 1.8.5 and VirtualBox 5.1.4 on OS X 10.11.6.

My django repo is checked out at 14879ac.

Consider using tox for all test runs

A tox.ini is now available in Django 1.11 (master), and includes environments for running flake, isort spelling and docs tasks. If we're already going to be using tox for these things, then it probably makes sense to use it for running the regular test suite.

  • add test_settings_files directory to PYTHONPATH
  • pass --selenium to the regular test env
  • bind existing aliases to the appropriate tox invocation including cd into /django

Will solve #2 #3 #4 #5

Add support for running javascript tests

The tox.ini provides a javascript environment, but the test environment relies on an old version of NPM: https://code.djangoproject.com/ticket/25803

This should probably be fixed upstream in some way. The grunt qunit test runner looks abandoned, so it might be necessary to look into something else. Once that is done, we can properly alias a command to run the javascript tests, just as we've done for docs/isort/flake8.

Install requirements from /django rather than preloading them

Rather than copying the content of all the requirements from /django/tests/requirements* locally, we can just refer directly to them via the nfs share. It has the added benefit of possibly being able to build new boxes by simply changing the version of django linked.

Add support for Oracle

This isn't high on my to-do list because it's not exactly easy, especially on debian based systems. There's also non-trivial licensing concerns with the various libraries needed from oracle that require click through license acceptance.

Can't run the tests (several errors) on Windows

Hi,

Following the README.md, I was able to setup the vagrant VM, but the test commands don't work.

I downloaded the box manually from https://www.djangoproject.com/m/vms/djangocore-box-1.1.box (I have an unstable and slow connection, and stupidly, atlas.hashicorp doesn't support resuming downloads). I run Windows 10 64 bits, Virtualbox 5.0.20.

Disclaimer : I never used vagrant boxes before, so maybe I missed an implicit step.

~$ runtests2.7-mysql

fails with

Please install test dependencies first:
$ pip install -r requirements/py2.txt

Then

~$ pip install -r /django/tests/requirements/py2.txt

fails with

Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 139, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 240, in run
    for req in parse_requirements(filename, finder=finder, options=options):
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1314, in parse_requirements
    for item in parse_requirements(req_url, finder, comes_from=filename, options=options):
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1356, in parse_requirements
    req = InstallRequirement.from_line(line, comes_from)
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 118, in from_line
    return cls(req, comes_from, url=url)
  File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 43, in __init__
    req = pkg_resources.Requirement.parse(req)
  File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2680, in parse
    reqs = list(parse_requirements(s))
  File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2605, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2573, in scan_list
    raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', "pylibmc; sys.platform != 'win32'", 'at', "; sys.platform != 'win32'")

Python3.3 tests have another problem :

~$ runtests3.3-mysql

fails with

Traceback (most recent call last):
  File "/django/tests/runtests.py", line 13, in <module>
    from django.apps import apps
  File "/django/django/apps/__init__.py", line 1, in <module>
    from .config import AppConfig
  File "/django/django/apps/config.py", line 6, in <module>
    from django.utils.module_loading import module_has_submodule
  File "/django/django/utils/module_loading.py", line 67, in <module>
    from importlib.util import find_spec as importlib_find
ImportError: cannot import name find_spec

Tests failing due to msguniq not being available

When running time runtests35-sqlite3 one test fails, and this is the output:

FAIL: test_makemessages_no_settings (i18n.test_extraction.NoSettingsExtractionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/usr/lib/python3.5/unittest/case.py", line 600, in run
    testMethod()
  File "/django/tests/i18n/test_extraction.py", line 723, in test_makemessages_no_settings
    self.assertNoOutput(err)
  File "/django/tests/admin_scripts/tests.py", line 203, in assertNoOutput
    self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
  File "/usr/lib/python3.5/unittest/case.py", line 820, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib/python3.5/unittest/case.py", line 813, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: 96 != 0 : Stream should be empty: actually contains 'CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.

As it reported gettext being missing I tried installing it, to no avail:

apt-cache policy get text
N: Unable to locate package get text

Adding the optional repo in /etc/apt/sources.list and doing an update fixes it:

sudo vi /etc/apt/sources.list
sudo apt-get update
sudo apt-get install gettext

Selenium tests fail

Selenium tests currently do not work.
Run with the command runtests27-sqlite3 admin_widgets --selenium chrome or directly from the django test directory with ./runtests.py admin_widgets --selenium chrome
they fail with one of these errors:

======================================================================
ERROR: test_many_to_many (admin_widgets.tests.AdminRawIdWidgetSeleniumTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/unittest/suite.py", line 163, in _handleClassSetUp
    setUpClass()
  File "/django/django/test/selenium.py", line 64, in setUpClass
    cls.selenium = cls.create_webdriver()
  File "/django/django/test/selenium.py", line 55, in create_webdriver
    return self.import_webdriver(self.browser)()
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"7814.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=54.0.2840.90)
  (Driver info: chromedriver=2.22.397932 (282ed7cf89cf0053b6542e0d0f039d4123bbb6ad),platform=Linux 4.4.0-38-generic x86_64)

or

======================================================================
ERROR: test_date_time_picker_shortcuts (admin_widgets.tests.DateTimePickerAltTimezoneSeleniumTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.5/unittest/suite.py", line 163, in _handleClassSetUp
    setUpClass()
  File "/django/django/test/selenium.py", line 64, in setUpClass
    cls.selenium = cls.create_webdriver()
  File "/django/django/test/selenium.py", line 55, in create_webdriver
    return self.import_webdriver(self.browser)()
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 407, in execute
    return self._request(command_info[0], url, body=data)
  File "/home/vagrant/venv/lib/python3.5/site-packages/selenium/webdriver/remote/remote_connection.py", line 439, in _request
    resp = self._conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

or

======================================================================
ERROR: test_refresh_page (admin_widgets.tests.HorizontalVerticalFilterSeleniumTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/suite.py", line 146, in _handleClassSetUp
    setUpClass()
  File "/django/django/test/selenium.py", line 64, in setUpClass
    cls.selenium = cls.create_webdriver()
  File "/django/django/test/selenium.py", line 55, in create_webdriver
    return self.import_webdriver(self.browser)()
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
    desired_capabilities=desired_capabilities)
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 407, in execute
    return self._request(command_info[0], url, body=data)
  File "/django/.tox/py27/local/lib/python2.7/site-packages/selenium/webdriver/remote/remote_connection.py", line 439, in _request
    resp = self._conn.getresponse()
  File "/usr/lib/python2.7/httplib.py", line 1136, in getresponse
    response.begin()
  File "/usr/lib/python2.7/httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.7/httplib.py", line 417, in _read_status
    raise BadStatusLine(line)
BadStatusLine: ''

I will continue investigating this problem.

Document common issues running on Linux

During pycon AU we had several issues getting django box running on Linux. Let's document common issues with Linux and their resolution steps.

  • nfs-kernel-server

Box not found during Vagrant up

Using b9eb4f0 of this repo (latest master at time of posting), I get:

[~/src/django-box]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'django-box-1.11' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'django-box-1.11' (v0) for provider: virtualbox
    default: Downloading: django-box-1.11
    default:
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

Couldn't open file /C:/Users/Ed/src/django-box/django-box-1.11
==> default: VM not created. Moving on...

This occurs even if I uncomment the box_url pref in Vagrantfile.

It's worth noting that since a box URL isn't set, Vagrant will only look on https://atlas.hashicorp.com/boxes/search - where the box doesn't exist.

NFS problem in sharing an encrypted folder on host

After going through the setup process as documented on an Ubuntu 16.04 host, the vagrant up command ends with a non zero exit status with:

==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 1.2.3.1:/home/wayne/Documents/Programming/git/django /django

Stdout from the command:

Stderr from the command:

mount.nfs: access denied by server while mounting 1.2.3.1:/home/wayne/Documents/Programming/git/django

As discussed at hashicorp/vagrant#5424, this issue appears to be an issue with NFS being unable to share a folder that is part of an encrypted (ecryptfs) volume. In my case /home/wayne is an ecryptfs volume

Due to the failure of the NFS share, /django in the test box is empty and therefore no tests can be run

OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'djangoproject/django-box-2.0' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'djangoproject/django-box-2.0'
default: URL: https://vagrantcloud.com/djangoproject/django-box-2.0
==> default: Adding box 'djangoproject/django-box-2.0' (v2.0.0) for provider: virtualbox
default: Downloading: https://vagrantcloud.com/djangoproject/boxes/django-box-2.0/versions/2.0.0/providers/virtualbox.box
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104

Some more guidance about testing for beginners in README.md

Hi,

It's great to have django-box, as it makes it easy to run test for new contributors. This only thing I find missing is a bit more guidance aimed at beginners. Some of it is covered on https://docs.djangoproject.com/en/1.10/topics/testing/overview/ but it doesn't seem to fully match with what's possible in django-box with the runtestsXX-xxx shortcuts.

  • What to do when a test fails ? How to debug failing tests ? Naive approaches such as using print statements, raising exceptions don't output anything usable in the console, using pdb also doesn't seem possible. Also it's not clear whether and how it's possible to use manage.py to run the dev server and test live using the shell or the browser.
  • Is it possible to speed up testing ? By default, all the tests are run, which is very long. It is possible to restrict to one particular module using eg. runtests35-mysql admin_views (runtests35-mysql admin_views.UserAdminTest or runtests35-mysql admin_views.UserAdminTest.test_user_fk_change_popup don't seem to work though), but this still takes more than 2 minutes to setup, making code/test iterations quite slow. Is it possible to avoid deletion/recreation of the database each time (which seem to be the most time-consuming task) ?
  • Is it possible to run all test at once, ideally exactly as done by Jenkins, so to make sure a commit passes all tests before making a PR ? By default, it seems the output of runtestsXX-xxxx goes to the console, but not to the .tox directory, so that it's hard to get a clean overview of what happened.

Thanks a lot for the box already, I think it's a big step towards getting more and better contributions to django ! (at least for me)

Cannot run on ubuntu 16.04

I tried to run this on ubuntu 16.04 with the default versions of vagrant (1.8.1+dfsg-1) and virtualbox (5.0.24-dfsg-0ubuntu1.16.04.1) and got this error when I ran vagrant up:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'djangoproject/django-box-1.11'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'djangoproject/django-box-1.11' is up to date...
==> default: Setting the name of the VM: django-box_default_1473795778940_68676
==> default: Pruning invalid NFS exports. Administrator privileges will be required...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown eth1 2> /dev/null

Stdout from the command:



Stderr from the command:

mesg: ttyname failed: Inappropriate ioctl for device

This appears to be related to a vagrant bug, which suggests I should upgrade to the latest version of vagrant (1.8.5). This gets further, but still fails with a similar error:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'djangoproject/django-box-1.11' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2016-09-13 20:38:51 BST; 13min ago
 Main PID: 2903 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

Sep 13 20:38:51 quartic-XPS13-9333 systemd[1]: Starting NFS server and services...
Sep 13 20:38:51 quartic-XPS13-9333 exportfs[2899]: exportfs: Failed to stat /home/quartic/dev/django: No such file or directory
Sep 13 20:38:51 quartic-XPS13-9333 systemd[1]: Started NFS server and services.
exportfs: /home/quartic/dev/django does not support NFS export
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

set -e
mkdir -p /django
mount -o vers=3,udp 1.2.3.1:/home/quartic/dev/django /django
if command -v /sbin/init && /sbin/init --version | grep upstart; then
  /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=/django
fi


Stdout from the command:



Stderr from the command:

mesg: ttyname failed: Inappropriate ioctl for device
mount.nfs: access denied by server while mounting 1.2.3.1:/home/quartic/dev/django

I finally tried to use the latest version of virtualbox (5.1.6-110634Ubuntuxenial amd64), but this also failed:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'djangoproject/django-box-1.11' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.0.20
    default: VirtualBox Version: 5.1
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
● nfs-server.service - NFS server and services
   Loaded: loaded (/lib/systemd/system/nfs-server.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2016-09-13 20:38:51 BST; 19min ago
 Main PID: 2903 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

Sep 13 20:38:51 quartic-XPS13-9333 systemd[1]: Starting NFS server and services...
Sep 13 20:38:51 quartic-XPS13-9333 exportfs[2899]: exportfs: Failed to stat /home/quartic/dev/django: No such file or directory
Sep 13 20:38:51 quartic-XPS13-9333 systemd[1]: Started NFS server and services.
exportfs: /home/quartic/dev/django does not support NFS export
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

set -e
mkdir -p /django
mount -o vers=3,udp 1.2.3.1:/home/quartic/dev/django /django
if command -v /sbin/init && /sbin/init --version | grep upstart; then
  /sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=/django
fi


Stdout from the command:



Stderr from the command:

mesg: ttyname failed: Inappropriate ioctl for device
mount.nfs: access denied by server while mounting 1.2.3.1:/home/quartic/dev/django

Mounting NFS on mac (OS 10.13.6) times out.

==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
Password:
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -o vers=3,udp 1.2.3.1:/Users/user/Documents/code/django-core/django /django

Stdout from the command:

Stderr from the command:

mount.nfs: Connection timed out


I tried the commands:
"vagrant destroy && sudo vagrant up"
to no avail.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.