Build And Test In The Cloud
JavaGruppen 2011 Denmark
http://www.carlossanchez.eu
Building and testing software can be a time- and resource-consuming
task. Cloud computing/on-demand services such as Amazon EC2 provide a
cost-effective way to scale applications and, for building and testing
software, can reduce the time needed to find and correct problems,
meaning a cost reduction as well.
Properly configuring your build tools (Maven, Ant,...), continuous
integration servers (Continuum, Hudson, Cruise Control,...), and
testing tools (TestNG, Selenium,...) can enable you to run all the
building/testing process in a cloud environment, simulating high-load
environments, distributing long-running tests to reduce their
execution time, using different environments for client or server
applications, and so on—and in the case of on-demand services such as
Amazon EC2, pay only for the time you use it.
In this presentation we will introduce a development process and
architecture using popular open source tools for the build and test
process such as Apache Maven or Ant for building, Apache Continuum as
continuous integration server with distributed capabilities, TestNG
and Selenium for parallel, distributed and load testing, and how to
configure them to achieve the best results and performance in several
typical use cases (long running testing processes, different
environments, different client platforms,...) by using he Amazon
Elastic Computing Cloud EC2, and therefore reducing time and costs
compared to other solutions.
5. Build: Apache Maven
Build tool and more
Dependency management
Execution of unit/integration tests
Start/stop application server
Automatic application deployment
6. Test Cases: TestNG
Unit/integration tests
parameterized tests
parallel testing
7. Integration Tests: Selenium
UI and Integration testing
Tests run in the browser
support for multiple browsers
Tests can be recorded
no need for developers writing tests
Selenium IDE Firefox plugin
8. Continuous Integration: Apache Continuum
Tight integration with Apache Maven
dependency handling
Trigger builds
when integration tests change
when the webapp changes
when the webapp dependencies change
Distributed building
9. Cloud Computing: Amazon Web Services
Amazon S3
storage
Amazon SQS
queue service
Amazon Mechanical Turk
manpower
Amazon EC2
computation
12. Resource Optimization
build servers can be repurposed
test servers working 10-20% of the time
ability to do expensive builds/tests
for a short amount of time
20. Predictions cost money
Infrastructure
Cost $
You just lost
customers
Predicted
Demand
Opportunity Traditional
Cost Hardware
Actual
Demand
time
Source: Amazon
30. Continuum
Master Continuum server
Centralized management
Builds, users, output,...
Can build too
Distributed build agents
distribute load
different environments
different networks/clouds
32. Configuration
Use properties
Allow customizing environments
-Djetty.port=8081
-Dweb.host=184.73.250.39
33. Configuration
Use settings.xml <settings>
For user / agents <profiles>
configuration <profile>
<id>acme</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<jetty.port>8081</jetty.port>
<web.host>184.73.250.39</web.host>
</properties>
</profile>
</profiles>
</settings>
34. Build agents in the cloud
Startup
Automatically start with instance
API
Auto-connect to master when instance starts
ie. using user-data on EC2
35. Starting more agents
Not worth at build time
Instance startup time
Pay for full hours
Use a pool
Keep a minimum number of instances in pool
Start/Stop more as needed
43. The webapp to test
Apache Maven 2
Effective Implementation
Centrepoint sample webapp
44. A new Maven project
Centrepoint
selenium-tests
<groupId>com.effectivemaven.centrepoint</groupId>
<artifactId>selenium-tests</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Centrepoint Selenium Test Suite</name>
45. that depends on
Centrepoint webapp
<dependency>
<groupId>com.effectivemaven.centrepoint</groupId>
<artifactId>webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
46. using Jetty plugin to run it
automatically
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
68. Amazon AMIs
Create AMIs for different environments to test
Read user data to customize the images at runtime
where is the Selenium Hub
69. Linux
Selenium headless
Use *nix X Virtual Frame Buffer
In Maven
selenium:xvfb
70. Windows
Run Selenium Agent in user account
not local service
Selenium needs to have access to Desktop
Disable password expiration
Disable/Open windows firewall
netsh firewall add portopening TCP 8181 “Continuum BuildAgent”
netsh firewall add portopening TCP 9000 “Selenium RC 9000”
71. Browser config
Uninstall Internet Explorer Enhanced Security
Configuration
Windows 2003
http://www.visualwin.com/IE-enhanced-security/ in Add/Remove programs
Windows 2008
http://windowsitpro.com/article/articleid/96159/how-do-i-turn-off-internet-explorer-
enhanced-security-configuration-in-windows-server-2008.html
Safari/Firefox
Disable popup blocker