Skip to content
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

Add more behat test suits #118

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ env:
- TEST_COMMAND=$(echo $TRAVIS_REPO_SLUG | cut -d/ -f 2) # Get command name to be tested

before_script:
- cat /etc/mysql/my.cnf | grep -i 'bind-address'
- sudo sed -i 's/^bind-address.*/bind-address = "0.0.0.0"/' /etc/mysql/my.cnf
- cat /etc/mysql/my.cnf | grep -i 'bind-address'
- sudo service mysql restart
- sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
- |
# Remove Xdebug for a huge performance increase:
Expand All @@ -17,7 +21,6 @@ before_script:
echo "xdebug.ini does not exist"
fi
- ./ci/prepare.sh
- ./ci/add-test-certs.sh

script:
- cd "$TRAVIS_BUILD_DIR/../easyengine"
Expand All @@ -39,3 +42,6 @@ addons:
apt:
packages:
- docker-ce

services:
- mysql
106 changes: 0 additions & 106 deletions ci/add-test-certs.sh

This file was deleted.

34 changes: 34 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,12 @@ public static function cleanup(AfterFeatureScope $scope)
'www.example3.test',
'labels.test',
'wpcache.test',
'wp-local-db.test',
'wp-local-redis.test',
'wp-local-db-redis.test',
'wp-remote-db-local-redis.test',
'wp-remote-db-global-redis.test',

];

$result = EE::launch( 'sudo bin/ee site list --format=text',false, true );
Expand All @@ -422,4 +428,32 @@ public static function cleanup(AfterFeatureScope $scope)
unlink('ee-old.phar');
}
}

/**
* @Then Check global redis cache for :site
*/
public function checkGlobalRedisCacheOfSite($site)
{
exec("docker exec -it ee-global-redis redis-cli set 'easyengine' 'rocks'");
$output = exec("docker exec -it ee-global-redis redis-cli get 'easyengine'");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add checks for object cache working using: wp cache set and wp cache get
In both local and global scenario.

if ( '"rocks"' !== $output ) {
throw new Exception("Global redis not working for $site site. Getting '$output' instead of 'rock'");
}
exec("docker exec -it ee-global-redis redis-cli del 'easyengine'");
}

/**
* @Then Check local redis cache for :site
*/
public function checkLocalRedisCacheOfSite($site)
{
$site_root_folder = EE_SITE_ROOT . '/' . $site;
exec("cd $site_root_folder && docker-compose exec redis redis-cli set 'easyengine' 'rocks'");
$output = exec("cd $site_root_folder && docker-compose exec redis redis-cli get 'easyengine'");
if ( '"rocks"' !== $output ) {
throw new Exception("Local redis not working for $site site. Getting '$output' instead of 'rock'.");
}
exec("cd $site_root_folder && docker-compose exec redis redis-cli del 'easyengine'");
}

}
157 changes: 155 additions & 2 deletions features/site.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Feature: Site Command
usage: ee site
"""

Scenario: Check site create sub command is present
When I run 'bin/ee site create'
Then STDOUT should return exactly
"""
usage: ee site create <site-name> [--ssl=<value>] [--wildcard] [--type=<type>] [--skip-status-check]
"""

Scenario: Create wp site successfully
When I run 'bin/ee site create wp.test --type=wp'
Then After delay of 5 seconds
Expand All @@ -26,15 +33,15 @@ Feature: Site Command
| header |
| HTTP/1.1 200 OK |

Scenario: Create wp site successfully
Scenario: Create wp cache site successfully
When I run 'bin/ee site create wpcache.test --type=wp --cache'
Then After delay of 5 seconds
And The site 'wpcache.test' should have webroot
And The site 'wpcache.test' should have WordPress
And Request on 'wpcache.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |

Scenario: Create wpsubdir site successfully
When I run 'bin/ee site create wpsubdir.test --type=wp --mu=subdir'
And I create subsite '1' in 'wpsubdir.test'
Expand Down Expand Up @@ -67,6 +74,102 @@ Feature: Site Command
wpsubdom.test
"""

Scenario: Check site disable sub command is present
When I run 'bin/ee site disable'
Then STDERR should return something like
"""
Error: Could not find the site you wish to run site disable command on.
Either pass it as an argument: `ee site disable <site-name>`
or run `ee site disable` from inside the site folder.
"""

Scenario: Disable the site
When I run 'bin/ee site disable wp.test'
Then STDOUT should return exactly
"""
Disabling site wp.test.
Success: Site wp.test disabled.
"""
And Request on 'wp.test' should contain following headers:
| header |
| HTTP/1.1 503 Service Temporarily Unavailable |

Scenario: Check site reload sub command is present
When I run 'bin/ee site reload'
Then STDERR should return something like
"""
Error: Could not find the site you wish to run site reload command on.
Either pass it as an argument: `ee site reload <site-name>`
or run `ee site reload` from inside the site folder.
"""

Scenario: Reload site services
When I run 'bin/ee site reload wp.test'
Then STDERR should return something like
"""
Error: Site wp.test is not enabled. Use `ee site enable wp.test` to enable it.
"""

Scenario: Check site enable sub command is present
When I run 'bin/ee site enable'
Then STDERR should return something like
"""
Error: Could not find the site you wish to run site enable command on.
Either pass it as an argument: `ee site enable <site-name>`
or run `ee site enable` from inside the site folder.
"""

Scenario: Enable the site
When I run 'bin/ee site enable wp.test'
Then STDOUT should return exactly
"""
Enabling site wp.test.
Success: Site wp.test enabled.
Running post enable configurations.
Starting site's services.
Success: Post enable configurations complete.
"""
And Request on 'wp.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |

Scenario: Check site info sub command is present
When I run 'bin/ee site info'
Then STDERR should return something like
"""
Error: Could not find the site you wish to run site info command on.
Either pass it as an argument: `ee site info <site-name>`
or run `ee site info` from inside the site folder.
"""

Scenario: Details of the site uing site info command
When I run 'bin/ee site info wp.test'
Then STDOUT should return something like
"""
| Site | http://wp.test
"""

Scenario: Reload site services
When I run 'bin/ee site reload wp.test'
Then STDOUT should return something like
"""
Reloading nginx
"""

Scenario: Reload site nginx services
When I run 'bin/ee site reload wp.test --nginx'
Then STDOUT should return something like
"""
Reloading nginx
"""

Scenario: Check site delete sub command is present
When I run 'bin/ee site delete'
Then STDOUT should return exactly
"""
usage: ee site delete <site-name> [--yes]
"""

Scenario: Delete the sites
When I run 'bin/ee site delete wp.test --yes'
Then STDOUT should return something like
Expand All @@ -85,3 +188,53 @@ Feature: Site Command
| db |
| redis |
| phpmyadmin |

Scenario: Create WordPress site with local DB and global redis
When I run 'bin/ee site create wp-local-db.test --cache --type=wp --local-db'
Then After delay of 2 seconds
And The site 'wp-local-db.test' should have webroot
And The site 'wp-local-db.test' should have WordPress
And Request on 'wp-local-db.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |
And Check global redis cache for 'wp-local-db.test'

Scenario: Create WordPress site with local redis and global db
When I run 'bin/ee site create wp-local-redis.test --cache --type=wp --with-local-redis'
Then After delay of 2 seconds
And The site 'wp-local-redis.test' should have webroot
And The site 'wp-local-redis.test' should have WordPress
And Request on 'wp-local-redis.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |
And Check local redis cache for 'wp-local-redis.test'

Scenario: Create WordPress site with local DB and local redis
When I run 'bin/ee site create wp-local-db-redis.test --cache --type=wp --local-db --with-local-redis'
Then After delay of 2 seconds
And The site 'wp-local-db-redis.test' should have webroot
And The site 'wp-local-db-redis.test' should have WordPress
And Request on 'wp-local-db-redis.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |
And Check local redis cache for 'wp-local-db-redis.test'

Scenario: Create WordPress site with remote DB and local redis
When I run 'bin/ee site create wp-remote-db-local-redis.test --cache --type=wp --dbuser="root" --dbpass="" --dbhost="localhost" --with-local-redis'
Then After delay of 2 seconds
And The site 'wp-remote-db-local-redis.test' should have webroot
And The site 'wp-remote-db-local-redis.test' should have WordPress
And Request on 'wp-remote-db-local-redis.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |
And Check local redis cache for 'wp-remote-db-local-redis.test'

Scenario: Create WordPress site with remote DB and global redis
When I run 'bin/ee site create wp-remote-db-global-redis.test --cache --type=wp --dbuser="travis" --dbpass="" --dbhost="127.0.0.1"'
Then After delay of 2 seconds
And The site 'wp-remote-db-global-redis.test' should have webroot
And The site 'wp-remote-db-global-redis.test' should have WordPress
And Request on 'wp-remote-db-global-redis.test' should contain following headers:
| header |
| HTTP/1.1 200 OK |
And Check global redis cache for 'wp-remote-db-global-redis.test'