Skip to content
Snippets Groups Projects
Commit be66e5d1 authored by gakin's avatar gakin
Browse files

SSDM-4197 : Integration test openbis_sync. Implement installDataSourcePlugin....

SSDM-4197 : Integration test openbis_sync. Implement installDataSourcePlugin. Extend GitArtifactRepository and use hardcoded project id and private token as an intermediate solution.

SVN: 37154
parent 8e9a6058
No related branches found
No related tags found
No related merge requests found
#!/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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment