From 1314a2ecf534398f71f5e4010ccb36f86a1d4d4c Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 27 Nov 2015 13:20:07 +0000 Subject: [PATCH 01/11] Add omego dump, optionally parse db properties from config.xml --- omego/db.py | 87 ++++++++++++++++++++++++++++++++++++++--------- omego/env.py | 3 ++ omego/external.py | 23 ++++++++++++- 3 files changed, 96 insertions(+), 17 deletions(-) diff --git a/omego/db.py b/omego/db.py index c138d73..d4a43b3 100644 --- a/omego/db.py +++ b/omego/db.py @@ -10,7 +10,7 @@ import fileutils from external import External, RunException from yaclifw.framework import Command, Stop -from env import EnvDefault, DbParser +from env import DbParser log = logging.getLogger("omego.db") @@ -30,17 +30,15 @@ def __init__(self, dir, command, args, external): if not os.path.exists(dir): raise Exception("%s does not exist!" % dir) + self.external = external + psqlv = self.psql('--version') log.info('psql version: %s', psqlv) - self.external = external - self.check_connection() - if command == 'init': - self.initialise() - elif command == 'upgrade': - self.upgrade() + if command in ('init', 'upgrade', 'dump'): + getattr(self, command)() else: raise Stop('Invalid db command: %s', command) @@ -161,23 +159,79 @@ def get_current_db_version(self): log.info('Current omero db version: %s', v) return v - def psql(self, *psqlargs): + def dump(self): """ - Run a psql command + Dump the database using the postgres custom format """ - if not self.args.dbname: + dumpfile = self.args.dumpfile + if not dumpfile: + db, env = self.get_db_args_env() + dumpfile = fileutils.timestamp_filename( + 'omero-database-%s' % db['name'], 'pgdump') + + log.info('Dumping database to %s', dumpfile) + if not self.args.dry_run: + self.pgdump('-Fc', '-f', dumpfile) + + def get_db_args_env(self): + """ + Get a dictionary of database connection parameters, and create an + environment for running postgres commands. + Falls back to omego defaults. + """ + db = { + 'name': self.args.dbname, + 'host': self.args.dbhost, + 'user': self.args.dbuser, + 'pass': self.args.dbpass + } + + if self.args.use_db_config: + c = self.external.get_config() + for k in db: + try: + db[k] = c['omero.db.%s' % k] + except KeyError: + log.info( + 'Failed to lookup parameter omero.db.%s, using %s', + k, db[k]) + + if not db['name']: raise Exception('Database name required') env = os.environ.copy() - env['PGPASSWORD'] = self.args.dbpass - args = ['-d', self.args.dbname, '-h', self.args.dbhost, '-U', - self.args.dbuser, '-w', '-A', '-t'] + list(psqlargs) + env['PGPASSWORD'] = db['pass'] + return db, env + + def psql(self, *psqlargs): + """ + Run a psql command + """ + db, env = self.get_db_args_env() + + args = ['-d', db['name'], '-h', db['host'], '-U', db['user'], + '-w', '-A', '-t'] + list(psqlargs) stdout, stderr = External.run('psql', args, capturestd=True, env=env) if stderr: log.warn('stderr: %s', stderr) log.debug('stdout: %s', stdout) return stdout + def pgdump(self, *pgdumpargs): + """ + Run a pg_dump command + """ + db, env = self.get_db_args_env() + + args = ['-d', db['name'], '-h', db['host'], '-U', db['user'], '-w' + ] + list(pgdumpargs) + stdout, stderr = External.run( + 'pg_dump', args, capturestd=True, env=env) + if stderr: + log.warn('stderr: %s', stderr) + log.debug('stdout: %s', stdout) + return stdout + class DbCommand(Command): """ @@ -192,13 +246,14 @@ def __init__(self, sub_parsers): self.parser = DbParser(self.parser) self.parser.add_argument("-n", "--dry-run", action="store_true") - Add = EnvDefault.add # TODO: Kind of duplicates Upgrade args.sym/args.server - Add(self.parser, 'serverdir', 'Root directory of the server') + self.parser.add_argument( + '--serverdir', help='Root directory of the server') self.parser.add_argument( "dbcommand", - choices=['init', 'upgrade'], + choices=['init', 'upgrade', 'dump'], help='Initialise or upgrade a database') + self.parser.add_argument('--dumpfile', help='Database dump file') def __call__(self, args): super(DbCommand, self).__call__(args) diff --git a/omego/env.py b/omego/env.py index 936474d..f305c67 100644 --- a/omego/env.py +++ b/omego/env.py @@ -86,6 +86,9 @@ def __init__(self, parser): help="Username for connecting to the OMERO database") Add(group, "dbpass", "omero", help="Password for connecting to the OMERO database") + group.add_argument( + "--use-db-config", action="store_true", + help="Get the database settings from omero config") # TODO Admin credentials: dbauser, dbapass Add(group, "omerosql", None, diff --git a/omego/external.py b/omego/external.py index 12d8bc5..ad83ffe 100644 --- a/omego/external.py +++ b/omego/external.py @@ -49,6 +49,8 @@ def __init__(self, dir=None): if dir: self.set_server_dir(dir) + self._omero = None + def set_server_dir(self, dir): """ Set the directory of the server to be controlled @@ -68,13 +70,31 @@ def has_config(self): raise Exception('No server directory set') return self.configured + def get_config(self): + """ + Returns a dictionary of all config.xml properties + + setup_omero_cli() must be called before this method to import the + correct omero module to minimise the possibility of version conflicts + """ + if not self.has_config: + raise Exception('No config file') + + c = self._omero.config.ConfigXml(os.path.join( + self.dir, 'etc', 'grid', 'config.xml'), + exclusive=False, read_only=True) + try: + return c.as_map() + finally: + c.close() + def setup_omero_cli(self): """ Imports the omero CLI module so that commands can be run directly. Note Python does not allow a module to be imported multiple times, so this will only work with a single omero instance. - This can have several surprisingly effects, so setup_omero_cli() + This can have several surprising effects, so setup_omero_cli() must be explcitly called. """ if not self.dir: @@ -96,6 +116,7 @@ def setup_omero_cli(self): self.cli = omero.cli.CLI() self.cli.loadplugins() + self._omero = omero def setup_previous_omero_env(self, olddir, savevarsfile): """ From ce5d95aca585efb2513a76ebc1e63b4074740bb1 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 27 Nov 2015 16:42:05 +0000 Subject: [PATCH 02/11] Add unit tests for pgdump() --- test/unit/test_db.py | 105 ++++++++++++++++++++++++++++++++----- test/unit/test_external.py | 3 ++ 2 files changed, 94 insertions(+), 14 deletions(-) diff --git a/test/unit/test_db.py b/test/unit/test_db.py index 7903630..6b48e7b 100644 --- a/test/unit/test_db.py +++ b/test/unit/test_db.py @@ -203,28 +203,105 @@ def test_get_current_db_version(self): assert db.get_current_db_version() == ('OMERO4.4', '0') self.mox.VerifyAll() + @pytest.mark.parametrize('dumpfile', ['test.pgdump', None]) + @pytest.mark.parametrize('dryrun', [True, False]) + def test_dump(self, dumpfile, dryrun): + args = self.Args({'dry_run': dryrun, 'dumpfile': dumpfile}) + db = self.PartialMockDb(args, None) + self.mox.StubOutWithMock(omego.fileutils, 'timestamp_filename') + self.mox.StubOutWithMock(db, 'get_db_args_env') + self.mox.StubOutWithMock(db, 'pgdump') + + if not dumpfile: + db.get_db_args_env().AndReturn(self.create_db_test_params()) + + dumpfile = 'omero-database-name-00000000-000000-000000.pgdump' + omego.fileutils.timestamp_filename( + 'omero-database-name', 'pgdump').AndReturn(dumpfile) + + if not dryrun: + db.pgdump('-Fc', '-f', dumpfile).AndReturn('') + + self.mox.ReplayAll() + + db.dump() + self.mox.VerifyAll() + + def create_db_test_params(self, prefix=''): + db = { + 'name': '%sname' % prefix, + 'host': '%shost' % prefix, + 'user': '%suser' % prefix, + 'pass': '%spass' % prefix, + } + env = {'PGPASSWORD': '%spass' % prefix} + return db, env + @pytest.mark.parametrize('dbname', ['name', '']) - def test_psql(self, dbname): + @pytest.mark.parametrize('useconfig', [True, False]) + def test_get_db_args_env(self, dbname, useconfig): + ext = self.mox.CreateMock(External) args = self.Args({'dbhost': 'host', 'dbname': dbname, - 'dbuser': 'user', 'dbpass': 'pass'}) - + 'dbuser': 'user', 'dbpass': 'pass', + 'use_db_config': useconfig}) + db = self.PartialMockDb(args, ext) + self.mox.StubOutWithMock(db.external, 'get_config') self.mox.StubOutWithMock(os.environ, 'copy') - self.mox.StubOutWithMock(External, 'run') - if dbname: - os.environ.copy().AndReturn({'PGPASSWORD': 'incorrect'}) - psqlargs = ['-d', dbname, '-h', 'host', '-U', 'user', - '-w', '-A', '-t', 'arg1', 'arg2'] - External.run('psql', psqlargs, capturestd=True, - env={'PGPASSWORD': 'pass'}).AndReturn(('', '')) - self.mox.ReplayAll() + if useconfig: + expecteddb, expectedenv = self.create_db_test_params('ext') + else: + expecteddb, expectedenv = self.create_db_test_params() - db = self.PartialMockDb(args, None) + if useconfig: + cfg = { + 'omero.db.host': 'exthost', + 'omero.db.user': 'extuser', + 'omero.db.pass': 'extpass', + } + if dbname: + cfg['omero.db.name'] = 'extname' + + db.external.get_config().AndReturn(cfg) + + os.environ.copy().AndReturn({'PGPASSWORD': 'incorrect'}) + + self.mox.ReplayAll() if dbname: - db.psql('arg1', 'arg2') + rcfg, renv = db.get_db_args_env() + assert rcfg == expecteddb + assert renv == expectedenv else: with pytest.raises(Exception) as excinfo: - db.psql('arg1', 'arg2') + db.get_db_args_env() assert str(excinfo.value) == 'Database name required' + def test_psql(self): + db = self.PartialMockDb(None, None) + self.mox.StubOutWithMock(db, 'get_db_args_env') + self.mox.StubOutWithMock(External, 'run') + + psqlargs = ['-d', 'name', '-h', 'host', '-U', 'user', + '-w', '-A', '-t', 'arg1', 'arg2'] + db.get_db_args_env().AndReturn(self.create_db_test_params()) + External.run('psql', psqlargs, capturestd=True, + env={'PGPASSWORD': 'pass'}).AndReturn(('', '')) + self.mox.ReplayAll() + + db.psql('arg1', 'arg2') + self.mox.VerifyAll() + + def test_pgdump(self): + db = self.PartialMockDb(None, None) + self.mox.StubOutWithMock(db, 'get_db_args_env') + self.mox.StubOutWithMock(External, 'run') + + pgdumpargs = ['-d', 'name', '-h', 'host', '-U', 'user', + '-w', 'arg1', 'arg2'] + db.get_db_args_env().AndReturn(self.create_db_test_params()) + External.run('pg_dump', pgdumpargs, capturestd=True, + env={'PGPASSWORD': 'pass'}).AndReturn(('', '')) + self.mox.ReplayAll() + + db.pgdump('arg1', 'arg2') self.mox.VerifyAll() diff --git a/test/unit/test_external.py b/test/unit/test_external.py index 5aa0193..d68bfd3 100644 --- a/test/unit/test_external.py +++ b/test/unit/test_external.py @@ -85,6 +85,9 @@ def test_set_server_dir_and_has_config(self, tmpdir, configured): tmpdir.ensure('etc', 'grid', 'config.xml') assert self.ext.has_config() == configured + # def test_get_config(self): + # Not easily testable since it requires the omero module + # def test_setup_omero_cli(self): # Not easily testable since it does a direct import From f33e5ad417376ec23f4f5bc3ff57efe517f16ed1 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 27 Nov 2015 17:23:13 +0000 Subject: [PATCH 03/11] Fix name of omego db init command --- omego/db.py | 2 +- test/unit/test_db.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/omego/db.py b/omego/db.py index d4a43b3..2cc1a50 100644 --- a/omego/db.py +++ b/omego/db.py @@ -49,7 +49,7 @@ def check_connection(self): log.error(e) raise Stop(30, 'Database connection check failed') - def initialise(self): + def init(self): omerosql = self.args.omerosql autoupgrade = False if not omerosql: diff --git a/test/unit/test_db.py b/test/unit/test_db.py index 6b48e7b..b5b573f 100644 --- a/test/unit/test_db.py +++ b/test/unit/test_db.py @@ -74,7 +74,7 @@ def test_check_connection(self, connected): @pytest.mark.parametrize('sqlfile', ['exists', 'missing', 'notprovided']) @pytest.mark.parametrize('dryrun', [True, False]) - def test_initialise(self, sqlfile, dryrun): + def test_init(self, sqlfile, dryrun): ext = self.mox.CreateMock(External) if sqlfile != 'notprovided': omerosql = 'omero.sql' @@ -109,10 +109,10 @@ def test_initialise(self, sqlfile, dryrun): if sqlfile == 'missing': with pytest.raises(Stop) as excinfo: - db.initialise() + db.init() assert str(excinfo.value) == 'SQL file not found' else: - db.initialise() + db.init() self.mox.VerifyAll() def test_sort_schema(self): From 46133e70f96fa317ae064921a7fde22054967a3d Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 30 Nov 2015 11:30:15 +0000 Subject: [PATCH 04/11] Invert use-db-config: no-db-config --- omego/db.py | 2 +- omego/env.py | 4 ++-- test/unit/test_db.py | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/omego/db.py b/omego/db.py index 2cc1a50..519b6d9 100644 --- a/omego/db.py +++ b/omego/db.py @@ -186,7 +186,7 @@ def get_db_args_env(self): 'pass': self.args.dbpass } - if self.args.use_db_config: + if not self.args.no_db_config: c = self.external.get_config() for k in db: try: diff --git a/omego/env.py b/omego/env.py index f305c67..b497e2a 100644 --- a/omego/env.py +++ b/omego/env.py @@ -87,8 +87,8 @@ def __init__(self, parser): Add(group, "dbpass", "omero", help="Password for connecting to the OMERO database") group.add_argument( - "--use-db-config", action="store_true", - help="Get the database settings from omero config") + "--no-db-config", action="store_true", + help="Ignore the database settings in omero config") # TODO Admin credentials: dbauser, dbapass Add(group, "omerosql", None, diff --git a/test/unit/test_db.py b/test/unit/test_db.py index b5b573f..41a1775 100644 --- a/test/unit/test_db.py +++ b/test/unit/test_db.py @@ -238,22 +238,22 @@ def create_db_test_params(self, prefix=''): return db, env @pytest.mark.parametrize('dbname', ['name', '']) - @pytest.mark.parametrize('useconfig', [True, False]) - def test_get_db_args_env(self, dbname, useconfig): + @pytest.mark.parametrize('noconfig', [True, False]) + def test_get_db_args_env(self, dbname, noconfig): ext = self.mox.CreateMock(External) args = self.Args({'dbhost': 'host', 'dbname': dbname, 'dbuser': 'user', 'dbpass': 'pass', - 'use_db_config': useconfig}) + 'no_db_config': noconfig}) db = self.PartialMockDb(args, ext) self.mox.StubOutWithMock(db.external, 'get_config') self.mox.StubOutWithMock(os.environ, 'copy') - if useconfig: - expecteddb, expectedenv = self.create_db_test_params('ext') - else: + if noconfig: expecteddb, expectedenv = self.create_db_test_params() + else: + expecteddb, expectedenv = self.create_db_test_params('ext') - if useconfig: + if not noconfig: cfg = { 'omero.db.host': 'exthost', 'omero.db.user': 'extuser', From 41f540caca28afa518bb1b552c110bc7d174048d Mon Sep 17 00:00:00 2001 From: Simon Li Date: Mon, 30 Nov 2015 12:22:04 +0000 Subject: [PATCH 05/11] ConfigXml read_only flag was added in 5.0.2 --- travis-build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/travis-build b/travis-build index 8e42779..25666e4 100644 --- a/travis-build +++ b/travis-build @@ -11,8 +11,7 @@ omego -h #Install a new server if [ $TEST = install ]; then - - omego install --initdb --dbhost localhost --dbname omero --prestartfile $HOME/config.omero -v http://downloads.openmicroscopy.org/omero/5.0.0-rc1/artifacts/OMERO.server-5.0.0-rc1-ice34-b10.zip; + omego install --initdb --dbhost localhost --dbname omero --prestartfile $HOME/config.omero -v http://downloads.openmicroscopy.org/omero/5.0.8/artifacts/OMERO.server-5.0.8-ice34-b60.zip; fi #Test a multistage DB upgrade (4.4 -> 5.1DEV) as part of the server upgrade From ffde65f0999a7ec0678563fad5148eaacb7eb0b2 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 15 Jan 2016 16:49:13 +0000 Subject: [PATCH 06/11] Check config.xml exists before reading properties --- omego/db.py | 2 +- omego/external.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/omego/db.py b/omego/db.py index 519b6d9..c88e9c8 100644 --- a/omego/db.py +++ b/omego/db.py @@ -186,7 +186,7 @@ def get_db_args_env(self): 'pass': self.args.dbpass } - if not self.args.no_db_config: + if not self.args.no_db_config and self.external.has_config(): c = self.external.get_config() for k in db: try: diff --git a/omego/external.py b/omego/external.py index ad83ffe..54b34db 100644 --- a/omego/external.py +++ b/omego/external.py @@ -77,7 +77,7 @@ def get_config(self): setup_omero_cli() must be called before this method to import the correct omero module to minimise the possibility of version conflicts """ - if not self.has_config: + if not self.has_config(): raise Exception('No config file') c = self._omero.config.ConfigXml(os.path.join( From 28b90147f26c2d0d56023ec2b91e6b0f93401d42 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 15 Jan 2016 16:50:23 +0000 Subject: [PATCH 07/11] Update db config tests --- test/unit/test_db.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/unit/test_db.py b/test/unit/test_db.py index 41a1775..f9a0ab8 100644 --- a/test/unit/test_db.py +++ b/test/unit/test_db.py @@ -238,22 +238,26 @@ def create_db_test_params(self, prefix=''): return db, env @pytest.mark.parametrize('dbname', ['name', '']) + @pytest.mark.parametrize('hasconfig', [True, False]) @pytest.mark.parametrize('noconfig', [True, False]) - def test_get_db_args_env(self, dbname, noconfig): + def test_get_db_args_env(self, dbname, hasconfig, noconfig): ext = self.mox.CreateMock(External) args = self.Args({'dbhost': 'host', 'dbname': dbname, 'dbuser': 'user', 'dbpass': 'pass', 'no_db_config': noconfig}) db = self.PartialMockDb(args, ext) + self.mox.StubOutWithMock(db.external, 'has_config') self.mox.StubOutWithMock(db.external, 'get_config') self.mox.StubOutWithMock(os.environ, 'copy') - if noconfig: + if noconfig or not hasconfig: expecteddb, expectedenv = self.create_db_test_params() else: expecteddb, expectedenv = self.create_db_test_params('ext') if not noconfig: + db.external.has_config().AndReturn(hasconfig) + if not noconfig and hasconfig: cfg = { 'omero.db.host': 'exthost', 'omero.db.user': 'extuser', From c8aaa3fc509164e67d23b252570f2d6c5e9bcc8b Mon Sep 17 00:00:00 2001 From: Simon Li Date: Tue, 2 Feb 2016 10:58:44 +0000 Subject: [PATCH 08/11] Don't fail if ConfigXml read_only arg not supported. Older versions of OMERO don't support this flag --- omego/external.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/omego/external.py b/omego/external.py index 54b34db..894c33d 100644 --- a/omego/external.py +++ b/omego/external.py @@ -80,9 +80,15 @@ def get_config(self): if not self.has_config(): raise Exception('No config file') - c = self._omero.config.ConfigXml(os.path.join( - self.dir, 'etc', 'grid', 'config.xml'), - exclusive=False, read_only=True) + configxml = os.path.join(self.dir, 'etc', 'grid', 'config.xml') + try: + # Attempt to open config.xml read-only, though this flag is not + # present in early versions of OMERO 5.0 + c = self._omero.config.ConfigXml( + configxml, exclusive=False, read_only=True) + except TypeError: + c = self._omero.config.ConfigXml(configxml, exclusive=False) + try: return c.as_map() finally: From de23851057d7f1d1fb89b75ee6b03786c5d07343 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 5 Feb 2016 15:40:24 +0000 Subject: [PATCH 09/11] Force re-reading of config.xml THe presence/absence of config.xml is recorded at initialisation since importing omero.cli may lead to the creation of an empty config.xml when previosuly there was none. However for a server upgrade we want to re-read the config.xml after it is copied. --- omego/db.py | 9 +++++++-- omego/external.py | 10 ++++++++-- test/unit/test_db.py | 24 +++++++++++++----------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/omego/db.py b/omego/db.py index c88e9c8..a2ca7f1 100644 --- a/omego/db.py +++ b/omego/db.py @@ -186,8 +186,13 @@ def get_db_args_env(self): 'pass': self.args.dbpass } - if not self.args.no_db_config and self.external.has_config(): - c = self.external.get_config() + if not self.args.no_db_config: + try: + c = self.external.get_config(force=True) + except Exception as e: + log.warn('config.xml not found: %s', e) + c = {} + for k in db: try: db[k] = c['omero.db.%s' % k] diff --git a/omego/external.py b/omego/external.py index 894c33d..bc18b52 100644 --- a/omego/external.py +++ b/omego/external.py @@ -70,17 +70,23 @@ def has_config(self): raise Exception('No server directory set') return self.configured - def get_config(self): + def get_config(self, force=False): """ Returns a dictionary of all config.xml properties + If `force = True` then ignore any cached state and read config.xml + if possible + setup_omero_cli() must be called before this method to import the correct omero module to minimise the possibility of version conflicts """ - if not self.has_config(): + if not force and not self.has_config(): raise Exception('No config file') configxml = os.path.join(self.dir, 'etc', 'grid', 'config.xml') + if not os.path.exists(configxml): + raise Exception('No config file') + try: # Attempt to open config.xml read-only, though this flag is not # present in early versions of OMERO 5.0 diff --git a/test/unit/test_db.py b/test/unit/test_db.py index f9a0ab8..c437e7b 100644 --- a/test/unit/test_db.py +++ b/test/unit/test_db.py @@ -256,17 +256,19 @@ def test_get_db_args_env(self, dbname, hasconfig, noconfig): expecteddb, expectedenv = self.create_db_test_params('ext') if not noconfig: - db.external.has_config().AndReturn(hasconfig) - if not noconfig and hasconfig: - cfg = { - 'omero.db.host': 'exthost', - 'omero.db.user': 'extuser', - 'omero.db.pass': 'extpass', - } - if dbname: - cfg['omero.db.name'] = 'extname' - - db.external.get_config().AndReturn(cfg) + cfg = {} + if hasconfig: + cfg = { + 'omero.db.host': 'exthost', + 'omero.db.user': 'extuser', + 'omero.db.pass': 'extpass', + } + if dbname: + cfg['omero.db.name'] = 'extname' + + db.external.get_config(force=True).AndReturn(cfg) + else: + db.external.get_config().AndRaise(Exception()) os.environ.copy().AndReturn({'PGPASSWORD': 'incorrect'}) From f00b0667e307f2e1c2f806b6e8a7291ca74e6bd4 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 5 Feb 2016 16:00:29 +0000 Subject: [PATCH 10/11] Add a few more tests to travis-build --- travis-build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/travis-build b/travis-build index 25666e4..4030118 100644 --- a/travis-build +++ b/travis-build @@ -10,8 +10,19 @@ omego version omego -h #Install a new server +#Tests rely on a non-zero error code being returned on failure if [ $TEST = install ]; then omego install --initdb --dbhost localhost --dbname omero --prestartfile $HOME/config.omero -v http://downloads.openmicroscopy.org/omero/5.0.8/artifacts/OMERO.server-5.0.8-ice34-b60.zip; + #TODO: switch to ice 3.5 and pass --release 5.0.8 instead of a URL + + # Check the expected server version was downloaded + test $(readlink OMERO-CURRENT) = './OMERO.server-5.0.8-ice34-b60' + + OMERO-CURRENT/bin/omero config set omero.db.name omero + + # Check db dump file + omego db dump --serverdir OMERO-CURRENT --dumpfile travis-omero.pgdump + pg_restore -e travis-omero.pgdump | grep 'CREATE TABLE dbpatch' fi #Test a multistage DB upgrade (4.4 -> 5.1DEV) as part of the server upgrade From d3a83a32dbb63b46d8caab78469dfb0856f0ea97 Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 5 Feb 2016 16:49:08 +0000 Subject: [PATCH 11/11] Set omero.db.name in .travis.yml, use config.xml db params for upgrade --- .travis.yml | 1 + travis-build | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb2ad01..63db779 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ before_script: - psql -c "select 1;" -U omero -h localhost omero - mkdir $HOME/OMERO - echo "config set omero.data.dir $HOME/OMERO" > $HOME/config.omero + - echo "config set omero.db.name omero" >> $HOME/config.omero script: - sh travis-build diff --git a/travis-build b/travis-build index 4030118..c7e311a 100644 --- a/travis-build +++ b/travis-build @@ -18,8 +18,6 @@ if [ $TEST = install ]; then # Check the expected server version was downloaded test $(readlink OMERO-CURRENT) = './OMERO.server-5.0.8-ice34-b60' - OMERO-CURRENT/bin/omero config set omero.db.name omero - # Check db dump file omego db dump --serverdir OMERO-CURRENT --dumpfile travis-omero.pgdump pg_restore -e travis-omero.pgdump | grep 'CREATE TABLE dbpatch' @@ -34,5 +32,5 @@ if [ $TEST = upgrade ]; then psql -q -h localhost -U omero omero < OMERO.sql; OMERO-CURRENT/bin/omero load $HOME/config.omero; OMERO-CURRENT/bin/omero admin start; - omego upgrade --branch=OMERO-5.1-latest --labels=ICE=3.4 --upgradedb --dbhost localhost --dbname omero -v; + omego upgrade --branch=OMERO-5.1-latest --labels=ICE=3.4 --upgradedb -v; fi