diff --git a/.travis.yml b/.travis.yml index b2e4b9b..93579a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,8 +4,8 @@ sudo: required env: globaL: - - DOCKER_VERSION=1.11.2-0~trusty - - DOCKER_COMPOSE_VERSION=1.7.1 + - COMPOSE_HTTP_TIMEOUT=3600 + - AEGIR_HOSTING_VERSION=7.x-3.x #env: # - test: Ubuntu 14.04 Apache @@ -16,33 +16,42 @@ env: addons: hosts: - - aegir.travis - - sitetest.aegir.travis + - aegir.local.computer + - sitetest.aegir.local.computer services: - docker before_install: - # list docker-engine versions - - apt-cache madison docker-engine - # upgrade docker-engine to specific version - - sudo apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION} + - sudo bash travis/prepare-docker.sh + + # Get Provision + - git clone http://git.drupal.org/project/provision.git /home/travis/build/aegir-project/provision + - cd /home/travis/build/aegir-project/provision + - git checkout $AEGIR_HOSTING_VERSION + + # Get Hosting + - git clone http://git.drupal.org/project/hosting.git /home/travis/build/aegir-project/hosting + - cd /home/travis/build/aegir-project/hosting + - git checkout $AEGIR_HOSTING_VERSION - # reinstall docker-compose at specific version - - sudo rm /usr/local/bin/docker-compose - - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - - docker --version - - docker-compose --version + # Get Hostmaster + - git clone http://git.drupal.org/project/hostmaster.git /home/travis/build/aegir-project/hostmaster + - cd /home/travis/build/aegir-project/hostmaster + - git checkout $AEGIR_HOSTING_VERSION + - cd /home/travis/build/aegir-project/tests - sudo mkdir vendor - sudo chmod 777 vendor - sudo mkdir bin - sudo chmod 777 bin + - cd /home/travis/build/aegir-project/tests/travis + + - ls -la /home/travis/build/aegir-project/hostmaster + script: # The test run is included in the docker-entrypoint-tests.sh file. - - sudo docker-compose up --abort-on-container-exit + - sg - docker -c 'docker-compose run hostmaster --rm' diff --git a/behat.yml b/behat.yml index 7c8ba3f..d967c06 100644 --- a/behat.yml +++ b/behat.yml @@ -11,7 +11,7 @@ default: Behat\MinkExtension: goutte: ~ selenium2: ~ - base_url: http://aegir.docker + base_url: http://aegir.local.computer Drupal\DrupalExtension: blackbox: ~ api_driver: 'drush' diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 33d17ce..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: '2' - -services: - - hostmaster: - image: aegir/hostmaster - ports: - - 80:80 - hostname: aegir.docker - links: - - database - depends_on: - - database - entrypoint: - - docker-entrypoint-tests.sh - environment: - VIRTUAL_HOST: aegir.docker - MYSQL_ROOT_PASSWORD: strongpassword - tty: true - stdin_open: true - volumes: - - ./:/var/aegir/tests - - database: - image: mariadb - - # Disable logging for this container, for testing environment. - logging: - driver: "none" - environment: - MYSQL_ROOT_PASSWORD: strongpassword diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 684dd92..e73adf3 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -21,4 +21,27 @@ class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext public function __construct() { } + /** + * @AfterSuite + */ + public static function cleanAegir() { + exec('rm -rf /var/aegir/platforms/d6/sites/drupal6.local.computer'); + print "Removed /var/aegir/platforms/d6/sites/drupal6.local.computer"; + } + + /** + * @When I select the radio button with the label :label + * + * @TODO: Remove when PR is merged: https://github.com/jhedstrom/drupalextension/pull/302 + */ + public function assertSelectRadioByName($label) { + $element = $this->getSession()->getPage(); + + $radiobutton = $element->find('named', array('radio', $this->getSession()->getSelectorsHandler()->xpathLiteral($label))); + if ($radiobutton === NULL) { + throw new \Exception(sprintf('The radio button with the label "%s" was not found on the page %s', $label, $this->getSession()->getCurrentUrl())); + } + $value = $radiobutton->getAttribute('value'); + $radiobutton->selectOption($value, FALSE); + } } diff --git a/features/drupal6.feature b/features/drupal6.feature new file mode 100644 index 0000000..d942779 --- /dev/null +++ b/features/drupal6.feature @@ -0,0 +1,100 @@ +Feature: Host Drupal 6 + + + @api + Scenario: Create a Drupal 6 Site + 1. Create a drupal6 platform. + 2. Create a drupal6 site. + 3. Create a drupal7 platform. + 4. Migrate the site to the drupal7 platform. + + Given I am logged in as a user with the "administrator" role + And I click "Platforms" + Then I click "Add platform" + + Given I fill in "Name" with "drupal6platform" + And I fill in "Makefile" with "http://cgit.drupalcode.org/provision/plain/provision-tests/makes/drupal6.make" + And I fill in "Publish path" with "d6" + When I press "Save" + Then I should see "Verify task has been queued for platform drupal6platform. It will be available once the task is completed." + And I should see "Platform drupal6platform has been created." + And I should see "/var/aegir/platforms/d6" + And I should see "drupal6platform" + + When I run drush "hosting-tasks -v" + Then print last drush output + Then I reload the page + When I click "Add site" + Then I should see "Create Site" + + When I fill in "Domain name" with "drupal6.local.computer" + And I select the radio button "drupal6platform" + Then I press "Save" + And I should see "Site drupal6.local.computer has been created." + And I should see "drupal6.local.computer" + And I should see "Install" + And I should see "Queued" + And I should see the link "drupal6platform" + + When I run drush "hosting-tasks -v" + Then print last drush output + Then I reload the page + And I should see "Enabled" + + Given I click "Log in to drupal6.local.computer" + Then I should see "You have just used your one-time login link. It is no longer necessary to use this link to login. Please change your password." + And I should see the link "drupal6.local.computer" + + # Setup Drupal 7 platform + Given I am on the homepage + And I click "Platforms" + Then I click "Add platform" + + Given I fill in "Name" with "drupal7platform" + And I fill in "Makefile" with "http://cgit.drupalcode.org/provision/plain/provision-tests/makes/drupal7.make" + And I fill in "Publish path" with "d7" + When I press "Save" + Then I should see "Verify task has been queued for platform drupal7platform. It will be available once the task is completed." + And I should see "Platform drupal7platform has been created." + And I should see "/var/aegir/platforms/d7" + And I should see "drupal7platform" + + When I run drush "hosting-tasks -v" + Then print last drush output + Then I reload the page + Then I should see "Enabled" + + Then I click "Sites" + And I click "drupal6.local.computer" + + # Enable site migration module + Given I run drush "en hosting_migrate -y" + Then print last drush output + Then I reload the page + Then I click "Move the site to a new platform." + Then I select the radio button with the label "drupal7platform" + + Then I press "Migrate" + + When I run drush "hosting-tasks -v" + Then print last drush output + Then I reload the page + And I click "drupal7platform" + Then I should see "Sites installed on this platform" + And I should see "drupal6.local.computer" + + When I click "drupal6.local.computer" + When I click "Generate a one-time login reset url for this site." + And I run drush "hosting-tasks -y" + Then print last drush output + Then I reload the page + + Given I click "Log in to drupal6.local.computer" + # The drupal 7 message! + Then I should see "You have just used your one-time login link. It is no longer necessary to use this link to log in. Please change your password." + + Given I click "Administration" + Then I click "Reports" + Then I click "Status report" + Then I click "Status report" + Then I should see "7.50" diff --git a/features/ui.feature b/features/ui.feature index e06f00c..5f3e2bb 100644 --- a/features/ui.feature +++ b/features/ui.feature @@ -10,23 +10,22 @@ Feature: Aegir UI # When I run drush "@hostmaster hosting-tasks" Then I am logged in as a user with the "administrator" role And I am on the homepage - And I should see "aegir.docker" + And I should see "aegir.local.computer" Then I should see "Sites" - And I should see "Task queue" + When I click "aegir.local.computer" + Then I should see "Enabled" # Confirm all tasks verified. When I click "Tasks" - Then I should see "aegir.docker" in the ".hosting-success" element - - # Not sure why this fails - # And I should see "hostmaster" in the ".hosting-success" element - # And I should see "database" in the ".hosting-success" element + Then I should not see a ".hosting-error" element +# @TODO: We are throwing warnings on migrate to 7.50 because we +# Then I should not see a ".hosting-warning" element # Platforms Page When I click "Platforms" Then I should see "hostmaster" Then I should see "drupal" - Then I should see "aegir.docker" + Then I should see "aegir.local.computer" # Platforms table Then I should see "Platform" diff --git a/travis/README.md b/travis/README.md new file mode 100644 index 0000000..fe56b10 --- /dev/null +++ b/travis/README.md @@ -0,0 +1,7 @@ +# Using Travis for Aegir Testing + +There are many git repositories that make up aegir. In order to implement proper CI, we need all of them to trigger test runs. + +Using this repository, http://github.com/aegir-project/tests, each repo can use slightly different `.travis.yml` files to run the same suite of tests. + +We are working on making this even more streamlined, but for now, see `example.hostmaster.travis.yml` and `example.hosting.travis.yml` for examples on how to add Travis integration into your aegir module. \ No newline at end of file diff --git a/travis/build-hostmaster-local.make b/travis/build-hostmaster-local.make index 69e9866..e030e94 100644 --- a/travis/build-hostmaster-local.make +++ b/travis/build-hostmaster-local.make @@ -3,6 +3,23 @@ api = 2 projects[drupal][type] = "core" +# Travis docker-compose.yml puts hosting module at /source/hostmaster projects[hostmaster][type] = "profile" projects[hostmaster][download][type] = "copy" -projects[hostmaster][download][url] = "/var/aegir/hostmaster-source" +projects[hostmaster][download][url] = "/source/hostmaster" + +# Travis docker-compose.yml puts hosting module at /source/hosting +projects[hosting][type] = "module" +projects[hosting][subdir] = "aegir" +projects[hosting][download][type] = "copy" +projects[hosting][download][url] = "/source/hosting" + +# Copy modules from source +projects[source_modules][type] = "module" +projects[source_modules][download][type] = "copy" +projects[source_modules][download][url] = "/source/modules" + +# Copy modules from source +projects[source_themes][type] = "theme" +projects[source_themes][download][type] = "copy" +projects[source_themes][download][url] = "/source/themes" diff --git a/travis/docker-compose.yml b/travis/docker-compose.yml index 43618e2..de73ca0 100644 --- a/travis/docker-compose.yml +++ b/travis/docker-compose.yml @@ -3,10 +3,10 @@ version: '2' services: hostmaster: - image: aegir/hostmaster + image: aegir/hostmaster:local ports: - 80:80 - hostname: aegir.docker + hostname: aegir.local.computer links: - database depends_on: @@ -15,14 +15,22 @@ services: # See https://github.com/aegir-project/dockerfiles/blob/master/docker-entrypoint-tests.sh - docker-entrypoint-tests.sh environment: - VIRTUAL_HOST: aegir.docker + VIRTUAL_HOST: aegir.local.computer MYSQL_ROOT_PASSWORD: strongpassword AEGIR_MAKEFILE: /var/aegir/tests/travis/build-hostmaster-local.make tty: true stdin_open: true volumes: - ../:/var/aegir/tests - - /home/travis/build/aegir-project/hostmaster:/var/aegir/hostmaster-source + - /home/travis/build/aegir-project/hostmaster:/source/hostmaster + - /home/travis/build/aegir-project/hosting:/source/hosting + - /home/travis/build/aegir-project/provision:/source/provision + + # Project code Volumes. + # Individual projects need to copy their codebase into source/modules, source/themes or source/drush to be included in the images. + - /home/travis/build/aegir-project/source/modules:/source/modules + - /home/travis/build/aegir-project/source/themes:/source/themes + - /home/travis/build/aegir-project/source/drush:/source/drush database: image: mariadb @@ -32,3 +40,7 @@ services: driver: "none" environment: MYSQL_ROOT_PASSWORD: strongpassword + + # These options are needed for Drupal 7.50 and up for full UTF-8 support. + # See https://www.drupal.org/node/2754539 + command: mysqld --innodb-large-prefix --innodb-file-format=barracuda --innodb-file-per-table \ No newline at end of file diff --git a/travis/example.hosting.travis.yml b/travis/example.hosting.travis.yml new file mode 100644 index 0000000..8a92ce0 --- /dev/null +++ b/travis/example.hosting.travis.yml @@ -0,0 +1,68 @@ +language: generic + +sudo: required + +env: + globaL: + - DOCKER_VERSION=1.11.2-0~trusty + - DOCKER_COMPOSE_VERSION=1.7.1 + - AEGIR_HOSTING_VERSION=7.x-3.x + - AEGIR_TESTS_VERSION=source-path + +# @TODO: Create multiple environments to run tests across multiple OS. +# See https://github.com/opendevshop/devshop/blob/1.x/.travis.yml#L16 for an example. +#env: +# - test: Ubuntu 14.04 Apache +# distribution: ubuntu +# version: 14.04 +# init: /sbin/init +# run_opts: "" + +addons: + hosts: + - aegir.travis + - sitetest.aegir.travis + +services: + - docker + +before_install: + # Show travis build dir variable. + - echo $TRAVIS_BUILD_DIR + + # Get Hosting + # The aegir-project/tests suite expects hosting and hostmaster to be + # available locally, at /home/travis/build/aegir-project/hostmaster and + # /home/travis/build/aegir-project/hosting + - git clone http://git.drupal.org/project/hosting.git /home/travis/build/aegir-project/hosting + - cd /home/travis/build/aegir-project/hosting + - git checkout $AEGIR_HOSTING_VERSION + + # Get test scripts + - git clone http://github.com/aegir-project/tests.git /home/travis/build/aegir-project/tests + - cd /home/travis/build/aegir-project/tests + - git checkout $AEGIR_TESTS_VERSION + + # list docker-engine versions + - apt-cache madison docker-engine + + # upgrade docker-engine to specific version + - sudo apt-get -qq -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION} + + # reinstall docker-compose at specific version + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + - docker --version + - docker-compose --version + + # Get aegir/hostmaster and database images. + - sudo docker pull aegir/hostmaster + - sudo docker pull mariadb + +script: + + # Tests are included in the docker-compose.yml file in the tests repo. + # There is a separate docker entrypoint script named `docker-entrypoint-tests.sh` that runs the containers and the tests in a single process. This is needed to fully automate the tests. + - sudo docker-compose run hostmaster --rm diff --git a/travis/example.hostmaster.travis.yml b/travis/example.hostmaster.travis.yml new file mode 100644 index 0000000..c836ab3 --- /dev/null +++ b/travis/example.hostmaster.travis.yml @@ -0,0 +1,70 @@ +language: generic + +sudo: required + +env: + globaL: + - DOCKER_VERSION=1.11.2-0~trusty + - DOCKER_COMPOSE_VERSION=1.7.1 + - AEGIR_HOSTING_VERSION=7.x-3.x + - AEGIR_TESTS_VERSION=source-path + +# @TODO: Create multiple environments to run tests across multiple OS. +# See https://github.com/opendevshop/devshop/blob/1.x/.travis.yml#L16 for an example. +#env: +# - test: Ubuntu 14.04 Apache +# distribution: ubuntu +# version: 14.04 +# init: /sbin/init +# run_opts: "" + +addons: + hosts: + - aegir.travis + - sitetest.aegir.travis + +services: + - docker + +before_install: + # Show travis build dir variable. + - echo $TRAVIS_BUILD_DIR + + # Get Hosting + # The aegir-project/tests suite expects hosting and hostmaster to be + # available locally, at /home/travis/build/aegir-project/hostmaster and + # /home/travis/build/aegir-project/hosting + - git clone http://git.drupal.org/project/hosting.git /home/travis/build/aegir-project/hosting + - cd /home/travis/build/aegir-project/hosting + - git checkout $AEGIR_HOSTING_VERSION + + # This is hostmaster's travis, so /home/travis/build/aegir-project/hostmaster is already present. + + # Get test scripts + - git clone http://github.com/aegir-project/tests.git /home/travis/build/aegir-project/tests + - cd /home/travis/build/aegir-project/tests + - git checkout $AEGIR_TESTS_VERSION + + # list docker-engine versions + - apt-cache madison docker-engine + + # upgrade docker-engine to specific version + - sudo apt-get -qq -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION} + + # reinstall docker-compose at specific version + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + - docker --version + - docker-compose --version + + # Get aegir/hostmaster and database images. + - sudo docker pull aegir/hostmaster + - sudo docker pull mariadb + +script: + + # Tests are included in the docker-compose.yml file in the tests repo. + # There is a separate docker entrypoint script named `docker-entrypoint-tests.sh` that runs the containers and the tests in a single process. This is needed to fully automate the tests. + - sudo docker-compose run hostmaster --rm diff --git a/travis/prepare-docker.sh b/travis/prepare-docker.sh new file mode 100644 index 0000000..3670402 --- /dev/null +++ b/travis/prepare-docker.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# Run this script in your .travis.yml file to upgrade docker. + +DOCKER_VERSION=1.12.0-0~trusty +DOCKER_COMPOSE_VERSION=1.8.0 + +# Use this to get list of versions +# apt-cache madison docker-engine + +apt-get -o Dpkg::Options::="--force-confnew" install -y docker-engine=${DOCKER_VERSION} -qq + +# reinstall docker-compose at specific version +rm /usr/local/bin/docker-compose +curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose +chmod +x docker-compose +mv docker-compose /usr/local/bin +docker --version +docker-compose --version + +echo "Adding user travis to docker group..." +usermod -aG docker travis + +# Prepare local docker container +# @TODO: This is really a pain. Travis is always 1000, standard for ubuntu. +# I can build a local container locally with the Dockerfile-local, but it's not working on travis. +# So instead, I created a docker aegir/hostmaster:local image on docker hub. +#USER_UID=`id -u travis` +#echo "Preparing local aegir container for UID $USER_UID" + +# Get Dockerfile +# wget https://raw.githubusercontent.com/aegir-project/dockerfiles/master/Dockerfile-local + +# Run Docker build +# docker build --build-arg AEGIR_UID=1000 -t aegir/hostmaster:local -f Dockerfile-local .