From fae5031a0fb14a795ba6c8787050d1db7f7f04ed Mon Sep 17 00:00:00 2001
From: gakin <gakin>
Date: Fri, 21 Apr 2017 14:33:01 +0000
Subject: [PATCH] SSDM-4584 : test_openbis_sync - find out the  the hash of
 last commit to download artifacts.

SVN: 38080
---
 integration-tests/test_openbis_sync.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/integration-tests/test_openbis_sync.py b/integration-tests/test_openbis_sync.py
index ee0269e0c50..798cdd19c37 100755
--- a/integration-tests/test_openbis_sync.py
+++ b/integration-tests/test_openbis_sync.py
@@ -8,6 +8,7 @@ import systemtest.testcase
 import systemtest.util as util
 import urllib, urllib2
 import ssl, base64
+import json
 
 from urllib2 import Request
 
@@ -16,6 +17,7 @@ from functools import wraps
 from systemtest.artifactrepository import GitArtifactRepository
 
 from systemtest.testcase import TEST_DATA
+from systemtest.util import printAndFlush
 
 #Had to add the ssl wrap thing below because of a problem during the auth call
 def sslwrap(func):
@@ -255,7 +257,8 @@ class TestCase(systemtest.testcase.TestCase):
         util.printAndFlush("path to core plugin in the repository: %s" % path)
         destination = "%s/servers/core-plugins/%s/" % (openbisController.installPath, openbisController.instanceName)
         util.printAndFlush("Unzipping plugin % s into folder %s"% (plugin_name, destination))
-        util.unzipSubfolder(path, 'OpenbisSync-master-c25365e4e2ff09203bbbb9286061c92f8d04df1e/core-plugins/%s/1/'% plugin_name, destination)
+        commit_id = self.getLatestCommitHashForCorePlugin('sissource.ethz.ch', 10)
+        util.unzipSubfolder(path, 'OpenbisSync-master-%s/core-plugins/%s/1/'% (commit_id, plugin_name), destination)
 
     def installDataSourcePlugin(self, openbisController, dss_port):
         self.installPlugin(openbisController, "datasource")
@@ -288,6 +291,13 @@ class TestCase(systemtest.testcase.TestCase):
     def getMasterDataScriptFolder(self):
         return systemtest.testcase.TEMPLATES + "/" + self.name + "/master_data"
     
+    def getLatestCommitHashForCorePlugin(self, host, project):
+        url = "https://%s/api/v4/projects/%s/repository/commits/master" % (host, project)
+        request = Request(url, headers = {'PRIVATE-TOKEN' : 'Rz1DbhpVBXSUpRny5Dbr'})
+        response = urllib2.urlopen(request)
+        result = json.load(response)
+        return result["id"]
+    
 class GitLabArtifactRepository(GitArtifactRepository):
     """
     Artifact repository for a gitlab projects.
-- 
GitLab