In this post, we'll take a step forward and add a custom task to CCNet that will query the database and generate a custom xml summary that includes performance comparison with previous runs, performance counters measurements per machine (divided to logical groups) and exception details for all the tests that have failed. We will also extend the CCNET portal to present the custom content.
Here's a screenshot of the resulting portal:
The source code can be downloaded from http://bookstoreservice.codeplex.com/SourceControl/list/changesets
Generating the Summary XML
Let's review the process that generates the summary xml out of the LoadTest2010 database (where the load test data is saved).
Here's the class diagram
We used 'LINQ to SQL' is to query data from the LoadTest2010 database.
Using 'Server Explorer' we can connect to the LoadTest2010 database and drag/drop the appropriate Tables/Views onto the dbml editor surface. For each Table/View – matching metadata classes and CRUD operations are automatically generated.
The auto-generated classes (LoadTest2010DataContext, LoadTestTestResult, LoadTestMessageSummary, LoadTestRun, LoadTestTransactionResult, ) are used by DataAccessService for all the interactions with the database.
Here's the DataAccessService class.
Here's the program main workflow:
As presented above, we used the DataAccessService to query data from the database and the XmlGenerator class to add the aggregated data to Xml.
Cruise Control .NET Configuration
We'll start by installing CCNet from here
Once the installation is complete, we need to add the appropriate project/tasks to CCNet configuration file located here: %Program Files%CruiseControl.NET\server\ccnet.config
The difference between this configuration and the configuration in the previous post, is that here we have an extra task for running the process LoadTestDbToXml.exe (explained above). This process queries the LoadTest2010 database and creates xml name LoadTestSummary.xml. In addition, instead of adding the test result trx to the build log, we will add LoadTestSummary.xml.
With the configuration above, CCNet will do the following (every 4 hours or one demand):
- Delete the last LoadTestSummary.xml
- Build the BookStore.sln
- Run the load test.
- Run LoadTestDbToXml.exe (this run will generate LoadTestSummary.xml)
- Add LoadTestSummary.xml to the build log (so we can present it in the portal)
Now. we need to extend the CCNet portal to present the results. We need to:
- Create xsl that transform the LoadTestSummary.xml to HTML
- Copy the xsl to '%Program Files%\CruiseControl.NET\webdashboard\xsl'
- Add link to the xsl to 'Program Files (x86)\CruiseControl.NET\webdashboard\dashboard.config'
- Restart IIS
Here's the xsl:
Here's the modified dashboard.config:We are done!
Now we can start the 'Cruise Control .NET' service or run the executable process from %Program Files%CruiseControl.NET\server\ccnet.exe.
Once the CCNet service/process is started, we can go ahead and trigger a build.The simplest way is to browse to the portal (installed and deployed to IIS during the installation) and force a build.