← Back to team overview

sts-sponsors team mailing list archive

Re: [Merge] ~ack/maas:perftest-create-db-each-test into maas:master

 

Review: Needs Fixing



Diff comments:

> 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}"'
> +        )

This is used both for performance tests and the normal tests. We need some kind of marker for this, that we can set in the performance tests.

>      yield
>      database["NAME"] = "no_such_db"
>  


-- 
https://code.launchpad.net/~ack/maas/+git/maas/+merge/433993
Your team MAAS Committers is subscribed to branch maas:master.



References