Skip to content

WebFrontendDevelopment

Lucas Meneghel Rodrigues edited this page Sep 22, 2011 · 2 revisions

Web Frontend Development

When we run a production Autotest server, we run the Django server through Apache and serve a compiled version of the GWT client. For development, however, this is far too painful, and we go through a completely different setup.

Django server development

You can read more about Django development at their documentation site, but here's the short version. The frontend/manage.py script is your friend here.

  • Running manage.py runserver will start a development server on http://localhost:8000. This server automatically reloads files when you change them. You can also view stdout/stderr from your Django code right in the console. There's not a whole lot you can do from your browser with this server by itself, since the only interface to it is through RPCs.

  • manage.py test will run the server test suite (implemented in frontend/afe/test.py). This includes running pylint on all files in frontend/afe/ (checking for errors only), running doctests found in the code, and running the extended doctests in frontend/afe/doctests. This suite is pretty good at catching errors, and you should definitely make sure it passes before submitting patches (and please add to it if you add new features). Note you may need to install pylint (Ubuntu package python2.4-pylint).

  • On that note, frontend/afe/doctests/rpc_test.txt is also the best documentation of the RPC interface to the server, so it's a pretty good place to start in understanding what's going on. It's purposely written to be readable as documentation, so it doesn't contain tests for all corner cases (such as error cases). Such tests should be written eventually, but they don't exist now, and if you write some, please place them in a separate file so as to keep rpc_test.txt readable.

  • You can test the RPC interface out by hand from a Python interpreter:

    >>> import common
    >>> from frontend.afe import rpc_client_lib
    >>> proxy = rpc_client_lib.get_proxy('http://localhost:8000/afe/server/rpc/', headers={})
    >>> proxy.get_tests(name='sleeptest')
    [{u'description': u'Just a sleep test.', u'test_type': u'Client', u'test_class': u'Kernel', u'path': u'client/tests/sleeptest/control', u'id': 1, u'name': u'sleeptest'}]
    

GWT client development

Again, the full scoop can be found in the GWT Developer Guide, but here's the short version:

Without Eclipse

  • frontend/client/AfeClient-shell runs a GWT development shell. This runs the client in a JRE in a modified browser widget. It will connect to the Django server and operate just like the production setup, but it's all running as a normal Java program and it compiles on-demand, so you'll never need to compile, you can use your favorite Java debugger, etc.
  • Exception tracebacks are viewable in the console window, and you can print information to this console using GWT.log().
  • Hitting reload in the browser window will pull in and recompile any changes to the Java code.

With Eclipse

  • The frontend/client/ directory contains .project and .classpath files for Eclipse, so you should be able to import the project using File->Import...->Existing Project into Workspace.
  • The frontend/client/AfeClient.launch file contains a launch configuration for the development shell, so you can run that by going to Run->Run Configurations... and selecting Afe````Client (after running once from there, you should be able to run directly through the Run button on the toolbar).
  • Likewise, you can debug through that launch configuration and set breakpoints etc. just like normal.

See Also

Clone this wiki locally