January 26, 2021
Hot Topics:

Building a Test Platform in the Cloud with Open Source Technologies

  • By Rini Susan, Vikas Valikan
  • Send Email »
  • More Articles »

Creating the Images for the Cloud Test Environment

In this section, we examine the various steps involved in creating each of the three previously listed images, providing the necessary startup scripts in detail. You can create the images in any of the CentOS 5.2 machines. Before we can begin, we need a pre-bundled CentOS 5.2 image. Refer to this OTN article for image creation details.

Creating the Tomcat Image

The pre-bundled CentOS image has to be mounted into a local directory. The first step is to create a directory where you can mount the image. Open a command prompt and execute the following commands.

# Make directorymkdir /mnt/Mount

Now mount the pre-bundled CentOS 5.2 image to the created folder.

#Mount Imagemount -o loop /mnt/Mount#Mount the Procmount -t proc none /mnt/Mount/proc/

Install Tomcat in the mount folder (i.e. place a Tomcat folder inside /mnt/Mount/home). To ensure that Tomcat starts automatically during instance bootup, follow these steps:

  1. Include JAVA_HOME and PATH variables in the /etc/rc.local file (/mnt/Mount/etc/rc.local).
  2. Add the startup script of Tomcat in the /etc/rc.local file as well.

The rc.local file should be as follows.

#!/bin/sh# This script will be executed *after* all the other init scripts.touch /var/lock/subsys/localexport JAVA_HOME=/home/jdk1.6.0_13export PATH=/home/jdk1.6.0_13/bin:$PATH:$HOME/bin/home/apache-Tomcat-6.0.18/bin/startup.sh

The Web application we used for testing is JPetStore. Put jpetstore.war inside the /webapps/ folder. Now the image contains all the necessary software and scripts.

The next step is to unmount the image. Go to the command prompt and execute the following commands.

#Un-Mount procumount /mnt/Mount/proc# Un-Mount Imageumount -d /mnt/Mount

The image that you obtain contains Tomcat 6 and the Web application. This image is now ready to be uploaded into the cloud. For instructions on uploading and running the image, refer to the Eucalyptus Image Management documentation.

Creating the JMeter Image

To create the JMeter image, follow the same steps as those for creating the Tomcat image in the previous section. Mount a CentOS 5.2 pre-bundled image to a specific folder:

#Mount Imagemount -o loop /mnt/Mount#Mount the Procmount -t proc none /mnt/Mount/proc/

Move JMeter 2.3.2 files inside the /mnt/Mount/home folder.

The JMeter master is set up in a physical Linux machine and the JMeter instance acts as slave. First, add the master to the slave machine's list of "known hosts" (refer to Setting up passwordless, passphraseless ssh for details), and then generate a passphrase-less key for the master machine and add it to the slave image. Keep the id_dsa generated on the master machine in the specified folder of the slave image (e.g. /mnt/Mount/home). Hence, each time the slave instance boots up, it will have the master's IP in the list of known hosts.

When the JMeter slave instance boots up, its IP address needs to be updated in the master machine's jmeter.properties file. To add the IP address automatically, we used a shell script. Create a script file within the mount folder (/mnt/Mount/home).

#---------- Find Ip-address of slave -----OS=`uname`IP="" # store IPJMETER_Prop_File=""Master=""KeyPath="/id_dsa" # Master's Passphrase less key.case $OS inLinux) IP=`ifconfig | grep 'inet addr:'| grep -v '' | cut -d: -f2 | awk '{ print $1}'`;;FreeBSD|OpenBSD) IP=`ifconfig | grep -E 'inet.[0-9]' | grep -v '' | awk '{ print $2}'` ;;SunOS) IP=`ifconfig -a | grep inet | grep -v '' | awk '{ print $2} '` ;;*) IP="Unknown";;esac#---------------- writes slaves Ip in master's properties file-----ssh -i $KeyPath root@$Master "sed -e 's/remote_hosts=/remote_hosts=$IP,/1' $JMETER_Prop_File/jmeter.properties>$JMETER_Prop_File/test.chk"ssh -i $KeyPath root@$Master "cp $JMETER_Prop_File/test.chk $JMETER_Prop_File/jmeter.properties"ssh -i $KeyPath root@$Master "rm -rf $JMETER_Prop_File/test.chk"

Save the above file with a .sh extension. Add the path of services that need to start up automatically during the instance bootup in the rc.local file (Refer back to the "Creating the Tomcat Image" section).

#!/bin/sh# this script will be executed *after* all the other init scripts.touch /var/lock/subsys/localchmod 600 //id_dsa/ export JAVA_HOME=//javaexport PATH=//java/bin:$PATH:$HOME/bin//jmeter2.3.2/bin/jmeter-serverservice vsftpd start

Unmount the image as explained in the "Creating the Tomcat Image" section.

Page 2 of 3

This article was originally published on October 20, 2010

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date