diff --git a/integration-tests/test_openbis_sync.py b/integration-tests/test_openbis_sync.py index f8f9100de1c6c9eeb466fd0b4b4de46fce15406a..7adc6e299c6f7f78c523c1589cc054b5a7fd1e52 100755 --- a/integration-tests/test_openbis_sync.py +++ b/integration-tests/test_openbis_sync.py @@ -1,9 +1,16 @@ #!/usr/bin/python +# encoding=utf8 import os import shutil import settings import systemtest.testcase import systemtest.util as util +import urllib2 + +from urllib2 import Request + +from systemtest.artifactrepository import GitArtifactRepository + from systemtest.testcase import TEST_DATA class TestCase(systemtest.testcase.TestCase): @@ -20,10 +27,38 @@ class TestCase(systemtest.testcase.TestCase): def executeInDevMode(self): openbis_datasource = self.createOpenbisController(instanceName = 'openbis1', dropDatabases=False) + self.installDataSourcePlugin(openbis_datasource) + corePluginsPropertiesFile = "%s/servers/core-plugins/core-plugins.properties" % openbis_datasource.installPath + util.printAndFlush(corePluginsPropertiesFile) + #util.writeProperties(corePluginsPropertiesFile) openbis_datasource.allDown() openbis_datasource.setDataStoreServerUsername('etlserver') openbis_datasource.allUp() - client = self.installScreeningTestClient() - client.run() + + def installDataSourcePlugin(self, openbisController): + repository = GitLabArtifactRepository(self.artifactRepository.localRepositoryFolder) + path = repository.getPathToArtifact('149', 'archive.zip') + util.printAndFlush("path to core plugin in the repository: %s" % path) + destination = "%s/servers/core-plugins/openbis1/" % openbisController.installPath + util.unzipSubfolder(path, 'openbissync.git/core-plugins/openbis-sync/1/', destination) + +class GitLabArtifactRepository(GitArtifactRepository): + """ + Artifact repository for a gitlab projects. + Note: it requires project id as the project "argument". This can be found by using the following command: + curl --header "PRIVATE-TOKEN: 2iwhxKbfe62ES8JWAKsG" "https://ssdmsource.ethz.ch/api/v3/projects?per_page=99999" + after logging in and retrieving the private token with + curl https://ssdmsource.ethz.ch/api/v3/session --data-urlencode 'login=’ --data-urlencode 'password=’ + """ + def __init__(self, localRepositoryFolder, host = 'ssdmsource.ethz.ch'): + GitArtifactRepository.__init__(self, localRepositoryFolder) + self.host = host + def downloadArtifact(self, project, pattern): + url = "https://%s/api/v3/projects/%s/repository/%s" % (self.host, project, pattern) + util.printAndFlush("Download %s to %s." % (url, self.localRepositoryFolder)) + request = Request(url, headers = {'PRIVATE-TOKEN' : '2iwhxKbfe62ES8JWAKsG'}) + self._download(urllib2.urlopen(request), pattern) + return pattern + TestCase(settings, __file__).runTest() \ No newline at end of file