Automating Test Environments on Private Clouds using VMware

 This article is an attempt to provide an understanding of how automated testing using virtual machines can be set up, and the benefits of using this as a QA practice. Test engineers often struggle while trying to set up a quick test environment, and perform operations such as starting specific services on a virtual machine. Let’s go step by step to see how this can be done.

Let’s first understand what a test environment/test bed setup is, and why it is so important. In simple words, it includes the location for the application software, supporting data to conduct tests, and the tools required to support testing.

As testers, we perform testing on different operating systems, browsers and hardware to certify a software build. Every time there is a new build, the same set of tests are performed in a specific test environment. If we miss anything during testing, it may create problems at a later stage and reduce confidence in releasing the build. For example – a test plan requires testing an application or software on specific hardware. While preparing the test bed, if the tester misses this setting and files a defect, the developer can ignore it since that was not the expected test environment. This ends up in time wasted for both the QA tester and the developer. Automation can help a lot here, since all repetitive steps will be automated and executed every time.

A test bed or test environment is configured as per the need of the application under test. Key aspects of test setup include

  • Hardware and Operating system
  • System and applications
  • Test data
  • Database server
  • Front end running environment
  • Browsers
  • Network

Setting up a test environment is really complex, and the right process needs to be followed. Without going into detail, this broadly includes the following

  • Prepare a test environment checklist( it includes types of hardware, OS and other requirements).
  • Prepare a document that states the challenges that might be faced while setting up the environment.
  • Follow best practices.

Testing automation is simply the process of using software tools to perform testing procedures that were previously done manually. Automation may be applied to some or all of the procedures involved in performing a test. The process of adding automation to any testing environment requires a certain amount of work to be done to implement the tools chosen to perform the automated tasks. While setting up a test environment, we frequently use virtual machines to speed up the test environment setup without any error. We install certain softwares, set browsers, keep the test data on the virtual environment and take snapshots. While running the same test suite again, we simply switch our virtual machine to the starting point, saving a lot of time here. Let’s understand how to easily setup a test environment using the VMware virtual environment. I assume you are familiar with the ESXi server, vSphere client, Snapshot etc.

Approach 1: Using Jenkins CI.

Step 1: Install vSphere Cloud Plugin from the Jenkins plugin installation page.

Click on Manage Jenkins → Manage Plugins

image_1

Step 2: Go to the ‘Available’ Tab, select “vSphere Plugin” and install it.

Step 3: Next, configure Jenkins to address what vSphere server will be used. Add a new “Cloud” in the Jenkins “Configure System” menu. Click on Manage Jenkins → Configure System. Enter vSphere Host IP (ESXi server IP), Credentials and Name. Test the connectivity and save it. You can add multiple ESXi servers as well.

image_2

Step 4: Now everything is set and you can control your virtual machine available on this ESXi server. Create a job and add build step by ‘vSphere build step‘.

Image_3

This will add the following section in the job. Select appropriate action and enter data in the remaining fields. Enter the virtual machine name and snapshot name in the fields VM and Snapshot Name respectively.

image_4

Approach 2: Vmware provides Python API for interacting with vSphere Web Services. Using these APIs you can clone virtual machines, power off/power on, create a snapshot, or perform all operations asynchronously to speed up the tasks on multiple virtual machines.

PySphere provides easy interfaces to: ( taken from Here. )

  • Connect to VMWare’s ESX, ESXi, Virtual Center, Virtual Server hosts
  • Query hosts, datacenters, resource pools, virtual machines
  • VMs: Power on, power off, reset, revert to snapshot, get properties, update vmware tools, clone, migrate.
  • vSphere 5.0 Guest Operations: create/delete/move files and directories. upload/download files from the guest system. List/start/stop processes in the guest system.
  • Create and delete snapshots
  • Get hosts statistics and monitor performance

Installation of python module.

For Further reading, please visit HERE

Comments

Popular posts from this blog

Selenium: File download handling.

Major Differences between Python and Java

Cypress V/S Selenium