Skip to content
This repository has been archived by the owner on May 24, 2023. It is now read-only.

Hosting git tests #15

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ default:
blackbox: ~
api_driver: 'drupal'
drupal:
# We do not include root here because then we cannot override it on the command line.
# drupal_root: /var/aegir/hostmaster-7.x-1.x

# This should eventually be un-hardcoded and put into the script triggering the tests, currently https://github.com/aegir-project/dockerfiles/blob/master/run-tests.sh
# Aegir needs a Robofile or a CLI command for running tests, so this is more automated.
# See https://github.com/opendevshop/devshop/blob/1.x/src/DevShop/Command/DevmasterTest.php#L45
drupal_root: /var/aegir/hostmaster
drush:
alias: '@hostmaster'
43 changes: 41 additions & 2 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
<?php

use Drupal\DrupalExtension\Context\RawDrupalContext;
use Drupal\DrupalExtension\Context\DrushContext;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;

/**
* Defines application features from the specific context.
*/
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
class FeatureContext extends DrushContext implements SnippetAcceptingContext {


/**
* Make MinkContext available.
* @var \Drupal\DrupalExtension\Context\MinkContext
*/
private $minkContext;

/**
* Prepare Contexts.
* @BeforeScenario
*/
public function gatherContexts(BeforeScenarioScope $scope)
{
$environment = $scope->getEnvironment();
$this->minkContext = $environment->getContext('Drupal\DrupalExtension\Context\MinkContext');
}

/**
* Log output and watchdog logs after any failed step.
* @AfterStep
*/
public function logAfterFailedStep($event)
{
if ($event->getTestResult()->getResultCode() === \Behat\Testwork\Tester\Result\TestResult::FAILED) {

// Print Current URL and Last reponse after any step failure.
echo "Step Failed.";

echo "\nLasts Response:\n";
$this->minkContext->printLastResponse();

echo "\nWatchdog Errors:\n";
$this->assertDrushCommand('wd-show');
$this->printLastDrushOutput();

}
}

/**
* Initializes context.
Expand Down
161 changes: 161 additions & 0 deletions features/git.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
Feature: Hosting Git
In order to easily deploy sites from git repos
As an aegir user
I need to enable and configure the hosting git module.

@api
Scenario: Enable and configure Hosting Git module.
Given I am logged in as a user with the "administrator" role
And I am at "admin/hosting"
Then I check the box "Git integration"
And I press "Save configuration"
Then I should see "The configuration options have been saved."

Then I run drush "hosting-tasks --force --fork=0 --strict=0"

Given I am at "admin/hosting/git"
Then I should see "Git Hooks"
And I should see "Allow deploying sites from git repositories."
And I should see "Allow deploying platforms from git repositories."

When I uncheck the box "Allow deploying sites from git repositories."
When I uncheck the box "Allow deploying platforms from git repositories."

When I uncheck the box "Allow platforms to have configurable git hooks."
When I uncheck the box "Allow sites to have configurable git hooks."

And I check the box "Run database updates"
And I check the box "Flush all caches"
And I check the box "Rebuild Registry"

Then I press "Save configuration"
Then I should see "The configuration options have been saved."

Given I am on "node/add/platform"
Then I should not see "Deploy from Git"
Then I should not see "Git Hooks"
And I should not see "Git Pull Method"

Given I am on "node/add/site"
Then I should not see "Deploy from Git"
Then I should not see "Git Hooks"
And I should not see "Git Pull Method"

Given I am at "admin/hosting/git"
Then I should see "Git Hooks"
And I should see "Allow deploying sites from git repositories."
And I should see "Allow deploying platforms from git repositories."

When I check the box "Allow deploying sites from git repositories."
When I check the box "Allow deploying platforms from git repositories."

When I check the box "Allow platforms to have configurable git hooks."
When I check the box "Allow sites to have configurable git hooks."
Then I press "Save configuration"
Then I should see "The configuration options have been saved."

# CREATE PLATFORM
Given I am on "node/add/platform"
Then I should see "Deploy from Git"
Then I should see "Git Hooks"

And the "Run database updates" checkbox should be checked
And the "Flush all caches" checkbox should be checked
And the "Rebuild Registry" checkbox should be checked

And I should see "Git Pull Method"

When I fill in "Repository URL" with "https://github.com/aegir-project/example-drupal.git"
And I fill in "Name" with "example-drupal"
And I fill in "edit-publish-path" with "example-drupal"
And I select the radio button with the label "Automatic Git Pull"

Then I press "Save"
And print current URL
Then I should see "Verified never"
Then I run drush "hosting-tasks --force --fork=0 --strict=0"
Then I reload the page
Then I should not see "Verified never"
And I should see "Verify Platform" in the ".hosting-success" element
And I should see "Git reference master"
And I should see "Git URL https://github.com/aegir-project/example-drupal.git"
And I should see "Git repository path /var/aegir/platforms/example-drupal"
And I should not see "Git repository docroot"

# EDIT PLATFORM
When I click "Edit"
And I uncheck the box "Run database updates"
And I uncheck the box "Flush all caches"
And I uncheck the box "Rebuild Registry"
And I press "Save"
Then I run drush "hosting-tasks --force --fork=0 --strict=0"
Then I reload the page
And I should see "Git reference master"
And I should see "Git URL https://github.com/aegir-project/example-drupal.git"
And I should see "Git repository path /var/aegir/platforms/example-drupal"
And I should not see "Git repository docroot"

# CREATE composer PLATFORM
Given I am on "node/add/platform"
Then I should see "Deploy from Git"
Then I should see "Git Hooks"

When I fill in "Repository URL" with "https://github.com/aegir-project/example-drupal-composer.git"
And I fill in "Name" with "drupalcomposer"
And I fill in "Repository docroot" with "web"
And I fill in "edit-publish-path" with "drupalcomposer"

Then I press "Save"
And print current URL
Then I should see "Verified never"
Then I run drush "hosting-tasks --force --fork=0 --strict=0"
Then I reload the page
Then I should not see "Verified never"
And I should see "Verify Platform" in the ".hosting-success" element
And I should see "Git reference master"
And I should see "Git URL https://github.com/aegir-project/example-drupal-composer.git"
And I should see "Git repository path /var/aegir/platforms/drupalcomposer"
And I should see "Git repository docroot web"

# EDIT composer PLATFORM
When I click "Edit"
And I press "Save"
And print current URL
Then I should not see "Git repository path /var/aegir/platforms/drupalcomposer/web"
Then I run drush "hosting-tasks --force --fork=0 --strict=0"
Then I reload the page
And I should see "Git reference master"
And I should see "Git URL https://github.com/aegir-project/example-drupal-composer.git"
And I should see "Git repository docroot web"
And I should see "Verify Platform" in the ".hosting-success" element

# Add site
When I click "Add site"
Then I should see "Deploy from Git"
Then I should see "Git Hooks"

And the "Run database updates" checkbox should be checked
And the "Flush all caches" checkbox should be checked
And I fill in "Domain name" with "drupalcomposertest.local.computer"
And I fill in "Repository URL" with "http://github.com/aegir-project/example-site-repo.git"

And I uncheck the box "Run database updates"
And I uncheck the box "Flush all caches"
And I uncheck the box "Rebuild Registry"
And I select the radio button with the label "Manual Git Pull"

And I press "Save"
And print current URL

Then I should see "Site drupalcomposertest.local.computer has been created."
And I should not see "Flush all caches, Rebuild Registry, Run database updates"
And I should see "Git reference master"
And I should see "Git URL http://github.com/aegir-project/example-site-repo.git"

Then I run drush "hosting-tasks --force --fork=0 --strict=0"
Then I reload the page

And I should see "Install" in the ".hosting-success" element


# TODO: Go to settings, disable git, go back to site and ensure it is not showing git info.
2 changes: 1 addition & 1 deletion travis/prepare-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Run this script in your .travis.yml file to upgrade docker.
# Docker is now 1.12.0 by default on Travis.
# DOCKER_VERSION=1.12.0-0~trusty
DOCKER_COMPOSE_VERSION=1.8.0
DOCKER_COMPOSE_VERSION=1.16.1

# Use this to get list of versions
# apt-cache madison docker-engine
Expand Down