Commit 625a17d5 authored by Xavier Thompson's avatar Xavier Thompson

software/*: Adapt tests to slapproxy upgrade

parent cc5a223b
...@@ -158,20 +158,12 @@ class TestJupyterPassword(InstanceTestCase): ...@@ -158,20 +158,12 @@ class TestJupyterPassword(InstanceTestCase):
) )
class SelectMixin(object): class Database(object):
def sqlite3_connect(self): def __init__(self, db_path):
sqlitedb_file = os.path.join( self.db = db_path
os.path.abspath(
os.path.join(
self.slap.instance_directory, os.pardir
)
), 'var', 'proxy.db'
)
return sqlite3.connect(sqlitedb_file)
def select(self, fields, table, where={}):
connection = self.sqlite3_connect()
def execute(self, query, *args):
connection = sqlite3.connect(self.db)
def dict_factory(cursor, row): def dict_factory(cursor, row):
d = {} d = {}
for idx, col in enumerate(cursor.description): for idx, col in enumerate(cursor.description):
...@@ -179,20 +171,11 @@ class SelectMixin(object): ...@@ -179,20 +171,11 @@ class SelectMixin(object):
return d return d
connection.row_factory = dict_factory connection.row_factory = dict_factory
cursor = connection.cursor() cursor = connection.cursor()
cursor.execute(query, args)
condition = " AND ".join("%s='%s'" % (k, v) for k, v in where.items())
cursor.execute(
"SELECT %s FROM %s%s"
% (
", ".join(fields),
table,
" WHERE %s" % condition if where else "",
)
)
return cursor.fetchall() return cursor.fetchall()
class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase): class TestJupyterCustomFrontend(InstanceTestCase):
instance_parameter_dict = {} instance_parameter_dict = {}
frontend_software_url = 'hello://frontend.url' frontend_software_url = 'hello://frontend.url'
frontend_software_type = 'hello-type' frontend_software_type = 'hello-type'
...@@ -226,7 +209,9 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase): ...@@ -226,7 +209,9 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase):
except Exception: except Exception:
pass pass
selection = self.select(fields=["*"], table = "slave14", where = {"hosted_by": r._partition_id}) runner_directory = os.path.abspath(os.path.join(self.slap.instance_directory, os.pardir))
db = Database(os.path.join(runner_directory, 'var', 'proxy.db'))
selection = db.execute('SELECT * FROM slave15 WHERE hosted_by=?', r._partition_id)
self.assertEqual(len(selection), 1) self.assertEqual(len(selection), 1)
...@@ -234,7 +219,7 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase): ...@@ -234,7 +219,7 @@ class TestJupyterCustomFrontend(SelectMixin, InstanceTestCase):
r.destroyed() r.destroyed()
class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase): class TestJupyterCustomAdditional(InstanceTestCase):
instance_parameter_dict = {} instance_parameter_dict = {}
frontend_additional_software_url = 'hello://frontend.url' frontend_additional_software_url = 'hello://frontend.url'
frontend_additional_software_type = 'hello-type' frontend_additional_software_type = 'hello-type'
...@@ -268,7 +253,9 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase): ...@@ -268,7 +253,9 @@ class TestJupyterCustomAdditional(SelectMixin, InstanceTestCase):
except Exception: except Exception:
pass pass
selection = self.select(fields=["*"], table = "slave14", where = {"hosted_by": r._partition_id}) runner_directory = os.path.abspath(os.path.join(self.slap.instance_directory, os.pardir))
db = Database(os.path.join(runner_directory, 'var', 'proxy.db'))
selection = db.execute('SELECT * FROM slave15 WHERE hosted_by=?', r._partition_id)
self.assertEqual(len(selection), 1) self.assertEqual(len(selection), 1)
......
...@@ -212,7 +212,7 @@ class MonitorAccessMixin(object): ...@@ -212,7 +212,7 @@ class MonitorAccessMixin(object):
cursor.execute( cursor.execute(
"SELECT reference, xml, connection_xml, partition_reference, " "SELECT reference, xml, connection_xml, partition_reference, "
"software_release, requested_state, software_type " "software_release, requested_state, software_type "
"FROM partition14 " "FROM partition15 "
"WHERE slap_state='busy'") "WHERE slap_state='busy'")
return cursor.fetchall() return cursor.fetchall()
......
...@@ -181,8 +181,8 @@ setup = ${slapos-repository:location}/software/jscrawler/test/ ...@@ -181,8 +181,8 @@ setup = ${slapos-repository:location}/software/jscrawler/test/
[slapos.core-repository] [slapos.core-repository]
<= git-clone-repository <= git-clone-repository
repository = https://lab.nexedi.com/nexedi/slapos.core.git repository = https://lab.nexedi.com/xavier_thompson/slapos.core.git
branch = master branch = proxy_root_path_migrate
[slapos.test.caucase-setup] [slapos.test.caucase-setup]
<= setup-develop-egg <= setup-develop-egg
......
...@@ -20,6 +20,10 @@ extends = ...@@ -20,6 +20,10 @@ extends =
./buildout.hash.cfg ./buildout.hash.cfg
parts = parts =
# >>>>>>>>>>>>
# Use unreleased version of slapos.core
slapos.core-dev
# <<<<<<<<<<<<
theia-wrapper theia-wrapper
slapos-cookbook slapos-cookbook
instance instance
...@@ -27,6 +31,24 @@ parts = ...@@ -27,6 +31,24 @@ parts =
# default for slapos-standalone # default for slapos-standalone
shared-part-list = shared-part-list =
# >>>>>>>>>>>>
# Use unreleased version of slapos.core
[slapos.core-repository]
recipe = slapos.recipe.build:gitclone
repository = https://lab.nexedi.com/xavier_thompson/slapos.core.git
branch = proxy_root_path_migrate
git-executable = ${git:location}/bin/git
develop = true
[slapos.core-dev]
recipe = zc.recipe.egg:develop
egg = slapos.core
setup = ${slapos.core-repository:location}
[versions]
slapos.core =
# <<<<<<<<<<<<
# We keep the gcc part in sync with the one from erp5 software, so that when we install # We keep the gcc part in sync with the one from erp5 software, so that when we install
# erp5 inside theia's slapos parts can be shared. # erp5 inside theia's slapos parts can be shared.
[gcc] [gcc]
...@@ -97,6 +119,7 @@ initialization = ...@@ -97,6 +119,7 @@ initialization =
software_root="%s/software" % args.base_directory, software_root="%s/software" % args.base_directory,
instance_root="%s/instance" % args.base_directory, instance_root="%s/instance" % args.base_directory,
partition_forward_configuration=partition_forward_configuration, partition_forward_configuration=partition_forward_configuration,
slapos_bin="${buildout:bin-directory}/slapos",
) )
standalone.start() standalone.start()
partition_count = 20 partition_count = 20
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment