___________ _____________ ___ .____ .___ _________ _____
\_ _____// _____/\ \/ / | | | |/ _____/ / _ \
| __)_ \_____ \ \ / ______ | | | |\_____ \ / /_\ \
| \/ \ / \ /_____/ | |___| |/ \/ | \
/_______ /_______ //___/\ \ |_______ \___/_______ /\____|__ /
\/ \/ \_/ \/ \/ \/
ESX-LISA is an automation testing framework based on github.com/LIS/lis-test project. In order to support ESX, ESX-LISA uses PowerCLI to automate all aspects of vSphere management, including network, storage, VM, guest OS and more. This framework automates the tasks required to test the Redhat Enterprise Linux Server on WMware ESX Server.
- Start a VM
- Push files to a VM
- Start a script executing on a VM
- Collect files from a VM
- Shutdown a VM
Provides the functions that drive the VMs through various states that result in a test case being run on a VM.
Provides utility functions used by the automation.
Functions that return a OS specific command line.
A test run is driven by an XML file. A sample command might look like the following:
.\lisa.ps1 run xml\debug_demo.xml -dbgLevel 5
The XML file has a number of key sections as follows: Global The global section defines settings used to specify where the log files are to be written, who to send email to, which email server to use, etc.
TestSuites
This section defines a test suite and lists all the test
cases the test suite will run.
TestCases
This section defines every test case that a test suite
might call. Test case definitions include the following:
Name of the test case
The test script to run on the VM
The file to push to the VM
Test case timeout value (in seconds)
What to do on error (stop testing or move on to next test case)
Test parameters
Test parameters are placed in a file named constants.sh
and then copied to the VM. The test case script can
source constants.sh to gain accesws to the test parameters.
VMs
The VMs section lists the VMs that will run tests. There will be a
VM definition for each VM that will run a test. Each VM can run
a separate test suite.
A very simple XML file would look something like the following:
<?xml version="1.0" encoding="utf-8"?>
<config>
<global>
<logfileRootDir>TestResults</logfileRootDir>
<defaultSnapshot>ICABase</defaultSnapshot>
<email>
<recipients>
<to>myboss@mycompany.com</to>
<to>myself@mycompany.com</to>
</recipients>
<sender>myself@mycompany.com</sender>
<subject>ESX demo Test</subject>
<smtpServer>mysmtphost.mycompany.com</smtpServer>
</email>
</global>
<testSuites>
<suite>
<suiteName>debug_demo_suite</suiteName>
<suiteTests>
<suiteTest>debug_demo_case</suiteTest>
</suiteTests>
</suite>
</testSuites>
<testCases>
<test>
<testName>debug_demo_case</testName>
<testID>ESX-DEMO-001</testID>
<testScript>testscripts\debug_demo.ps1</testScript>
<RevertDefaultSnapshot>True</RevertDefaultSnapshot>
<timeout>120</timeout>
<onError>Continue</onError>
<noReboot>False</noReboot>
</test>
</testCases>
<VMs>
<vm>
<hvServer>ESXI_HOST_IPADDRESS</hvServer>
<vmName>VM_NAME</vmName>
<os>Linux</os>
<ipv4></ipv4>
<sshKey>id_rsa.ppk</sshKey>
<suite>debug_demo_suite</suite>
</vm>
</VMs>
</config>
The automation scripts make some assumptions about the VMs used to run the tests. This requires test VMs be provisioned prior to running tests. The following settings need to be provisioned.
- Disable Linux firewall.
- Add your public key into ~/.ssh/authorized_keys.
- The following packages must be installed.
- development-tools
- at
- dos2unix
- dosfstools
- wget
- bc
- ntpdate
- The yum repo must be configured.
SSH keys are used to pass commands to Linux VMs, so the public ssh Key must to copied to the VM before the test is started.
The dos2unix must be installed. It is used to ensure the file has the correct end of line character.
The automation scripts currently use Putty as the SSH client. You will need to copy the Putty executables to the ./bin directory. You will also need to convert the private key into a Putty Private Key (.ppk).
-
Choose a Windows machine which has Powershell installed and have connection with VCenter server
-
Download and install Git client for Windows, like Git-2.8.1-64bit.exe
-
Download and install a code editor, such as Atom or Visual Studio Code.
-
Add four system environment variables from Control Pannel -> System -> Advanced system settings -> Environment Variables... -> System variables -> New...
Name Description $ENVVISIPADDR vSphere Center Server IP address $ENVVISUSERNAME vSphere Center Server login username $ENVVISPASSWORD vSphere Center Server login password $ENVVISPROTOCOL Connection protocol with vSphere Center Server, such as HTTPS. -
Edit xml\debug_demo.xml, replace ESXI_HOST_IPADDRESS and VM_NAME with your settings.
-
Run demo case with one of the following cmdlets:
.\lisa.ps1 run .\xml\debug_demo.xml -dbgLevel 10
.\lisa.ps1 run .\xml\debug_demo.xml -vmName VM_NAME -hvServer ESXI_HOST_IPADDRESS -sshKey demo_id_rsa.ppk -suite debug_demo_suite -os Linux -dbgLevel 10