P2 Update Site for the DAWN project – the final piece of the puzzle

The Problem

The DAWN Science project has an update site, but an install of the product does not have the site automatically appearing in the ‘Available Software Sites’. This makes it difficult for users to upgrade their DAWN installation. 
Before: Sites list is empty

Workaround

Users can manually add in the site, but would need to know where to find the site. So even if users have the site URL, this is still an unnecessary hassle and definitely a significant barrier to upgrade. 

Complications

Over the years the Eclipse upgrade mechanism has changed dramatically, culminating in the P2 framework. A simple google search provides lots of out-of-date information mixed in with the key information (hint: anything referring to features and update sites is pretty much deprecated). P2 is a powerful and therefore complex mechanism. Even P2 developers admit things could be better – from the Eclipse help on P2 metadata:
 Disclaimer: Authoring p2 metadata is something we expect to support with better tooling in a future release. 
Most update site tutorials available do not address this final step, probably because its a product deployment issue, beyond the scope of the tutorials in question. 

Solution:

P2 can be a complicated beast, but the key information is out there if you know where to look.
The solution is to create a touchpoint advice file, place it the appropriate location and configure it with the site information. 
For DAWN that boils down to creating a new p2.inf file which is colocated with the org.dawnsci.base.product file. The file is configured with the update site information – here’s the key bit of magic.
This is essentially adding in a line with the instructions.configure key and the value in the specified format – see here for details
After: Sites list automatically populated with DAWN update site

Testing:

As ever, testing is the trickier part of the job. Using the existing Squish framework, two tests are added in. 
The first test launches DAWN and makes sure an update site is listed. This test ensures the list is not empty, it does not check the content of the list. While a check could be added to check the value of the site, this would make the test unnecessarily fragile and require updating every time the site is updated.  However, the content of the list of sites is added to the test logs to provide room for further checks if desired in the future. This is a regression test to ensure the codebase never reverts to the original problem. 
The second test actually provides a smoke test for the update site itself. This test launches a previously released version and then runs a full update against the DAWN p2 update site. The test passes if the p2 infrastructure returns success and DAWN restarts successfully. (Note this test is pending as it first requires the actual site locations to be approved).

Resources: