-
-
Notifications
You must be signed in to change notification settings - Fork 28
[#1560] Replaced BATS with PHPUnit for functional internal Vortex tests. #1657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
21e28c0
Moved the idempotence tests to PHPUnit.
AlexSkrypnyk a4787f7
Updated helpers.
AlexSkrypnyk 12c5799
verbose steps
AlexSkrypnyk 97174e2
Moved test files.
AlexSkrypnyk 8b14b26
Updated to helper 0.8.1 and simplified processRun().
AlexSkrypnyk 46878a0
Route all file operations through File class.
AlexSkrypnyk d6e942b
Fixed edge cases.
AlexSkrypnyk f955d54
Updated documentation.
AlexSkrypnyk aad905f
Fixed false assertion.
AlexSkrypnyk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Vortex Testing Framework | ||
|
|
||
| This directory contains the comprehensive testing system for the Vortex project | ||
| to ensure the quality and reliability of Vortex workflows and scripts. | ||
|
|
||
| ## Overview | ||
|
|
||
| The Vortex testing framework is designed to validate: | ||
|
|
||
| - Core Vortex functionality and scripts | ||
| - Installation and deployment workflows | ||
| - Integration scenarios | ||
| - CI/CD pipeline components | ||
|
|
||
| ## Testing Technologies | ||
|
|
||
| ### PHPUnit | ||
|
|
||
| PHPUnit handles functional testing of Vortex user's **workflows**: processes | ||
| and commands are ran in the context of a Vortex installation, simulating | ||
| real-world scenarios. | ||
|
|
||
| ### Bats (Bash Automated Testing System) | ||
|
|
||
| [Bats](https://github.com/bats-core/bats-core) is used for **unit** testing | ||
| shell scripts with coverage. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Docker and Docker Compose | ||
| - Node.js and Yarn | ||
| - PHP 8.2+ | ||
| - Composer | ||
| - Git | ||
|
|
||
| ### Setup | ||
|
|
||
| ```bash | ||
| # Install PHP dependencies | ||
| composer install | ||
|
|
||
| # Install Node.js dependencies for BATS testing (BATS is distributed via npm, but does not require Node.js to run) | ||
| yarn install | ||
| ``` | ||
|
|
||
| ## Running PHPUnit Tests | ||
|
|
||
| ```bash | ||
| # Run all PHPUnit tests | ||
| ./vendor/bin/phpunit | ||
|
|
||
| # Run specific test class | ||
| ./vendor/bin/phpunit phpunit/Functional/WorkflowTest.php | ||
| ``` | ||
|
|
||
| ## Running BATS tests | ||
|
|
||
| ```bash | ||
| # Run specific Bats test file | ||
| bats bats/helpers.bats | ||
|
|
||
| # Run with verbose output | ||
| bats --verbose-run bats/provision.bats | ||
| ``` | ||
|
|
||
| ## Running Individual Test Suites | ||
|
|
||
| For parallel execution, tests can be run across multiple CI nodes using the | ||
| convenience script wrappers: | ||
|
|
||
| - [`test.common.sh]`(test.common.sh) - Common tests for all environments | ||
| - [`test.deployment.sh`](test.deployment.sh) - Deployment tests | ||
| - [`test.postbuild.sh`](test.postbuild.sh) - Post-build tests | ||
| - [`test.workflow.sh`](test.workflow.sh) - Workflow tests | ||
| - [`lint.scripts.sh`](lint.scripts.sh) - Linting for shell scripts | ||
| - [`lint.dockerfiles.sh`](lint.dockerfiles.sh) - Linting for Dockerfiles | ||
|
|
||
| These scripts are designed to run in CI environments (CircleCI, GitHub Actions) | ||
| and use the `TEST_NODE_INDEX` environment variable to distribute tests across | ||
| multiple runners. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| The following environment variables can be added in the environment to | ||
| customize test execution: | ||
|
|
||
| - `TEST_VORTEX_DEBUG=1` - Enable debug output | ||
| - `TEST_NODE_INDEX` - CI runner index for parallel execution | ||
| - `VORTEX_DEV_TEST_COVERAGE_DIR` - Coverage output directory | ||
| - `TEST_GITHUB_TOKEN` - GitHub token used for integration tests | ||
| - `TEST_VORTEX_CONTAINER_REGISTRY_USER/PASS` - Container registry credentials used for integration tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,56 @@ | ||
| { | ||
| "name": "drevops/vortex-tests", | ||
| "description": "Tests for Vortex", | ||
| "description": "Test for the Vortex project", | ||
| "type": "project", | ||
| "authors": [ | ||
| { | ||
| "name": "Alex Skrypnyk", | ||
| "email": "alex@drevops.com" | ||
| } | ||
| ], | ||
| "require": { | ||
| "php": ">=8.2" | ||
| }, | ||
| "require-dev": { | ||
| "alexskrypnyk/file": "^0.7.0", | ||
| "alexskrypnyk/phpunit-helpers": "^0.8.1", | ||
| "alexskrypnyk/shellvar": "^1.2", | ||
| "czproject/git-php": "^4.4", | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^1", | ||
| "drupal/coder": "^8.3", | ||
| "ergebnis/composer-normalize": "^2.47", | ||
| "phpstan/phpstan": "^2", | ||
| "phpunit/phpunit": "^12.1", | ||
| "rector/rector": "^2", | ||
| "squizlabs/php_codesniffer": "^3.12" | ||
| }, | ||
| "minimum-stability": "alpha", | ||
| "prefer-stable": true, | ||
| "require-dev": { | ||
| "alexskrypnyk/shellvar": "^1" | ||
| "autoload-dev": { | ||
| "psr-4": { | ||
| "DrevOps\\Vortex\\Tests\\": "phpunit/", | ||
| "AlexSkrypnyk\\File\\Tests\\": "vendor/alexskrypnyk/file/tests/" | ||
| } | ||
| }, | ||
| "config": { | ||
| "allow-plugins": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": true, | ||
| "ergebnis/composer-normalize": true | ||
| }, | ||
| "discard-changes": true, | ||
| "sort-packages": true | ||
| }, | ||
| "scripts": { | ||
| "lint": [ | ||
| "phpcs", | ||
| "phpstan", | ||
| "rector --clear-cache --dry-run" | ||
| ], | ||
| "lint-fix": [ | ||
| "rector --clear-cache", | ||
| "phpcbf" | ||
| ], | ||
| "reset": "rm -Rf vendor", | ||
| "test": "phpunit" | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Platform-agnostic
resetscript"reset": "rm -Rf vendor"breaks on Windows shells. A small PHP helper keeps it cross-platform:📝 Committable suggestion
🤖 Prompt for AI Agents