Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
bug 692091 - mozharness code for peptest. p=ahal, r=me
Browse files Browse the repository at this point in the history
  • Loading branch information
escapewindow committed Nov 5, 2011
1 parent e9eead4 commit 4e7318c
Show file tree
Hide file tree
Showing 6 changed files with 543 additions and 3 deletions.
52 changes: 52 additions & 0 deletions configs/peptest/prod_config.py
@@ -0,0 +1,52 @@
# This is a template config file for peptest production

# The peptest mozharness script is set up so that specifying None
# is the same as not specifying the option at all
import os

config = {
# mozharness script options
"base_work_dir": os.getcwd(),
"work_dir": "build",
"log_name": "pep",
"log_level": "info",
"test_url": "url_to_packaged_tests",
# path or url to a zip or folder containing the mozbase packages
"mozbase_path": "url_to_mozbase_zip",
# path or url to a zip or folder containing peptest
"peptest_path": "url_to_peptest_zip",

# peptest options
"appname": "url_to_application", # i.e the firefox build on ftp.m.o
# defaults to firefox, can also be thunderbird, fennec, etc.
"app": "firefox",
# if test_url is specified, this should be the relative
# path to the manifest inside the extracted test directory
# otherwise, should be path to a test manifest on the local file system
"test_manifest": "path_to_test_manifest",
# optional, use an existing profile (temp profile created by default)
"profile_path": None,
# global timeout in seconds (without output)
"timeout": 60,
# if specified, creates a webserver for hosting test
# related files at this document root
"server_path": None,
"server_port": None,
# EventTracer setting, the threshold to count a failure (ms)
"tracer_threshold": 50,
# EventTracer setting, interval at which to send tracer events (ms)
"tracer_interval": 10,
# URL or path to the symbols directory for debugging crashes
"symbols_path": None,
}

# these config options depend on the abs_work_dir option
abs_work_dir = os.path.abspath(os.path.join(config['base_work_dir'],
config['work_dir']))

config['virtualenv_path'] = os.path.join(abs_work_dir, "venv")
# directory to extract tests to
config['test_install_dir'] = os.path.join(abs_work_dir, "tests")
# directory to install application to
config['application_install_dir'] = os.path.join(abs_work_dir,
"application")
37 changes: 37 additions & 0 deletions configs/peptest/test_config.py
@@ -0,0 +1,37 @@
import os

config = {
# mozharness script options
"base_work_dir": os.getcwd(),
"work_dir": "build",
"log_name": "pep",
"log_level": "info",
"test_url": "https://github.com/downloads/ahal/peptest/tests.zip",
"mozbase_path": "https://github.com/mozilla/mozbase/zipball/master",
"peptest_path": "https://github.com/mozilla/peptest/zipball/master",

# peptest options
"appname": "ftp://ftp.mozilla.org/pub/firefox/nightly/latest-mozilla-central/firefox-10.0a1.en-US.linux-i686.tar.bz2",
"app": "firefox",
"test_manifest": "firefox/all_tests.ini", # this is relative to the test folder specified by test_url
"profile_path": None,
"timeout": 60,
"server_path": None,
"server_port": None,
"tracer_threshold": 50,
"tracer_interval": 10,
"symbols_path": None,

# get latest tinderbox options
"get_latest_tinderbox_product": "mozilla-central",
"get_latest_tinderbox_platform": None,
"get_latest_tinderbox_debug_build": False,
}

abs_work_dir = os.path.abspath(os.path.join(config['base_work_dir'],
config['work_dir']))

config['virtualenv_path'] = os.path.join(abs_work_dir, "venv")
config['test_install_dir'] = os.path.join(abs_work_dir, "tests")
config['application_install_dir'] = os.path.join(abs_work_dir,
"application")
56 changes: 56 additions & 0 deletions configs/peptest/user_config.py
@@ -0,0 +1,56 @@
# This is a template config file for peptest user

# The peptest mozharness script is set up so that specifying None
# is the same as not specifying the option at all
import os

config = {
# mozharness script options
"base_work_dir": os.getcwd(),
"work_dir": "build",
"log_name": "pep",
"log_level": "info",
"test_url": "url_to_packaged_tests",
# path or url to a zip or folder containing the mozbase packages
"mozbase_path": "url_to_mozbase_zip",
# path or url to a zip or folder containing peptest
"peptest_path": "url_to_peptest_zip",

# peptest options

"appname": "path_to_application_binary",
# defaults to firefox, can also be thunderbird, fennec, etc.
"app": "firefox",
"test_manifest": "path_to_test_manifest",
# optional, use an existing profile (temp profile created by default)
"profile_path": None,
# global timeout in seconds (without output)
"timeout": 60,
# if specified, creates a webserver for hosting test
# related files at this document root
"server_path": None,
"server_port": None,
# EventTracer setting, the threshold to count a failure (ms)
"tracer_threshold": 50,
# EventTracer setting, interval at which to send tracer events (ms)
"tracer_interval": 10,
# URL or path to the symbols directory for debugging crashes
"symbols_path": None,

# get latest tinderbox options
# (these are only used by the get-latest-tinderbox action)
"get_latest_tinderbox_product": "mozilla-central",
"get_latest_tinderbox_platform": None, # defaults to current platform
"get_latest_tinderbox_debug_build": False,
}

# these config options depend on the abs_work_dir option
abs_work_dir = os.path.abspath(os.path.join(config['base_work_dir'],
config['work_dir']))

config['virtualenv_path'] = os.path.join(abs_work_dir, "venv")
# directory to extract tests to
config['test_install_dir'] = os.path.join(abs_work_dir, "tests")
# directory to install application to
config['application_install_dir'] = os.path.join(abs_work_dir,
"application")
21 changes: 20 additions & 1 deletion mozharness/base/python.py
Expand Up @@ -61,12 +61,14 @@ class VirtualenvMixin(object):
* virtualenv_modules lists the module names. * virtualenv_modules lists the module names.
* MODULE_url list points to the module URLs (optional) * MODULE_url list points to the module URLs (optional)
Requires virtualenv to be in PATH. Requires virtualenv to be in PATH.
Depends on OSMixin
''' '''
python_paths = {} python_paths = {}


def query_python_path(self, binary="python"): def query_python_path(self, binary="python"):
"""Return the path of a binary inside the virtualenv, if """Return the path of a binary inside the virtualenv, if
c['virtualenv_path'] is set; otherwise return the binary name. c['virtualenv_path'] is set; otherwise return the binary name.
Otherwise return None
""" """
if binary not in self.python_paths: if binary not in self.python_paths:
bin_dir = 'bin' bin_dir = 'bin'
Expand All @@ -76,7 +78,24 @@ def query_python_path(self, binary="python"):
self.python_paths[binary] = os.path.abspath(os.path.join(self.config['virtualenv_path'], bin_dir, binary)) self.python_paths[binary] = os.path.abspath(os.path.join(self.config['virtualenv_path'], bin_dir, binary))
else: else:
self.python_paths[binary] = binary self.python_paths[binary] = binary
return self.python_paths[binary] return self.which(self.python_paths[binary])

def query_package(self, package_name, error_level=WARNING):
"""
Returns a list of all installed packages
that contain package_name in their name
"""
pip = self.query_python_path("pip")
if not pip:
self.log("query_package: Program pip not in path", level=error_level)
return []
output = self.get_output_from_command(pip + " freeze",
silent=True)
if not output:
return []
packages = output.split()
return [package for package in packages
if package.lower().find(package_name.lower()) != -1]


def create_virtualenv(self): def create_virtualenv(self):
c = self.config c = self.config
Expand Down
27 changes: 25 additions & 2 deletions mozharness/base/script.py
Expand Up @@ -73,7 +73,7 @@
class OSMixin(object): class OSMixin(object):
"""Filesystem commands and the like. """Filesystem commands and the like.
Currently dependent on LogMixin, and a self.config of some sort. Depends on LogMixin, ShellMixin, and a self.config of some sort.
""" """
def mkdir_p(self, path): def mkdir_p(self, path):
if not os.path.exists(path): if not os.path.exists(path):
Expand Down Expand Up @@ -161,7 +161,7 @@ def download_file(self, url, file_name=None,
try: try:
self.info("Downloading %s" % url) self.info("Downloading %s" % url)
f = urllib2.urlopen(req) f = urllib2.urlopen(req)
local_file = open(file_name, 'w') local_file = open(file_name, 'wb')
local_file.write(f.read()) local_file.write(f.read())
local_file.close() local_file.close()
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
Expand Down Expand Up @@ -258,6 +258,29 @@ def chdir(self, dir_name, ignore_if_noop=False):
else: else:
os.chdir(dir_name) os.chdir(dir_name)


def which(self, program):
"""
OS independent implementation of Unix's which command
Takes in a program name
Returns path to executable or None
"""
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

if self._is_windows() and not program.endswith(".exe"):
program += ".exe"
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
env = self.query_env()
for path in env["PATH"].split(os.pathsep):
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None

# ShellMixin {{{1 # ShellMixin {{{1
class ShellMixin(object): class ShellMixin(object):
"""These are very special but very complex methods that, together with """These are very special but very complex methods that, together with
Expand Down

0 comments on commit 4e7318c

Please sign in to comment.