sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #03747
[Merge] ~ack/maas:perftest-create-db-each-test into maas:master
Alberto Donato has proposed merging ~ack/maas:perftest-create-db-each-test into maas:master.
Commit message:
perftests: create database before each test
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~ack/maas/+git/maas/+merge/433993
--
Your team MAAS Maintainers is requested to review the proposed merge of ~ack/maas:perftest-create-db-each-test into maas:master.
diff --git a/src/maastesting/pytest/django.py b/src/maastesting/pytest/django.py
index 5848532..986a7b5 100644
--- a/src/maastesting/pytest/django.py
+++ b/src/maastesting/pytest/django.py
@@ -169,14 +169,16 @@ def ensuremaasdb(templatemaasdb, pytestconfig, worker_id):
database = development.DATABASES["default"]
database["NAME"] = dbname
cluster = pytestconfig.stash[cluster_stash]
- if dbname not in cluster.databases:
- template = pytestconfig.stash[db_template_stash]
- with cluster.lock.exclusive:
- with connect(cluster) as conn:
- with conn.cursor() as cursor:
- cursor.execute(
- f'CREATE DATABASE "{dbname}" WITH TEMPLATE "{template}"'
- )
+ template = pytestconfig.stash[db_template_stash]
+ with (
+ cluster.lock.exclusive,
+ connect(cluster) as conn,
+ conn.cursor() as cursor,
+ ):
+ cursor.execute(f"DROP DATABASE IF EXISTS {dbname}")
+ cursor.execute(
+ f'CREATE DATABASE "{dbname}" WITH TEMPLATE "{template}"'
+ )
yield
database["NAME"] = "no_such_db"
Follow ups
-
[Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: MAAS Lander, 2022-12-09
-
Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Thorsten Merten, 2022-12-09
-
[Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Alberto Donato, 2022-12-09
-
Re: [UNITTESTS] -b perftest-create-db-each-test lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas - TESTS PASS
From: MAAS Lander, 2022-12-09
-
Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Anton Troyanov, 2022-12-09
-
Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Alberto Donato, 2022-12-02
-
Re: [UNITTESTS] -b perftest-create-db-each-test lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas - TESTS FAILED
From: MAAS Lander, 2022-12-02
-
Re: [UNITTESTS] -b perftest-create-db-each-test lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas - TESTS PASS
From: MAAS Lander, 2022-12-02
-
Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Björn Tillenius, 2022-12-02
-
Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master
From: Björn Tillenius, 2022-12-02
-
Re: [UNITTESTS] -b perftest-create-db-each-test lp:~ack/maas/+git/maas into -b master lp:~maas-committers/maas - TESTS PASS
From: MAAS Lander, 2022-12-02