[node-patches] Change in ovirt-node[master]: tests: Add annotation convenience function

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Sep 14 10:13:53 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: tests: Add annotation convenience function
......................................................................

tests: Add annotation convenience function

Each test step can be annotated

Change-Id: Ia97f0b9887718f1ed824bb117203d54b81caa8ef
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M tests/igor/libs/common/common.py
1 file changed, 15 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/03/8003/1

diff --git a/tests/igor/libs/common/common.py b/tests/igor/libs/common/common.py
index 699b766..dbc0057 100644
--- a/tests/igor/libs/common/common.py
+++ b/tests/igor/libs/common/common.py
@@ -89,6 +89,13 @@
   api_call("jobs/{session}/step/{step}/failed".format(session=igor.session, \
                                                      step=igor.current_step))
 
+def annotate_step(annotation):
+  debug("Adding annotation to current step: '%s'" % annotation)
+  url = api_url("jobs/{session}/step/current/annotate".format(
+                                                        session=igor.session))
+  __put_data(url, annotation)
+
+
 def add_artifact(dst, filename):
   if not os.path.exists(filename):
     raise Exception(("Failed to add artifact '%s', because file '%s' does " + \
@@ -100,12 +107,7 @@
                                                         dst=dst))
 
   data = open(filename, "rb").read()
-
-  opener = urllib2.build_opener(urllib2.HTTPHandler)
-  request = urllib2.Request(url, data=data)
-  request.add_header('Content-Type', 'text/plain')
-  request.get_method = lambda: 'PUT'
-  resp = opener.open(request)
+  __put_data(url, data)
 
 
 def touch(filename, comment=""):
@@ -113,6 +115,13 @@
     f.write(comment)
 
 
+def __put_data(url, data):
+  opener = urllib2.build_opener(urllib2.HTTPHandler)
+  request = urllib2.Request(url, data=data)
+  request.add_header('Content-Type', 'text/plain')
+  request.get_method = lambda: 'PUT'
+  resp = opener.open(request)
+
 def quit_testing():
   """This function ends the looping through all testcases, this is needed for
   e.g. reboots


--
To view, visit http://gerrit.ovirt.org/8003
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia97f0b9887718f1ed824bb117203d54b81caa8ef
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list