Re: [PATCH 3/3] Add Docker IP to whitelist for django-debug-toolbar

2016-08-08 Thread Andrew Donnellan

On 09/08/16 14:38, Daniel Axtens wrote:

Yay for debugging with Docker.

Signed-off-by: Daniel Axtens <d...@axtens.net>


Reviewed-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com>

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH v2 5/6] Allow use of Docker for development

2016-08-08 Thread Andrew Donnellan

On 04/08/16 16:10, Daniel Axtens wrote:

This makes it possible to use Docker and docker-compose for development
as an alternative to Vagrant.

I quite liked vagrant a couple of years ago, but currently:

 * Trying to install VirtualBox on Ubuntu wants me to disable
   Secure Boot, and I don't want to do that.

 * Trying to use the libvirt plugin for vagrant requires I pick
   from a very small set of possible images, and requires that I
   install the upstream vagrant rather than the vagrant shipped
   with Ubuntu 16.04

 * I find docker containers faster to work with and more transparent.

So I've done the work to make docker work for Patchwork development.
This doesn't break or in any way interfere with using Vagrant, it just
provides an alternative.

It includes support for headless selenium tests using Chromium.

Signed-off-by: Daniel Axtens <d...@axtens.net>


Step 18 : WORKDIR /home/patchwork/patchwork
 ---> Running in d3058a7597b4
 ---> 135d5890866b
Removing intermediate container d3058a7597b4
Successfully built 135d5890866b
WARNING: Image for service web was built because it did not already 
exist. To rebuild this image you must use `docker-compose build` or 
`docker-compose up --build`.

Creating patchwork_db_1
Creating patchwork_web_1
Attaching to patchwork_db_1, patchwork_web_1
db_1   | Initializing database
web_1  | MySQL seems not to be connected, or the patchwork user is broken
web_1  | MySQL may still be starting. Waiting 5 seconds.
web_1  | Still cannot connect to MySQL.
web_1  | Are you using docker-compose? If not, have you set up the link 
correctly?

patchwork_web_1 exited with code 1
db_1   | Database initialized
db_1   | MySQL init process in progress...
db_1   | Warning: Unable to load '/usr/share/zoneinfo/Factory' as time 
zone. Skipping it.
db_1   | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as 
time zone. Skipping it.
db_1   | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' 
as time zone. Skipping it.
db_1   | Warning: Unable to load '/usr/share/zoneinfo/posix/Factory' as 
time zone. Skipping it.
db_1   | Warning: Unable to load '/usr/share/zoneinfo/right/Factory' as 
time zone. Skipping it.
db_1   | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time 
zone. Skipping it.
db_1   | mysql: [Warning] Using a password on the command line interface 
can be insecure.
db_1   | mysql: [Warning] Using a password on the command line interface 
can be insecure.

db_1   |
db_1   | /usr/local/bin/docker-entrypoint.sh: ignoring 
/docker-entrypoint-initdb.d/*

db_1   |
db_1   |
db_1   | MySQL init process done. Ready for start up.
db_1   |

Perhaps 5 seconds isn't enough?

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH v2 5/6] Allow use of Docker for development

2016-08-04 Thread Andrew Donnellan
de 100644
index ..eb2ed7dddb85
--- /dev/null
+++ b/docker/bashrc
@@ -0,0 +1,5 @@
+# This snippet is appended to ~/.bashrc when the container is created
+
+alias runserver='python3 $PROJECT_HOME/manage.py runserver 0.0.0.0:8000'
+alias createsu='python3 $PROJECT_HOME/manage.py createsuperuser'
+
diff --git a/docker/db/.dockerignore b/docker/db/.dockerignore
new file mode 100644
index ..1269488f7fb1
--- /dev/null
+++ b/docker/db/.dockerignore
@@ -0,0 +1 @@
+data
diff --git a/docker/db/.gitignore b/docker/db/.gitignore
new file mode 100644
index ..60baa9cb833f
--- /dev/null
+++ b/docker/db/.gitignore
@@ -0,0 +1 @@
+data/*
diff --git a/docker/db/Dockerfile b/docker/db/Dockerfile
new file mode 100644
index ..5df9b5acb486
--- /dev/null
+++ b/docker/db/Dockerfile
@@ -0,0 +1,10 @@
+FROM mysql:5.7
+
+ENV MYSQL_ROOT_PASSWORD password
+ENV MYSQL_USER patchwork
+ENV MYSQL_PASSWORD password
+
+# We don't want to use the MYSQL_DATABASE env here because
+# we want to be able to create the database with UTF-8 explictly.
+# We also can't load in the data because it's in XML, yay.
+
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100755
index ..c6cf18713fd8
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+set -euo pipefail
+
+# functions
+test_db_connection() {
+mysqladmin -h $PW_TEST_DB_HOST -u patchwork --password=password ping > 
/dev/null 2> /dev/null
+}
+
+reset_data() {
+mysql -u$db_user -p$db_pass -h $PW_TEST_DB_HOST << EOF
+DROP DATABASE IF EXISTS patchwork;
+CREATE DATABASE patchwork CHARACTER SET utf8;
+GRANT ALL ON patchwork.* TO 'patchwork' IDENTIFIED BY 'password';
+FLUSH PRIVILEGES;
+EOF
+
+# load initial data
+python3 $PROJECT_HOME/manage.py migrate #> /dev/null
+python3 $PROJECT_HOME/manage.py loaddata default_tags #> /dev/null
+python3 $PROJECT_HOME/manage.py loaddata default_states #> /dev/null
+python3 $PROJECT_HOME/manage.py loaddata default_projects #> /dev/null
+}
+
+
+# The script begins!
+
+# check if patchwork is mounted. Checking if we exist is a
+# very good start!
+if [ ! -f ~patchwork/patchwork/docker/entrypoint.sh ]; then
+echo "The patchwork directory doesn't seem to be mounted!"
+echo "Are you using docker-compose?"
+echo "If not, you need -v PATH_TO_PATCHWORK:/home/patchwork/patchwork"
+exit 1
+fi
+
+# check if we need to rebuild because requirements changed
+for x in /tmp/requirements-*.txt; do
+if ! cmp $x ~/patchwork/$(basename $x); then
+   echo "A requirements file has changed."
+   echo "Please rebuild the patchwork image:"
+   echo "docker-compose build web"
+   exit 1
+fi
+done
+
+# check if mysql is connected
+if ! test_db_connection; then
+echo "MySQL seems not to be connected, or the patchwork user is broken"
+echo "MySQL may still be starting. Waiting 5 seconds."
+sleep 5
+if ! test_db_connection; then
+   echo "Still cannot connect to MySQL."
+   echo "Are you using docker-compose? If not, have you set up the link 
correctly?"
+   exit 1
+fi
+fi
+
+# rebuild mysql db
+# do this on --reset or if the db doesn't exist
+if [[ "$1" == "--reset" ]]; then
+shift
+reset_data
+elif ! ( echo ';' | mysql -h db -u patchwork -ppassword patchwork 2> /dev/null 
); then
+reset_data
+fi
+
+if [ $# -eq 0 ]; then
+# we probably ran with --reset and nothing else
+# just exit cleanly
+exit 0
+elif [ "$1" == "--shell" ]; then
+exec bash
+elif [ "$1" == "--quick-test" ]; then
+export PW_SKIP_BROWSER_TESTS=yes
+python3 manage.py test
+elif [ "$1" == "--test" ]; then
+xvfb-run --server-args='-screen 0, 1024x768x16' python3 manage.py test
+else # run whatever CMD is set to
+$@
+fi



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH v2 2/6] Fix test_login in test_user_browser.py

2016-08-04 Thread Andrew Donnellan

On 04/08/16 16:10, Daniel Axtens wrote:

It tried to use the pbkdf2 hash as the password. Use the username instead, as 
that
is what create_user sets.

Then it compared the test user username to testuser, rather than the username, 
which
is dynamically generated. Compare to the generated username.

Signed-off-by: Daniel Axtens <d...@axtens.net>


All looks good.

Reviewed-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com>

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH v2 4/6] Put test db host and port into env variables.

2016-08-04 Thread Andrew Donnellan

On 04/08/16 16:10, Daniel Axtens wrote:

This is preparation for a Docker-based dev environment.

Signed-off-by: Daniel Axtens <d...@axtens.net>


A good move generally.

Reviewed-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com>

--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: [PATCH 02/10] models: Add 'Series' model and related models

2016-07-18 Thread Andrew Donnellan

On 19/07/16 10:50, Russell Currey wrote:

On Mon, 2016-06-13 at 11:41 +0100, Stephen Finucane wrote:

Add a series model. This model is intentionally very minimal to allow
as much dynaminism as possible. It is expected that patches will be
migrated between series as new data is provided.

Signed-off-by: Stephen Finucane <stephen.finuc...@intel.com>
---


I'm pretty sure this broke the patches API, though I'm not exactly a Django
expert.  Here's what I'm seeing:

Exception Type: ImproperlyConfigured at /api/1.0/patches/
Exception Value: Could not resolve URL for hyperlinked relationship using view
name "seriesrevision-detail". You may have failed to include the related model
in your API, or incorrectly configured the `lookup_field` attribute on this
field.

Full log here: http://dpaste.com/0P3C63K


Temporary fix to exclude the series field from the Patch endpoint.

Signed-off-by: Andrew Donnellan <andrew.donnel...@au1.ibm.com>

diff --git a/patchwork/rest_serializers.py b/patchwork/rest_serializers.py
index af6b1b7..be55ad1 100644
--- a/patchwork/rest_serializers.py
+++ b/patchwork/rest_serializers.py
@@ -84,7 +84,7 @@ class PatchSerializer(URLSerializer):
 'content', 'hash', 'msgid')
 # there's no need to expose an entire "tags" endpoint, so we 
custom

 # render this field
-exclude = ('tags',)
+exclude = ('tags', 'series')
 check_names = dict(Check.STATE_CHOICES)
 mbox_url = SerializerMethodField()
 state = SerializerMethodField()


--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


<    1   2   3