This repository provides a comprehensive automated testing solution for validating and verifying Rancher-managed environments. By integrating UI and API tests, the suite ensures robust quality assurance for critical workflows in Rancher instances. The project is designed to work seamlessly within local environments and GitHub Actions CI/CD pipelines, offering scalable and reusable solutions.
- Integrated Testing: Combines UI (Cypress) and API (Go) tests to provide end-to-end coverage.
- Dynamic Environment Management: Automates the provisioning and teardown of Rancher environments using Docker and Terraform.
- CI/CD Integration: Fully automated workflows triggered by GitHub Actions to streamline testing and reporting.
- Scalability: Modular design allows individual or combined execution of UI and API tests.
- Optimized for Reusability: TypeScript-driven UI tests and Go-based API tests provide a robust and maintainable testing framework.
The repository is organized into the following components:
suse-qa-challenge/
├── api-tests/ # API tests implemented in Go
├── ui-tests/ # UI tests implemented with Cypress and TypeScript
├── scripts/ # Helper scripts for Rancher management
├── terraform/ # Infrastructure provisioning using Terraform
├── .github/workflows/ # CI/CD workflows for GitHub Actions
Ensure the following tools are installed:
- Docker (20.10 or newer)
- Node.js (18.x or newer)
- npm (for managing dependencies in ui-tests/)
- Go (1.21 or newer, for api-tests/)
- Terraform (1.0.0 or newer, for infrastructure provisioning)
- jq (JSON processor, for Rancher scripts)
- Clone the Repository:
git clone https://github.com/nikolarss0n/suse-qa-challenge.git
cd suse-qa-challenge- Setup UI Tests:
cd ui-tests
npm ci-
Setup API Tests: Ensure Go is installed and available on your PATH.
-
Make Rancher Scripts Executable:
chmod +x scripts/rancher-local.sh- Start Rancher:
npm run rancher:start-
Run Cypress Tests:
- Open the Cypress UI:
npm run test:open
- Run headlessly:
npm run test -
Stop Rancher:
npm run rancher:stop- Start Rancher and Generate API Tokens:
./scripts/rancher-local.sh start- Run API Tests:
cd api-tests
ginkgo -r- Stop Rancher:
./scripts/rancher-local.sh stopThe repository is configured with GitHub Actions workflows for automated testing. These are triggered on push events to main, test/, or feature/ branches and can also be initiated manually.
- Navigate to the Actions tab in your GitHub repository.
- Select the Rancher Test Suite workflow.
- Click Run workflow and choose the desired test suite (all, ui, or api).
The following variables are used for configuration:
- ADMIN_USERNAME: Rancher admin username
- ADMIN_PASSWORD: Rancher admin password
- CYPRESS_BASE_URL: Base URL for the Rancher instance
- CYPRESS_RANCHER_URL: Rancher API URL
- CYPRESS_AUTH_TOKEN: Authentication token for Rancher API
For local development, use cypress.env.json for UI tests:
{
"ADMIN_USERNAME": "username",
"ADMIN_PASSWORD": "password"
}- Environment Setup:
- Spins up a Rancher Docker container.
- Configures authentication tokens.
- Dependency Installation:
- Installs Cypress and Go dependencies.
- Test Execution:
- Runs UI and/or API tests based on the trigger.
- Artifact Upload:
- Saves test artifacts (e.g., videos, screenshots) for debugging.
- Cleanup:
- Stops and removes the Rancher container.
Test results and artifacts are available in:
- Local Runs:
- Cypress videos and screenshots: ui-tests/cypress/videos and ui-tests/cypress/screenshots
- CI/CD Runs:
- Available as downloadable artifacts in GitHub Actions.
To manually stop and clean up Rancher environments, run:
./scripts/rancher-local.sh stop