Diff for "Foundations/Webservice/TestingApiApplications"

Not logged in - Log In / Register

Differences between revisions 6 and 7
Revision 6 as of 2010-10-08 18:23:09
Size: 3865
Editor: mars
Comment:
Revision 7 as of 2010-10-08 18:24:22
Size: 3933
Editor: mars
Comment:
Deletions are marked like this. Additions are marked like this.
Line 72: Line 72:
 * Your application can read and write data to a live server  * Your application can read and write test data to a live server
Line 76: Line 76:
 * The changes you make to the site data are not permanent
Line 78: Line 80:
 * Not all of data creation functions in Launchpad are available through the API; Working with SSH keys and Project Groups are two notable examples. You may be able to work around this by employing a mix of well-known existing data and generated sample data.  * Not all of data creation functions in Launchpad are available through the API (working with SSH keys and Project Groups are two notable examples). You may be able to work around this by employing a mix of well-known existing data and generated sample data.

This page provides a guide to writing tests for Launchpad API clients.

Techniques for Testing API Clients

Point your application at the staging.launchpad.net web service

By writing data to the staging.launchpad.net web service you can observe how the application will behave against a copy of real, live data. You can also observe the application going over the network.

The data on staging.launchpad.net is copied from the production database every night. Copying overwrites any changes made to the staging data from the previous day.

Pros

  • Your application gets to write real data to a live site over the network.
  • The changes you make to the site data are not permanent

Cons

  • If your application reads and writes data to Launchpad, and you want to do multiple test runs against staging between the nightly database resets, then you will have to write your application to reset the data for you, or you must reset it manually. Depending on the problem you are trying to solve, you may also have the option to have your application ignore and overwrite any data already present on the server. You may also consider having your application generate its own test data.

  • Because the staging server is only updated nightly, you can not test your application against data on the same data that that data was entered into production. You may be able to work around by providing your users with a read-only switch.

An Example

Notes

The staging database always runs code that is released or soon-to-be released on the Launchpad production servers. The API version will be equal to or greater than the production API version.

The staging server goes down for approximately two hours on the weekend for automated database updates.


Give your application read-only access to the server

By giving your application read-only access to the server you can allow developers and users to test your application against live data without fear of it destroying data. By only reading data it also becomes possible to run the tests multiple times in a row.

Pros

  • Both developers and users can test your application without fear of it destroying data
  • You can run the tests as many times as desired
  • Your application gets to read real data from a production server

Cons

  • Some application tests are not possible without writing data. You may not get 100% test coverage with this technique.
  • You must modify your code so that it gracefully handles the inability to write data to the server, and you must do so at every point where data writes happen. This can be tedious to retrofit into an existing script.

An Example

Notes


Have your application generate its own test data on the staging server

This is an advanced technique that builds upon 'test your application against staging'. You can have your application generate its own test data on the staging server, then run its tests against said data.

Pros

  • Your application can read and write test data to a live server
  • You are not limited by how many times in a row you can run the tests
  • The changes you make to the site data are not permanent

Cons

  • Not all of data creation functions in Launchpad are available through the API (working with SSH keys and Project Groups are two notable examples). You may be able to work around this by employing a mix of well-known existing data and generated sample data.

An Example

Notes

Foundations/Webservice/TestingApiApplications (last edited 2010-11-02 00:50:26 by gary)