Apache CloudStack UI automation framework using Playwright for end-to-end testing of the web interface. Includes smoke tests, BAT tests, and automated regression testing integrated with Jenkins CI/CD.
- Overview
- Prerequisites
- Installation
- Configuration
- Running Tests
- Test Structure
- Jenkins Integration
- Contributing
- Troubleshooting
This framework provides automated UI testing for Apache CloudStack using Playwright. It's designed to:
- Verify CloudStack UI functionality
- Run smoke tests for quick health checks
- Execute BAT (Basic Acceptance Tests) for core features
- Integrate seamlessly with Jenkins CI/CD
- Generate comprehensive test reports
- Support multiple CloudStack environments
| Category | Duration | Purpose | When to Run |
|---|---|---|---|
| @smoke | 1-2 min | Quick health check (login, navigation) | After every deployment |
| @bat | 5-10 min | Core functionality (VM deployment, basic operations) | Before release |
| all | 10-20 min | Complete test suite | Full regression |
- Node.js: v18.x or higher
- npm: v9.x or higher
- Git: For cloning the repository
- Apache CloudStack instance (4.18+ recommended)
- Management server accessible via HTTP/HTTPS
- Admin credentials
- OS: Linux, macOS, or Windows
- RAM: 2GB minimum, 4GB recommended
- Disk: 1GB free space
git clone https://github.com/shapeblue/cloudstack-ui-automation.git
cd cloudstack-ui-automationnpm installnpx playwright install chromium --with-depsOr install all browsers:
npx playwright install --with-depsnpx playwright --versionCreate a .env file in the project root:
# CloudStack Configuration
CLOUDSTACK_URL=http://10.0.3.101:8080/client
CLOUDSTACK_MGMT_IP=10.0.3.101
CLOUDSTACK_USERNAME=admin
CLOUDSTACK_PASSWORD=password
CLOUDSTACK_DOMAIN=/
# Test Configuration
HEADLESS=true
BROWSER=chromium
TIMEOUT=30000| Variable | Description | Default | Required |
|---|---|---|---|
CLOUDSTACK_URL |
CloudStack UI URL | - | Yes |
CLOUDSTACK_MGMT_IP |
Management server IP | - | Yes |
CLOUDSTACK_USERNAME |
Admin username | admin |
Yes |
CLOUDSTACK_PASSWORD |
Admin password | password |
Yes |
CLOUDSTACK_DOMAIN |
Domain path | / |
Optional |
HEADLESS |
Run in headless mode | true |
Optional |
BROWSER |
Browser to use | chromium |
Optional |
TIMEOUT |
Default timeout (ms) | 30000 |
Optional |
If not using .env, you can configure in playwright.config.js:
export default defineConfig({
use: {
baseURL: 'http://your-cloudstack-url:8080/client',
// ... other settings
},
});npm testnpm test -- --grep "@smoke"npm test -- --grep "@bat"npm test tests/01-login.spec.jsnpm run test:headednpm run test:uinpm run test:debugcloudstack-ui-automation/
├── tests/ # Test files
│ ├── 01-login.spec.js # Login/logout tests (@smoke, @bat)
│ ├── 02-vm-deployment.spec.js # VM deployment tests (@bat)
│ └── fixtures.js # Test fixtures and setup
│
├── pages/ # Page Object Models
│ ├── BasePage.js # Base page class
│ ├── LoginPage.js # Login page
│ ├── DashboardPage.js # Dashboard page
│ └── VirtualMachinePage.js # VM management page
│
├── utils/ # Utility scripts
│ ├── environment-extractor.js # Extract config from Trillian
│ └── helpers.js # Helper functions
│
├── playwright.config.js # Playwright configuration
├── package.json # Dependencies and scripts
└── .env # Environment variables (create this)
- Login with valid credentials (@smoke, @bat)
- Login with invalid credentials (@smoke)
- Logout functionality (@smoke)
- Dashboard navigation (@smoke)
- Deploy virtual machine (@bat)
- Deploy VM and wait for Running state (@bat)
- Deploy VM with custom configuration (@bat)
- Verify VM in list (@bat)
Page Object Model (POM) pattern for maintainable tests:
// Example: pages/LoginPage.js
class LoginPage extends BasePage {
async login(username, password) {
await this.fillInput('#username', username);
await this.fillInput('#password', password);
await this.clickElement('#login-button');
}
}- Jenkins instance with Pipeline support
- Jenkins agent with Node.js and Git installed
- Access to CloudStack environment
-
Create Jenkins Job (or use existing Trillian job)
-
Add Parameters:
RUN_UI_TESTS(Boolean): Enable UI testsUI_TEST_SUITE(Choice):@smoke,@bat, orall
-
Add Build Steps:
#!/bin/bash
echo "Cloning UI Automation Framework"
UI_AUTO_DIR="$WORKSPACE/cloudstack-ui-automation"
if [ -d "$UI_AUTO_DIR" ]; then
rm -rf "$UI_AUTO_DIR"
fi
git clone https://github.com/shapeblue/cloudstack-ui-automation.git "$UI_AUTO_DIR"#!/bin/bash
if [ "$RUN_UI_TESTS" != "true" ]; then
echo "UI tests disabled"
exit 0
fi
cd "$WORKSPACE/cloudstack-ui-automation"
npm install
npx playwright install chromium --with-deps
# Extract environment from Trillian
node utils/environment-extractor.js "$WORKSPACE"
# Run tests
export TESTS_TO_RUN="${UI_TEST_SUITE:-@bat}"
export HEADLESS="true"
npm test -- --grep "$TESTS_TO_RUN"- Add Post-Build Actions:
- Publish JUnit results:
ui-test-results/junit.xml - Publish HTML reports:
ui-test-results/html-report/index.html - Archive artifacts:
ui-test-results/**/*
- Publish JUnit results:
pipeline {
agent any
parameters {
booleanParam(name: 'RUN_UI_TESTS', defaultValue: false, description: 'Run UI tests')
choice(name: 'UI_TEST_SUITE', choices: ['@bat', '@smoke', 'all'], description: 'Test suite')
}
stages {
stage('Deploy CloudStack') {
steps {
// Your Trillian deployment steps
}
}
stage('Clone UI Tests') {
steps {
sh '''
git clone https://github.com/shapeblue/cloudstack-ui-automation.git
'''
}
}
stage('Run UI Tests') {
when {
expression { params.RUN_UI_TESTS == true }
}
steps {
dir('cloudstack-ui-automation') {
sh '''
npm install
npx playwright install chromium --with-deps
node utils/environment-extractor.js "$WORKSPACE"
npm test -- --grep "${UI_TEST_SUITE}"
'''
}
}
}
}
post {
always {
junit 'cloudstack-ui-automation/test-results/junit.xml'
publishHTML([
reportDir: 'cloudstack-ui-automation/playwright-report',
reportFiles: 'index.html',
reportName: 'Playwright Test Report'
])
}
}
}After tests run, view the interactive HTML report:
npx playwright show-reportOr open manually:
playwright-report/index.html
Located at: test-results/junit.xml
Used by Jenkins for test result visualization.
Real-time test execution output in terminal.
Error: browserType.launch: Executable doesn't exist
Solution:
npx playwright install chromium --with-depsError: net::ERR_CONNECTION_REFUSED
Solution: Verify CloudStack URL in .env:
# Check if CloudStack is accessible
curl http://your-cloudstack-url:8080/clientError: Login failed - Element not found
Solution:
- Verify credentials in
.env - Check CloudStack version compatibility
- Run in headed mode to see what's happening:
npm run test:headedError: Test timeout of 30000ms exceeded
Solution: Increase timeout in .env:
TIMEOUT=60000Or in specific test:
test.setTimeout(60000);Error: Failed to extract environment configuration
Solution: Ensure Trillian created these files:
ls $WORKSPACE/config_name
ls $WORKSPACE/Ansible/hosts_*- Create test file in
tests/directory - Use appropriate tags:
@smoke,@bat,@network, etc. - Follow naming convention:
NN-feature-name.spec.js - Use Page Objects for UI interactions
Example:
// tests/03-networks.spec.js
import { test, expect } from './fixtures';
test('should create network @bat @network', async ({ networkPage }) => {
await networkPage.createNetwork({
name: 'test-network',
displayText: 'Test Network'
});
expect(await networkPage.networkExists('test-network')).toBeTruthy();
});- Extend BasePage for common functionality
- Use descriptive method names
- Add JSDoc comments
Example:
// pages/NetworkPage.js
import BasePage from './BasePage.js';
class NetworkPage extends BasePage {
/**
* Creates a new guest network
* @param {Object} config - Network configuration
* @param {string} config.name - Network name
* @param {string} config.displayText - Display text
*/
async createNetwork(config) {
await this.clickElement('button:has-text("Add Guest Network")');
await this.fillInput('[name="name"]', config.name);
await this.clickElement('button:has-text("Create")');
}
}
export default NetworkPage;- Use
async/awaitfor asynchronous operations - Use descriptive variable names
- Add comments for complex logic
- Follow existing patterns in the codebase
- Login/Logout
- Dashboard navigation
- VM deployment
- VM state verification
- Network management
- Storage operations
- Template management
- User/Account management
- Project management
- Keep tests independent: Each test should run standalone
- Use descriptive names: Test name should describe what it does
- Tag appropriately: Use
@smoke,@bat,@network, etc. - Clean up resources: Delete created resources after tests
- One page object per page: Don't mix different pages
- Reusable methods: Create methods that can be used by multiple tests
- Wait for elements: Use proper wait strategies
- Error handling: Add meaningful error messages
- Use environment variables: Don't hardcode URLs/credentials
- Keep secrets safe: Never commit
.envto Git - Document requirements: Add comments for config options
Apache License 2.0
- ShapeBlue QA Team
For questions or issues:
- Check Troubleshooting section
- Review GitHub Issues
- Contact ShapeBlue QA team
# Clone and install
git clone https://github.com/shapeblue/cloudstack-ui-automation.git
cd cloudstack-ui-automation
npm install
npx playwright install chromium --with-deps
# Configure
echo "CLOUDSTACK_URL=http://your-cloudstack:8080/client" > .env
echo "CLOUDSTACK_MGMT_IP=your-mgmt-ip" >> .env
echo "CLOUDSTACK_USERNAME=admin" >> .env
echo "CLOUDSTACK_PASSWORD=password" >> .env
# Run tests
npm test -- --grep "@smoke" # Quick smoke tests
npm test -- --grep "@bat" # Core BAT tests
npm test # All testsHappy Testing!