Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.
Merged
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
45 changes: 44 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"""

import os
import shutil
from ConfigParser import SafeConfigParser
from fabric.api import task, local
from fabric.api import task, local, lcd
from textwrap import dedent
from path import path
import requests
Expand All @@ -21,6 +22,13 @@
# Process timeout for test results
PROCESS_TIMEOUT = 600

# edx-platform git repo
# Used to install the page objects for edxapp
EDX_PLATFORM_REPO_NAME = "edx-platform"
EDX_PLATFORM_REPO_URL = "https://github.com/edx/edx-platform.git"
EDXAPP_PAGES_DIR = "common/test/bok_choy"
EDX_PLATFORM_VERSION = "659e590fc9386e17f36ffa0e59ac10fd08cb7635"


@task
def config_lms(**kwargs):
Expand Down Expand Up @@ -49,6 +57,41 @@ def config_mktg(**kwargs):
_set_config('mktg', kwargs)


@task
def install_pages(repo_dirname="/tmp"):
"""
Install page objects from external repos.

`repo_dirname` is the directory in which to clone the repos.
If a copy of the repo does not yet exist under this directory
then it will first be cloned there.

WARNING: This operation is NOT safe to run concurrently.
"""
try:

# Clone the repo and check out the commit
repo_path = os.path.join(repo_dirname, EDX_PLATFORM_REPO_NAME)
if not os.path.isdir(repo_path):
local(_cmd("git", "clone", EDX_PLATFORM_REPO_URL, repo_path))

with lcd(repo_path):
local(_cmd("git", "fetch"))
local(_cmd("git", "checkout", EDX_PLATFORM_VERSION))

# Install the page objects in the current virtualenv
with lcd(os.path.join(repo_path, EDXAPP_PAGES_DIR)):
local(_cmd("python", "setup.py", "install"))

# Fabric will fail-fast and exit if any of these commands fail
# This could leave the git repository in an unusable state
# Therefore, if we exit with a fatal error, assume that the git repository
# can no longer be trusted and delete it.
except SystemExit:
if os.path.isdir(repo_path):
shutil.rmtree(repo_path)


@task
def test():
"""
Expand Down
55 changes: 55 additions & 0 deletions jenkins/test_edxapp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

# Run end-to-end tests for edxapp and other services in Jenkins
# Assumes that the following environment variables are set:
#
# TEST_ENV_HOST: hostname to run the tests on (e.g. test.domain.org)
# Assumes that Studio is served from studio.$TEST_ENV_HOST
#
# BASIC_AUTH_USER and BASIC_AUTH_PASSWORD: basic auth credentials; can be blank
#
# REGISTRATION_EMAIL: email used to register for new courses (e.g. test@example.com)
#
# SSH_USER and SSH_KEYFILE: user and private key to ssh into the test server
#
# Optional: Saucelabs plugin may set additional environment variables,
# which are printed to make debugging easier

set -e

# Create the virtualenv and install requirements
mkdir -p venv
virtualenv venv
. venv/bin/activate
pip install -r requirements.txt

# Install edxapp page objects
# This operation is not safe to run concurrently,
# so ensure the jobs use unique directories
mkdir -p /mnt/tmp/${JOB_NAME}
fab install_pages:/mnt/tmp/${JOB_NAME}

# Debug information
echo "SELENIUM_BROWSER=$SELENIUM_BROWSER"
echo "SELENIUM_VERSION=$SELENIUM_VERSION"
echo "SELENIUM_PLATFORM=$SELENIUM_PLATFORM"

# Configure the test
fab config_lms:protocol=http
fab config_lms:test_host=$TEST_ENV_HOST
fab config_lms:basic_auth_user=$BASIC_AUTH_USER
fab config_lms:basic_auth_password=$BASIC_AUTH_PASSWORD
fab config_lms:registration_email=$REGISTRATION_EMAIL
fab config_lms:ssh_user=$SSH_USER
fab config_lms:ssh_keyfile=$SSH_KEYFILE

fab config_studio:protocol=http
fab config_studio:test_host=studio.$TEST_ENV_HOST
fab config_studio:basic_auth_user=$BASIC_AUTH_USER
fab config_studio:basic_auth_password=$BASIC_AUTH_PASSWORD
fab config_studio:ssh_user=$SSH_USER
fab config_studio:ssh_keyfile=$SSH_KEYFILE

# Run the tests
fab test_lms
fab test_studio
5 changes: 1 addition & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ requests==2.0.1
nose

# bok-choy framework
-e git+https://github.com/edx/bok-choy.git@69eb162b0bd1e8bf4c4c2d88bd1ea01930b32f3d#egg=bok_choy

# edx-platform page objects
-e git+https://github.com/edx/edx-platform.git@04e66be70589612b0e5ffb6c55465932ca930e8d#egg=edxapp_selenium_pages
-e git+https://github.com/edx/bok-choy.git@d276a2b508820651ae6e20266dc8e584f128bd3a#egg=bok_choy
4 changes: 2 additions & 2 deletions test_lms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from bok_choy.web_app_test import WebAppTest
from .fixtures import UserFixture
from edxapp_selenium_pages.lms.login import LoginPage
from edxapp_selenium_pages.lms.dashboard import DashboardPage
from edxapp_pages.lms.login import LoginPage
from edxapp_pages.lms.dashboard import DashboardPage


class LoggedInTest(WebAppTest):
Expand Down
22 changes: 11 additions & 11 deletions test_lms/test_lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
from credentials import TestCredentials
from fixtures import UserFixture

from edxapp_selenium_pages.lms.login import LoginPage
from edxapp_selenium_pages.lms.find_courses import FindCoursesPage
from edxapp_selenium_pages.lms.info import InfoPage
from edxapp_selenium_pages.lms.course_about import CourseAboutPage
from edxapp_selenium_pages.lms.register import RegisterPage
from edxapp_selenium_pages.lms.dashboard import DashboardPage
from edxapp_selenium_pages.lms.course_info import CourseInfoPage
from edxapp_selenium_pages.lms.tab_nav import TabNavPage
from edxapp_selenium_pages.lms.course_nav import CourseNavPage
from edxapp_selenium_pages.lms.progress import ProgressPage
from edxapp_selenium_pages.lms.video import VideoPage
from edxapp_pages.lms.login import LoginPage
from edxapp_pages.lms.find_courses import FindCoursesPage
from edxapp_pages.lms.info import InfoPage
from edxapp_pages.lms.course_about import CourseAboutPage
from edxapp_pages.lms.register import RegisterPage
from edxapp_pages.lms.dashboard import DashboardPage
from edxapp_pages.lms.course_info import CourseInfoPage
from edxapp_pages.lms.tab_nav import TabNavPage
from edxapp_pages.lms.course_nav import CourseNavPage
from edxapp_pages.lms.progress import ProgressPage
from edxapp_pages.lms.video import VideoPage

from .base import LoggedInTest

Expand Down
6 changes: 3 additions & 3 deletions test_lms/test_ora.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""

from .base import LoggedInTest
from edxapp_selenium_pages.lms.tab_nav import TabNavPage
from edxapp_selenium_pages.lms.course_nav import CourseNavPage
from edxapp_selenium_pages.lms.open_response import OpenResponsePage
from edxapp_pages.lms.tab_nav import TabNavPage
from edxapp_pages.lms.course_nav import CourseNavPage
from edxapp_pages.lms.open_response import OpenResponsePage


class OpenResponseTest(LoggedInTest):
Expand Down
6 changes: 3 additions & 3 deletions test_studio/test_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"""

from bok_choy.web_app_test import WebAppTest
from edxapp_selenium_pages.studio.login import LoginPage
from edxapp_selenium_pages.studio.howitworks import HowitworksPage
from edxapp_selenium_pages.studio.signup import SignupPage
from edxapp_pages.studio.login import LoginPage
from edxapp_pages.studio.howitworks import HowitworksPage
from edxapp_pages.studio.signup import SignupPage


class LoggedOutTest(WebAppTest):
Expand Down