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

Commit

Permalink
Create separate config files for daily and l10n tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whimboo committed Jan 4, 2012
1 parent e7102d5 commit 9ee67a0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
15 changes: 15 additions & 0 deletions config/example_daily.cfg
@@ -0,0 +1,15 @@
{
"jenkins": {
"url": "http://localhost:8080",
"username": "mozilla",
"password": "test1234"
},
"pulse": {
"applabel": "qa-auto@mozilla.com|mozmill_daily",
"routing_key_regex": "build\\..+(-l10n)?-nightly\\.\\d+\\.finished",
"platforms": ["macosx", "macosx64"],
"branches": ["mozilla-central", "mozilla-aurora", "mozilla-1.9.2"],
"products": ["firefox"],
"locales": ["de", "en-US", "ja"]
}
}
15 changes: 15 additions & 0 deletions config/example_l10n.cfg
@@ -0,0 +1,15 @@
{
"jenkins": {
"url": "http://localhost:8080",
"username": "mozilla",
"password": "test1234"
},
"pulse": {
"applabel": "qa-auto@mozilla.com|mozmill_l10n",
"routing_key_regex": "build\\..+-l10n-dep\\.\\d+\\.finished",
"platforms": ["macosx", "macosx64"],
"branches": ["mozilla-central", "mozilla-aurora"],
"products": ["firefox"],
"locales": ["de", "pl"]
}
}
52 changes: 28 additions & 24 deletions pulse.py
Expand Up @@ -47,23 +47,6 @@
from mozillapulse import consumers


# Configuration settings which have to be moved out of the script
config = {
'jenkins': {
'url': 'http://localhost:8080',
'username': 'mozilla',
'password': 'test1234',
},
'pulse': {
'routing_key_regex': r'build\..+(-l10n)?-nightly\.\d+\.finished',
'branches': ['mozilla-central', 'mozilla-aurora', 'mozilla-1.9.2'],
'locales': ['de', 'en-US', 'ja'],
'platforms': ['macosx', 'macosx64'],
'products': ['firefox'],
}
}


# Map to translate platform ids from Pulse to Mozmill / Firefox
PLATFORM_MAP = {'linux': 'linux',
'linux-debug': 'linux',
Expand All @@ -80,10 +63,18 @@


# Globally shared variables
config = None
debug = False
log_folder = None


class NotFoundException(Exception):
"""Exception for a resource not being found (e.g. no logs)"""
def __init__(self, message, location):
self.location = location
Exception.__init__(self, ': '.join([message, location]))


def handle_notification(data, message):
routing_key = data['_meta']['routing_key']

Expand Down Expand Up @@ -161,7 +152,19 @@ def handle_notification(data, message):
'BUILD_ID': props.get('buildid')})


def read_json_file(filename):
if not os.path.isfile(filename):
raise NotFoundException('Specified file cannot be found.', filename)

try:
f = open(filename, 'r')
return json.loads(f.read())
finally:
f.close()


def main():
global config
global debug
global log_folder

Expand All @@ -179,20 +182,21 @@ def main():
help='Log file of a Pulse message to process for Jenkins')
options, args = parser.parse_args()

if not len(args):
parser.error('A configuration file has to be passed in as first argument.')

config = read_json_file(args[0])
debug = options.debug
log_folder = options.log_folder

# Initialize Pulse connection
pulse = consumers.BuildConsumer(applabel='qa-auto@mozilla.com|daily_testrun')
pulse = consumers.BuildConsumer(applabel=config['pulse']['applabel'])
pulse.configure(topic='#', callback=handle_notification)
print "Connected to Mozilla Pulse. Listening for notifications..."

if options.message:
try:
f = open(options.message, 'r')
data = json.loads(f.read())
handle_notification(data, None)
finally:
f.close()
data = read_json_file(options.message)
handle_notification(data, None)
else:
while True:
try:
Expand Down

0 comments on commit 9ee67a0

Please sign in to comment.