summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Rigby <john.rigby@linaro.org>2012-11-29 19:18:06 -0700
committerJohn Rigby <john.rigby@linaro.org>2012-11-29 19:18:06 -0700
commit096ff257f0de1fc08ef729aac680221ec7c6262f (patch)
treee1a6e129bc7031065274cc451637484fc1215234
Initial checkinHEADmaster
-rwxr-xr-xbrowser-test-lava.py142
1 files changed, 142 insertions, 0 deletions
diff --git a/browser-test-lava.py b/browser-test-lava.py
new file mode 100755
index 0000000..b656fb2
--- /dev/null
+++ b/browser-test-lava.py
@@ -0,0 +1,142 @@
+#!/usr/bin/python
+# based on post-build-lava.py
+
+import os
+import sys
+import json
+import xmlrpclib
+import urllib2
+import re
+
+def obfuscate_credentials(s):
+ return re.sub(r"([^ ]:).+?(@)", r"\1xxx\2", s)
+
+def main():
+ """Script entry point: return some JSON based on calling args.
+ We should be called from Jenkins and expect the following to be defined:
+ JOB_NAME
+ JOB_BUILD_NUMBER
+ DEVICE_TYPE
+ BUNDLE_STREAM_NAME, default:/private/team/linaro/developers-and-community-builds/
+ LAVA_USER
+ LAVA_TOKEN
+ LAVA_SERVER, default:validation.linaro.org/lava-server/RPC2/
+ IMAGE_TYPE, default:ubuntu-desktop
+ IMAGE_URL
+ """
+
+ # CI base URL
+ ci_base_url = "https://ci.linaro.org/jenkins/job/"
+ # Snapshots base URL
+ snapshots_url = "http://snapshots.linaro.org"
+
+ # Name of the hardware pack project
+ job_name = os.environ.get("JOB_NAME")
+ # The hardware pack build number
+ job_build_number = os.environ.get("JOB_BUILD_NUMBER")
+ # Device type
+ device_type = os.environ.get("DEVICE_TYPE", "Undefined")
+ if device_type == "Undefined":
+ sys.exit("Device type is not defined.")
+
+ image_type = os.environ.get("IMAGE_TYPE", "ubuntu-desktop")
+ image_url = os.environ.get("IMAGE_URL", "Undefined")
+ if image_url == "Undefined":
+ sys.exit("IMAGE_URL is not defined.")
+
+ distribution = 'precise'
+ architecture = 'armhf'
+ hwpack_type = "hwpack_type"
+
+ # Bundle stream name
+ bundle_stream_name = os.environ.get("BUNDLE_STREAM_NAME", \
+ "/private/team/linaro/developers-and-community-builds/")
+ # LAVA user
+ lava_user = os.environ.get("LAVA_USER")
+ if lava_user == None:
+ f = open('/var/run/lava/lava-user')
+ lava_user = f.read().strip()
+ f.close()
+ # LAVA token
+ lava_token = os.environ.get("LAVA_TOKEN")
+ if lava_token == None:
+ f = open('/var/run/lava/lava-token')
+ lava_token = f.read().strip()
+ f.close()
+ # LAVA server URL
+ lava_server = os.environ.get("LAVA_SERVER", \
+ "validation.linaro.org/lava-server/RPC2/")
+ # LAVA server base URL
+ lava_server_root = lava_server.rstrip("/")
+ if lava_server_root.endswith("/RPC2"):
+ lava_server_root = lava_server_root[:-len("/RPC2")]
+
+ actions = [
+ {
+ "command": "deploy_linaro_image",
+ "parameters": {
+ "image": "%s" % image_url,
+ },
+ "metadata": {
+ "ubuntu.image_type": "%s" % image_type,
+ },
+ },
+ {
+ "command": "boot_linaro_image",
+ },
+ {
+ "command": "lava_test_install",
+ "parameters": {
+ "tests": ["browser-benchmarks"]
+ },
+ },
+ {
+ "command": "lava_test_run",
+ "parameters": {
+ "test_name": "browser-benchmarks",
+ }
+ },
+ {
+ "command": "submit_results",
+ "parameters": {
+ "stream": bundle_stream_name,
+ "server": "%s%s" % ("http://", lava_server)
+ }
+ },
+ ]
+
+ config = json.dumps({"timeout": 18000,
+ "actions": actions,
+ "job_name": "%s%s/%s/" % (ci_base_url, \
+ job_name, \
+ job_build_number),
+ "device_type": device_type,
+ }, indent=2)
+
+ print config
+
+ skip_lava = os.environ.get("SKIP_LAVA")
+ if skip_lava == None:
+ try:
+ server_url = \
+ "https://{lava_user:>s}:{lava_token:>s}@{lava_server:>s}"
+ server = \
+ xmlrpclib.ServerProxy(server_url.format(\
+ lava_user=lava_user, \
+ lava_token=lava_token, \
+ lava_server=lava_server))
+ lava_job_id = server.scheduler.submit_job(config)
+ except xmlrpclib.ProtocolError, e:
+ print "Error making a LAVA request:", obfuscate_credentials(str(e))
+ sys.exit(1)
+
+ print "LAVA Job Id: %s, URL: http://%s/scheduler/job/%s" % \
+ (lava_job_id, lava_server_root, lava_job_id)
+ json.dump({'lava_url': "http://" + lava_server_root,
+ 'job_id': lava_job_id},
+ open('lava-job-info', 'w'))
+ else:
+ print "LAVA job submission skipped."
+
+if __name__ == "__main__":
+ main()