aboutsummaryrefslogtreecommitdiff
path: root/ca
diff options
context:
space:
mode:
Diffstat (limited to 'ca')
-rw-r--r--ca/tests/yamlconf.py34
-rw-r--r--ca/tests/yamltest.py13
2 files changed, 19 insertions, 28 deletions
diff --git a/ca/tests/yamlconf.py b/ca/tests/yamlconf.py
index efe161d6..c463369f 100644
--- a/ca/tests/yamlconf.py
+++ b/ca/tests/yamlconf.py
@@ -491,11 +491,13 @@ class allocation(object):
def syncdb(self):
import django.core.management
assert not self.is_hosted
- django.core.management.call_command("syncdb",
- database = self.irdb_name,
- load_initial_data = False,
- interactive = False,
- verbosity = 0)
+ django.core.management.call_command(
+ "syncdb",
+ verbosity = 0,
+ database = self.irdb_name,
+ migrate = True,
+ load_initial_data = False,
+ interactive = False)
def hire_zookeeper(self):
assert not self.is_hosted
@@ -755,22 +757,13 @@ def body():
pre_django_sql_setup(set(d.irdb_name for d in db if not d.is_hosted))
# Now ready for fun with multiple databases in Django!
-
+ #
# https://docs.djangoproject.com/en/1.4/topics/db/multi-db/
# https://docs.djangoproject.com/en/1.4/topics/db/sql/
-
- # This will probably need hacking to work with rpki.django_settings,
- # rpki.db_router, and all the related new code, but let's get the
- # kinks ironed out of the normal stuff before messing with this.
- #
- # I suspect the correct strategy here will be to import
- # rpki.django_settings and modify its DATABASES and DATABASE_ROUTERS
- # settings, but we'll see.
#
- # We will almost certainly have to run syncdb and migrate. We may want
- # our own private south database so we don't mess up anything else; that
- # database might even be one of our outputs (ie, yamltest may need that
- # too, and may end up generating its own when run without this).
+ # This program's use of the ORM is sufficiently different that it's
+ # not worth straining to use rpki.django_settings, so we just use
+ # Django's settings API directly.
database_template = {
"ENGINE" : "django.db.backends.mysql",
@@ -780,8 +773,7 @@ def body():
"PORT" : "",
"OPTIONS" : { "init_command": "SET storage_engine=INNODB" }}
- databases = dict((d.irdb_name,
- dict(database_template, NAME = d.irdb_name))
+ databases = dict((d.irdb_name, dict(database_template, NAME = d.irdb_name))
for d in db if not d.is_hosted)
databases["default"] = databases[db.root.irdb_name]
@@ -791,7 +783,7 @@ def body():
settings.configure(
DATABASES = databases,
DATABASE_ROUTERS = ["rpki.irdb.router.DBContextRouter"],
- INSTALLED_APPS = ("rpki.irdb",))
+ INSTALLED_APPS = ("rpki.irdb", "south"))
import rpki.irdb
diff --git a/ca/tests/yamltest.py b/ca/tests/yamltest.py
index e265fd46..835d25f2 100644
--- a/ca/tests/yamltest.py
+++ b/ca/tests/yamltest.py
@@ -547,8 +547,8 @@ class allocation(object):
cmd.append(self.path("rpkic.%s.prof" % rpki.sundial.now()))
cmd.extend(str(a) for a in argv if a is not None)
print 'Running "%s"' % " ".join(cmd)
- env = os.environ.copy()
- env.update(YAMLTEST_RPKIC_COUNTER = self.next_rpkic_counter(),
+ env = dict(os.environ,
+ YAMLTEST_RPKIC_COUNTER = self.next_rpkic_counter(),
RPKI_CONF = self.path("rpki.conf"))
subprocess.check_call(cmd, cwd = self.host.path(), env = env)
@@ -576,15 +576,15 @@ class allocation(object):
if not os.fork():
os.environ["RPKI_CONF"] = self.path("rpki.conf")
import django.core.management
- django.core.management.call_command("syncdb", verbosity = verbosity, load_initial_data = False, migrate = True)
+ django.core.management.call_command("syncdb", migrate = True, verbosity = verbosity,
+ load_initial_data = False, interactive = False)
sys.exit(0)
if os.wait()[1]:
raise RuntimeError("syncdb failed for %s" % self.name)
else:
cmd = (prog_rpki_manage, "syncdb", "--noinput", "--no-initial-data", "--migrate", "--verbosity", str(verbosity))
- env = os.environ.copy()
- env.update(RPKI_CONF = self.path("rpki.conf"))
+ env = dict(os.environ, RPKI_CONF = self.path("rpki.conf"))
print 'Running "%s"' % " ".join(cmd)
subprocess.check_call(cmd, cwd = self.host.path(), env = env)
@@ -600,8 +600,7 @@ class allocation(object):
if args.profile and basename != "rootd":
cmd.extend((
"--profile", self.path(basename + ".prof")))
- env = os.environ.copy()
- env.update(RPKI_CONF = self.path("rpki.conf"))
+ env = dict(os.environ, RPKI_CONF = self.path("rpki.conf"))
p = subprocess.Popen(cmd, cwd = self.path(), env = env)
print 'Running %s for %s: pid %d process %r' % (" ".join(cmd), self.name, p.pid, p)
return p