Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building and testing under CI a desktop application written in Python using Qt, nose and Jenkins.

Building and testing under CI a desktop application written in Python using Qt, nose and Jenkins.

This will be illustrated through the client we developed to allow bidirectional synchronization between a desktop app and a remote Nuxeo content repository.
The talk will cover the general concepts of a Python/Qt cross-platform application, the way we used unittest and nose to run functional tests and the whole build process handled by Jenkins. Starting from the application packaging for Windows and Mac OS X with cx_Feeze and py2app, ending with the execution of the tests under the 3 main platforms.

Antoine Taillefer

October 17, 2013
Tweet

Other Decks in Technology

Transcript

  1. OSDC 2013 - Paris Building and testing under CI a

    desktop application written in Python using Qt, nose and Jenkins Antoine Taillefer [email protected]
  2. 2 About me – Antoine Taillefer • Graduated from ENSEEIHT

    in 2006 • Worked for 5 years for an Open source solutions integrator • Working at Nuxeo since 2011 ✔ Software engineer ✔ Involved in consulting / training • Languages : ✔ Java ✔ Python
  3. 3 Agenda • Introduction: Nuxeo & Nuxeo Drive • Nuxeo

    Drive architecture • Coding session • Build and continuous integration • Roadmap
  4. 5 Useful links • Source code: github.com/nuxeo/nuxeo-drive • Documentation: doc.nuxeo.com

    • Continuous integration: qa.nuxeo.org • Backlog: jira.nuxeo.com - "Nuxeo Drive" • Nuxeo: nuxeo.com / nuxeo.org
  5. 6 Nuxeo Platform • Open source content management platform •

    Repository available through: ✔ Web user interface ✔ REST services (Nuxeo Drive) ✔ Shell • Java based • Modular and extensible => build business apps • Configuration tools: Nuxeo Studio / Nuxeo IDE
  6. 8 Nuxeo Drive • Fully open source, on Github, LGPL

    • Desktop client for Nuxeo • Available for Windows and OS X • Roundtrip synchronization • Selection of the folders to synchronize • Synchronization of any type of content • Conflict management (allows offline work) • Quick edit
  7. 9 Main features • Command line • Systray GUI •

    Background synchronization • Robust to network errors: goes offline • Token based authentication + revocation • Multiple server bindings
  8. 12 Server-side • Addon for Nuxeo • Token authentication service

    • Change detection based on audit log • Pluggable service layer • REST API: basic operations ✔ getChanges() ✔ downloadFile() ✔ createFile()
  9. 13 Client-side • UI thread / Synchronization thread • Local

    storage: maintain pair states • Token based authentication • Local file system client • Remote HTTP client (JSON) • Synchronization: infinite loop ✔ Polling for remote changes ✔ File system scan for local changes ✔ Resolution and synchronization
  10. 14 Main libraries • Threading: threading • Command-line : argparse

    • GUI: PyQt4 (GPL) • Storage / ORM: sqlalchemy • OS detection: sys • File system: os • HTTP exchanges: urllib2, json, poster • Logging: logging • Testing: nose
  11. 16 Dev tools • git • vi / Sublime Text

    / Eclipse + PyDev • nose (+ ipdbplugin) / PyUnit • Jenkins
  12. 17 Test Driven Development (TDD) • Goal: PDF conversion of

    locally synchronized files • Steps : ✔ Write test scenario ✔ Write test ✔ Run it with nose / PyUnit => should fail ✔ Implement feature ✔ Run test again => should succeed
  13. 18 GUI with PyQt • Goal: add menu entry to

    open the PDF conversion output folder • Steps: ✔ Code function ✔ Add menu action • Testing the PyQt GUI? ✔ Simulating clicks with PyQt API by sending signals ✔ PyQt QTest + unittest ✔ TDriver ✔ Squish
  14. 20 Goal • Build standalone binary packages ✔ For Windows:

    .msi ✔ For OS X: .dmg • Embed Python, Qt, PyQt and all required libraries • Don't interfere with already installed packages
  15. 21 Build environment setup • Install Python 2 (using Homebrew

    for OS X) • Install Qt / PyQt ✔ Linux: sudo apt-get install python-qt4 ✔ OS X: sudo brew install pyqt ✔ Windows: install binary package • Install pip with setuptools: sudo easy_install pip • Install freeze program ✔ Os X: pip install py2app ✔ Windows: install cx_Freeze
  16. 22 Application freeze • Clone nuxeo-drive from Github git clone

    https://github.com/nuxeo/nuxeo-drive.git • Grab dependencies sudo pip install -r requirements.txt • Run freeze • Windows python.exe setup.py --freeze –dev bdist_msi • OS X python setup.py py2app sh tools/osx/create-dmg.sh
  17. 24 Continuous integration • Jenkins • Several jobs ✔ Build

    Nuxeo addon with Maven ✔ Freeze for Windows => msi ✔ Freeze for OS X => dmg ✔ Functional tests (depends on previous jobs) ➔ Launch Nuxeo server with Drive addon ➔ Run tests with nose
  18. 26 Nuxeo 5.8 • HTTP proxy • Handle readonly documents

    • GUI improvements ✔ Unified settings menu ✔ Home folder configuration ✔ Status icon ✔ Last synchronization date
  19. 27 Nuxeo 5.x • GUI improvements ✔ Notifications ("10 files

    synchronized in 8 seconds") ✔ Recently modified files ✔ Suspend synchronization ✔ Multiple server bindings • Versioning and auto-upgrade • Explorer / Finder decoration + Right click • Optimization of local changes detection