[1/3] travis: test against postgresql 10

Message ID 20180703063751.12068-1-daniel@linux.ibm.com
State Superseded
Headers show
Series
  • [1/3] travis: test against postgresql 10
Related show

Commit Message

Daniel Black July 3, 2018, 6:37 a.m.
Signed-off-by: Daniel Black <daniel@linux.ibm.com>
---
 .travis.yml | 45 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 43 insertions(+), 2 deletions(-)

Comments

Daniel Black July 4, 2018, 3:50 a.m. | #1
Resultant travis test:

https://travis-ci.org/grooverdan/patchwork
Stephen Finucane July 13, 2018, 5:31 p.m. | #2
On Tue, 2018-07-03 at 16:37 +1000, Daniel Black wrote:
> Signed-off-by: Daniel Black <daniel@linux.ibm.com>
> ---
>  .travis.yml | 45 +++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 43 insertions(+), 2 deletions(-)

Thanks for the contribution :) Some comments below.

> diff --git a/.travis.yml b/.travis.yml
> index 6cb983f..d61b255 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -23,14 +23,55 @@ env:
>    global:
>      - PW_TEST_DB_PASS=""
>  
> +matrix:
> +  include:
> +    - addons:
> +        postgresql: "10"
> +        apt:
> +          packages:
> +          - postgresql-10
> +          - postgresql-client-10
> +      env:
> +        - PGPORT=5433
> +        - PW_TEST_DB_PORT=5433
> +        - PW_TEST_DB_TYPE=postgres
> +        - PW_TEST_DB_USER=travis
> +        - PW_TEST_DB_PASS=""
> +      python: 3.6
> +      sudo: true
> +      before_install:
> +        - sudo -u postgres psql -c "grant ALL on DATABASE postgres to travis WITH GRANT OPTION;"
> +    - env:
> +        - PGPORT=5432
> +        - PW_TEST_DB_PORT=5432
> +        - PW_TEST_DB_TYPE=postgres
> +        - PW_TEST_DB_USER=travis
> +        - PW_TEST_DB_PASS=""
> +      python: 3.6
> +      addons:
> +        postgresql: "9.6"
> +        apt:
> +          packages:
> +          - postgresql-9.6
> +          - postgresql-client-9.6
> +
> +

[Forgive me if this comes across rather silly - I'm no Travis expert]

I initially read this and thought...aren't we already doing this?
Looking into it more, it seems we're not quite. What we are doing is
running a test matrix of supported Python (and Python package) versions
(currently Python 2.7, 3.4, 3.5, and 3.6) against the supported
database backends (currently MariaDB/MySQL  and PostgreSQL). That gives
us 8 variations. This seems to be adding three more - one using MariaDB
10 and Python 2.7, one using PostgreSQL 9.6 and Python 3.6 and one
using PostgreSQL 10 and Python 3.6. Is that all correct so far?

If so, I have the following comments/questions:

 * The addtional PostgreSQL 9.6 environment seems unnecessary, given
   that we're already testing this with multiple Python versions
 * Is there any real reason we need to keep testing the older versions
   of the databases?
 * If so, is there any reason we need to run multiple the tests for
   multiple Python versions against both PostgreSQL and MariaDB?
   Couldn't we just run them against e.g. PostgreSQL 10 and then simply
   run the Python 3.6 tests against the other three possible backends?

>  before_script:
> -  - mysql -e 'create database patchwork character set utf8;'
> -  - psql -c "create database patchwork with ENCODING = 'UTF8';" -U postgres
> +  - if [[ $PW_TEST_DB_TYPE == mysql ]]; then mysql -e 'create database patchwork character set utf8;'; fi
> +  - if [[ $PW_TEST_DB_TYPE == postgres ]]; then psql -c "create database patchwork with ENCODING = 'UTF8';" -U $PW_TEST_DB_USER; fi
>  
>  install:
>    - pip install tox-travis
>  
>  script:
> +  - >
> +    if [[ $PW_TEST_DB_TYPE == mysql ]];
> +    then
> +      mysql -e 'SELECT VERSION(), CURRENT_USER();' -u $PW_TEST_DB_USER patchwork;
> +    else
> +      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER patchwork;
> +      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER postgres;
> +    fi
>    - tox
>    - tox -e coverage
>  

Cheers,
Stephen
Daniel Black Aug. 6, 2018, 5:25 a.m. | #3
On Fri, 13 Jul 2018 18:31:09 +0100
Stephen Finucane <stephen@that.guru> wrote:

> On Tue, 2018-07-03 at 16:37 +1000, Daniel Black wrote:
> > Signed-off-by: Daniel Black <daniel@linux.ibm.com>
>
> [Forgive me if this comes across rather silly - I'm no Travis expert]
> 
> I initially read this and thought...aren't we already doing this?
> Looking into it more, it seems we're not quite. What we are doing is
> running a test matrix of supported Python (and Python package)
> versions (currently Python 2.7, 3.4, 3.5, and 3.6) against the
> supported database backends (currently MariaDB/MySQL  and
> PostgreSQL). That gives us 8 variations.

> This seems to be adding
> three more - one using MariaDB 10 and Python 2.7, one using
> PostgreSQL 9.6 and Python 3.6 and one using PostgreSQL 10 and Python
> 3.6. Is that all correct so far?

yes.

> 
> If so, I have the following comments/questions:
> 
>  * The addtional PostgreSQL 9.6 environment seems unnecessary, given
>    that we're already testing this with multiple Python versions

Quite right. I'll remove or replace with a PG 11 release (currently at
beta2).

>  * Is there any real reason we need to keep testing the older versions
>    of the databases?

I'm assuming there is a lower version of database that you want to
maintain compatibility with. Or at least knowing if a break in
compatibility is made so it can be noted in release notes.

>  * If so, is there any reason we need to run multiple the tests for
>    multiple Python versions against both PostgreSQL and MariaDB?
>    Couldn't we just run them against e.g. PostgreSQL 10 and then
> simply run the Python 3.6 tests against the other three possible
> backends?

In practice its making sure the underlying libraries of django,
psycopg2 and mysqlclient are doing the right thing for each of the
server versions. Sure, this is mostly testing more than just patchwork.
I think it puts the development in a good place to start using newer
CTEs queries depending on database server version.

I think all combinations fall within the scope of a supported system so
may as well incur the few extra minutes of testing for the benefit of
users.

Patch

diff --git a/.travis.yml b/.travis.yml
index 6cb983f..d61b255 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,14 +23,55 @@  env:
   global:
     - PW_TEST_DB_PASS=""
 
+matrix:
+  include:
+    - addons:
+        postgresql: "10"
+        apt:
+          packages:
+          - postgresql-10
+          - postgresql-client-10
+      env:
+        - PGPORT=5433
+        - PW_TEST_DB_PORT=5433
+        - PW_TEST_DB_TYPE=postgres
+        - PW_TEST_DB_USER=travis
+        - PW_TEST_DB_PASS=""
+      python: 3.6
+      sudo: true
+      before_install:
+        - sudo -u postgres psql -c "grant ALL on DATABASE postgres to travis WITH GRANT OPTION;"
+    - env:
+        - PGPORT=5432
+        - PW_TEST_DB_PORT=5432
+        - PW_TEST_DB_TYPE=postgres
+        - PW_TEST_DB_USER=travis
+        - PW_TEST_DB_PASS=""
+      python: 3.6
+      addons:
+        postgresql: "9.6"
+        apt:
+          packages:
+          - postgresql-9.6
+          - postgresql-client-9.6
+
+
 before_script:
-  - mysql -e 'create database patchwork character set utf8;'
-  - psql -c "create database patchwork with ENCODING = 'UTF8';" -U postgres
+  - if [[ $PW_TEST_DB_TYPE == mysql ]]; then mysql -e 'create database patchwork character set utf8;'; fi
+  - if [[ $PW_TEST_DB_TYPE == postgres ]]; then psql -c "create database patchwork with ENCODING = 'UTF8';" -U $PW_TEST_DB_USER; fi
 
 install:
   - pip install tox-travis
 
 script:
+  - >
+    if [[ $PW_TEST_DB_TYPE == mysql ]];
+    then
+      mysql -e 'SELECT VERSION(), CURRENT_USER();' -u $PW_TEST_DB_USER patchwork;
+    else
+      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER patchwork;
+      psql -c "SELECT VERSION(), CURRENT_USER, current_database()" -U $PW_TEST_DB_USER postgres;
+    fi
   - tox
   - tox -e coverage