From e66b4a66b4847596a5aed34469c310ad3bc75bc9 Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Mon, 9 Jun 2014 17:22:31 -0400 Subject: [PATCH] Move Jenkins scripts into `scripts` directory with symlinks for backwards compatibility --- jenkins/acceptance.sh | 78 +---------------------- jenkins/all-tests.sh | 122 +----------------------------------- scripts/acceptance-tests.sh | 77 +++++++++++++++++++++++ scripts/all-tests.sh | 121 +++++++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+), 198 deletions(-) mode change 100755 => 120000 jenkins/acceptance.sh mode change 100755 => 120000 jenkins/all-tests.sh create mode 100755 scripts/acceptance-tests.sh create mode 100755 scripts/all-tests.sh diff --git a/jenkins/acceptance.sh b/jenkins/acceptance.sh deleted file mode 100755 index 0df24ebbda..0000000000 --- a/jenkins/acceptance.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash -set -e - -############################################################################### -# -# edx-acceptance.sh -# -# Execute acceptance tests for edx-platform. -# -# This script can be called from a Jenkins -# job that defines these environment variables: -# -# `TEST_SUITE` defines which acceptance test suite to run -# Possible values are: -# -# - "lms": Run the acceptance (Selenium) tests for the LMS -# - "cms": Run the acceptance (Selenium) tests for Studio -# -# `FEATURE_PATH` is the path to the lettuce .feature file -# containing the tests to run. If empty, run all the tests. -# -# Other assumptions: -# -# - The edx-platform git repository is checked out by the Jenkins git plugin. -# -# - Jenkins logs in as user "jenkins" -# -# - The Jenkins file system root is "/home/jenkins" -# -# - An init script creates a virtualenv at "/home/jenkins/edx-venv" -# with some requirements pre-installed (such as scipy) -# -# Jenkins worker setup: -# See the edx/configuration repo for Jenkins worker provisioning scripts. -# The provisioning scripts install requirements that this script depends on! -# -############################################################################### - -source $HOME/jenkins_env - -# Clean up previous builds -git clean -qxfd - -# Clear the mongo database -# Note that this prevents us from running jobs in parallel on a single worker. -mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})' - -# Ensure we have fetched origin/master -# Some of the reporting tools compare the checked out branch to origin/master; -# depending on how the GitHub plugin refspec is configured, this may -# not already be fetched. -git fetch origin master:refs/remotes/origin/master - -# Reset the jenkins worker's ruby environment back to -# the state it was in when the instance was spun up. -if [ -e $HOME/edx-rbenv_clean.tar.gz ]; then - rm -rf $HOME/.rbenv - tar -C $HOME -xf $HOME/edx-rbenv_clean.tar.gz -fi - -# Bootstrap Ruby requirements so we can run the tests -bundle install - -# Ensure the Ruby environment contains no stray gems -bundle clean --force - -# Reset the jenkins worker's virtualenv back to the -# state it was in when the instance was spun up. -if [ -e $HOME/edx-venv_clean.tar.gz ]; then - rm -rf $HOME/edx-venv - tar -C $HOME -xf $HOME/edx-venv_clean.tar.gz -fi - -# Activate the Python virtualenv -source $HOME/edx-venv/bin/activate - -rake test:acceptance:${TEST_SUITE}["-v 3 ${FEATURE_PATH}"] diff --git a/jenkins/acceptance.sh b/jenkins/acceptance.sh new file mode 120000 index 0000000000..be9e8badac --- /dev/null +++ b/jenkins/acceptance.sh @@ -0,0 +1 @@ +../scripts/acceptance-tests.sh \ No newline at end of file diff --git a/jenkins/all-tests.sh b/jenkins/all-tests.sh deleted file mode 100755 index afce8b7ad1..0000000000 --- a/jenkins/all-tests.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/env bash -set -e - -############################################################################### -# -# edx-all-tests.sh -# -# Execute all tests for edx-platform. -# -# This script can be called from a Jenkins -# multiconfiguration job that defines these environment -# variables: -# -# `TEST_SUITE` defines which kind of test to run. -# Possible values are: -# -# - "quality": Run the quality (pep8/pylint) checks -# - "unit": Run the JavaScript and Python unit tests -# (also tests building the Sphinx documentation, -# because we couldn't think of a better place to put it) -# - "lms-acceptance": Run the acceptance (Selenium) tests for the LMS -# - "cms-acceptance": Run the acceptance (Selenium) tests for Studio -# - "bok-choy": Run acceptance tests that use the bok-choy framework -# -# `SHARD` is a number (1, 2, or 3) indicating which subset of the tests -# to build. Currently, "lms-acceptance" has two shards (1 and 2), -# "cms-acceptance" has three shards (1, 2, and 3), and all the -# other test suites have one shard. -# -# Jenkins configuration: -# -# - The edx-platform git repository is checked out by the Jenkins git plugin. -# -# - Jenkins logs in as user "jenkins" -# -# - The Jenkins file system root is "/home/jenkins" -# -# - An init script creates a virtualenv at "/home/jenkins/edx-venv" -# with some requirements pre-installed (such as scipy) -# -# Jenkins worker setup: -# See the edx/configuration repo for Jenkins worker provisioning scripts. -# The provisioning scripts install requirements that this script depends on! -# -############################################################################### - -source $HOME/jenkins_env - -# Clean up previous builds -git clean -qxfd - -# Clear the mongo database -# Note that this prevents us from running jobs in parallel on a single worker. -mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})' - -# Ensure we have fetched origin/master -# Some of the reporting tools compare the checked out branch to origin/master; -# depending on how the GitHub plugin refspec is configured, this may -# not already be fetched. -git fetch origin master:refs/remotes/origin/master - -# Reset the jenkins worker's ruby environment back to -# the state it was in when the instance was spun up. -if [ -e $HOME/edx-rbenv_clean.tar.gz ]; then - rm -rf $HOME/.rbenv - tar -C $HOME -xf $HOME/edx-rbenv_clean.tar.gz -fi - -# Bootstrap Ruby requirements so we can run the tests -bundle install - -# Ensure the Ruby environment contains no stray gems -bundle clean --force - -# Reset the jenkins worker's virtualenv back to the -# state it was in when the instance was spun up. -if [ -e $HOME/edx-venv_clean.tar.gz ]; then - rm -rf $HOME/edx-venv - tar -C $HOME -xf $HOME/edx-venv_clean.tar.gz -fi - -# Activate the Python virtualenv -source $HOME/edx-venv/bin/activate - -case "$TEST_SUITE" in - - "quality") - rake pep8 > pep8.log || { cat pep8.log ; exit 1; } - rake pylint > pylint.log || { cat pylint.log; exit 1; } - rake quality - - # Need to create an empty test result so the post-build - # action doesn't fail the build. - mkdir -p reports - cat > reports/quality.xml < - - - -END - ;; - - "unit") - rake test - rake coverage - ;; - - "lms-acceptance") - rake test:acceptance:lms["-v 3 --tag shard_${SHARD}"] - ;; - - "cms-acceptance") - rake test:acceptance:cms["-v 3 --tag shard_${SHARD}"] - ;; - - "bok-choy") - rake test:bok_choy - rake test:bok_choy:coverage - ;; - -esac diff --git a/jenkins/all-tests.sh b/jenkins/all-tests.sh new file mode 120000 index 0000000000..29c7d4c2a9 --- /dev/null +++ b/jenkins/all-tests.sh @@ -0,0 +1 @@ +../scripts/all-tests.sh \ No newline at end of file diff --git a/scripts/acceptance-tests.sh b/scripts/acceptance-tests.sh new file mode 100755 index 0000000000..0df24ebbda --- /dev/null +++ b/scripts/acceptance-tests.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +set -e + +############################################################################### +# +# edx-acceptance.sh +# +# Execute acceptance tests for edx-platform. +# +# This script can be called from a Jenkins +# job that defines these environment variables: +# +# `TEST_SUITE` defines which acceptance test suite to run +# Possible values are: +# +# - "lms": Run the acceptance (Selenium) tests for the LMS +# - "cms": Run the acceptance (Selenium) tests for Studio +# +# `FEATURE_PATH` is the path to the lettuce .feature file +# containing the tests to run. If empty, run all the tests. +# +# Other assumptions: +# +# - The edx-platform git repository is checked out by the Jenkins git plugin. +# +# - Jenkins logs in as user "jenkins" +# +# - The Jenkins file system root is "/home/jenkins" +# +# - An init script creates a virtualenv at "/home/jenkins/edx-venv" +# with some requirements pre-installed (such as scipy) +# +# Jenkins worker setup: +# See the edx/configuration repo for Jenkins worker provisioning scripts. +# The provisioning scripts install requirements that this script depends on! +# +############################################################################### + +source $HOME/jenkins_env + +# Clean up previous builds +git clean -qxfd + +# Clear the mongo database +# Note that this prevents us from running jobs in parallel on a single worker. +mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})' + +# Ensure we have fetched origin/master +# Some of the reporting tools compare the checked out branch to origin/master; +# depending on how the GitHub plugin refspec is configured, this may +# not already be fetched. +git fetch origin master:refs/remotes/origin/master + +# Reset the jenkins worker's ruby environment back to +# the state it was in when the instance was spun up. +if [ -e $HOME/edx-rbenv_clean.tar.gz ]; then + rm -rf $HOME/.rbenv + tar -C $HOME -xf $HOME/edx-rbenv_clean.tar.gz +fi + +# Bootstrap Ruby requirements so we can run the tests +bundle install + +# Ensure the Ruby environment contains no stray gems +bundle clean --force + +# Reset the jenkins worker's virtualenv back to the +# state it was in when the instance was spun up. +if [ -e $HOME/edx-venv_clean.tar.gz ]; then + rm -rf $HOME/edx-venv + tar -C $HOME -xf $HOME/edx-venv_clean.tar.gz +fi + +# Activate the Python virtualenv +source $HOME/edx-venv/bin/activate + +rake test:acceptance:${TEST_SUITE}["-v 3 ${FEATURE_PATH}"] diff --git a/scripts/all-tests.sh b/scripts/all-tests.sh new file mode 100755 index 0000000000..afce8b7ad1 --- /dev/null +++ b/scripts/all-tests.sh @@ -0,0 +1,121 @@ +#!/usr/bin/env bash +set -e + +############################################################################### +# +# edx-all-tests.sh +# +# Execute all tests for edx-platform. +# +# This script can be called from a Jenkins +# multiconfiguration job that defines these environment +# variables: +# +# `TEST_SUITE` defines which kind of test to run. +# Possible values are: +# +# - "quality": Run the quality (pep8/pylint) checks +# - "unit": Run the JavaScript and Python unit tests +# (also tests building the Sphinx documentation, +# because we couldn't think of a better place to put it) +# - "lms-acceptance": Run the acceptance (Selenium) tests for the LMS +# - "cms-acceptance": Run the acceptance (Selenium) tests for Studio +# - "bok-choy": Run acceptance tests that use the bok-choy framework +# +# `SHARD` is a number (1, 2, or 3) indicating which subset of the tests +# to build. Currently, "lms-acceptance" has two shards (1 and 2), +# "cms-acceptance" has three shards (1, 2, and 3), and all the +# other test suites have one shard. +# +# Jenkins configuration: +# +# - The edx-platform git repository is checked out by the Jenkins git plugin. +# +# - Jenkins logs in as user "jenkins" +# +# - The Jenkins file system root is "/home/jenkins" +# +# - An init script creates a virtualenv at "/home/jenkins/edx-venv" +# with some requirements pre-installed (such as scipy) +# +# Jenkins worker setup: +# See the edx/configuration repo for Jenkins worker provisioning scripts. +# The provisioning scripts install requirements that this script depends on! +# +############################################################################### + +source $HOME/jenkins_env + +# Clean up previous builds +git clean -qxfd + +# Clear the mongo database +# Note that this prevents us from running jobs in parallel on a single worker. +mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})' + +# Ensure we have fetched origin/master +# Some of the reporting tools compare the checked out branch to origin/master; +# depending on how the GitHub plugin refspec is configured, this may +# not already be fetched. +git fetch origin master:refs/remotes/origin/master + +# Reset the jenkins worker's ruby environment back to +# the state it was in when the instance was spun up. +if [ -e $HOME/edx-rbenv_clean.tar.gz ]; then + rm -rf $HOME/.rbenv + tar -C $HOME -xf $HOME/edx-rbenv_clean.tar.gz +fi + +# Bootstrap Ruby requirements so we can run the tests +bundle install + +# Ensure the Ruby environment contains no stray gems +bundle clean --force + +# Reset the jenkins worker's virtualenv back to the +# state it was in when the instance was spun up. +if [ -e $HOME/edx-venv_clean.tar.gz ]; then + rm -rf $HOME/edx-venv + tar -C $HOME -xf $HOME/edx-venv_clean.tar.gz +fi + +# Activate the Python virtualenv +source $HOME/edx-venv/bin/activate + +case "$TEST_SUITE" in + + "quality") + rake pep8 > pep8.log || { cat pep8.log ; exit 1; } + rake pylint > pylint.log || { cat pylint.log; exit 1; } + rake quality + + # Need to create an empty test result so the post-build + # action doesn't fail the build. + mkdir -p reports + cat > reports/quality.xml < + + + +END + ;; + + "unit") + rake test + rake coverage + ;; + + "lms-acceptance") + rake test:acceptance:lms["-v 3 --tag shard_${SHARD}"] + ;; + + "cms-acceptance") + rake test:acceptance:cms["-v 3 --tag shard_${SHARD}"] + ;; + + "bok-choy") + rake test:bok_choy + rake test:bok_choy:coverage + ;; + +esac