Skip to content

Commit c10bc61

Browse files
authored
Migration tests, fix migration bug, and clean up test matrix. (#244)
Set up tests to upgrade from 1.1.1, 1.20, 1.3.0, 1.4.0. After upgrade, run migrations back to 0001 and then forward again to ensure no issues. Add a migration to remove bad migration history caused by the migration squash a while back. This was only causing an error when ugprading from 1.3.0 and then going backward again, caught by the new tests mentioned above. Update all test VMs to xenial (ubuntu 6.04). Add erlang fixing code to a central location for all builds. Ensure we get latest sqlite due to a very strange timing bug with sqlite and migrations that would cause migrations to randomly fail. Add python 3.6, and django 2.1 to text matrix.
1 parent 35353f9 commit c10bc61

File tree

4 files changed

+145
-27
lines changed

4 files changed

+145
-27
lines changed

.travis.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
11
language: python
22
sudo: false
3+
dist: xenial
34
cache: false
5+
before_install:
6+
- sudo apt update
7+
- sudo apt install -y wget
8+
- wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
9+
- sudo apt-key add erlang_solutions.asc
10+
- sudo apt install -y sqlite
11+
- sudo apt install -y erlang
12+
- sudo apt install -y erlang-nox
13+
- sudo apt install -y rabbitmq-server
14+
- sudo /etc/init.d/rabbitmq-server start
415
python:
516
- 2.7
617
- 3.5
18+
- 3.6
19+
- 3.7
720
- pypy
21+
# pypy3.5 not yet supported due to compilation errors with pyephem
22+
# https://github.com/celery/django-celery-beat/issues/245
23+
# - pypy3.5
824
env:
925
- DJANGO=1.11
1026
- DJANGO=2.0
27+
- DJANGO=2.1
1128
- DJANGO=2.2
1229
os:
1330
- linux
1431
matrix:
1532
include:
16-
- {python: 3.7, env: TOXENV=python37, dist: xenial, sudo: true}
33+
- { python: 2.7, env: TOXENV=upgradebeat111 }
34+
- { python: 2.7, env: TOXENV=upgradebeat120 }
35+
- { python: 3.5, env: TOXENV=upgradebeat130 }
36+
- { python: 3.5, env: TOXENV=upgradebeat140 }
1737
- { python: 3.5, env: TOXENV=flake8 }
1838
- { python: 2.7, env: TOXENV=flakeplus }
1939
- { python: 3.5, env: TOXENV=pydocstyle }
@@ -24,8 +44,10 @@ matrix:
2444
# - { python: 3.5, env: TOXENV=linkcheck }
2545
exclude:
2646
- { python: 2.7, env: DJANGO=2.0 }
47+
- { python: 2.7, env: DJANGO=2.1 }
2748
- { python: 2.7, env: DJANGO=2.2 }
2849
- { python: pypy, env: DJANGO=2.0 }
50+
- { python: pypy, env: DJANGO=2.1 }
2951
- { python: pypy, env: DJANGO=2.2 }
3052
install: travis_retry pip install -U tox-travis
3153
services: rabbitmq
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from __future__ import absolute_import, unicode_literals
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('django_celery_beat', '0010_auto_20190429_0326'),
10+
]
11+
12+
operations = [
13+
# delete the squashed migration history of migrations replaced by
14+
# 0005_add_solarschedule_events_choices_squashed_0009_merge_20181012_1416
15+
# the squashed file was convertd to a normal migration and the py files
16+
# were deleted, so we must also delete them from the history.
17+
# this is necessary because the squashed file was somehow screwing up
18+
# this history for version 1.3.0 installs that were upgraded.
19+
migrations.RunSQL([(
20+
"""
21+
delete from django_migrations where app='django_celery_beat' and (
22+
name = '0005_add_solarschedule_events_choices'
23+
or name = '0006_auto_20180210_1226'
24+
or name = '0006_auto_20180322_0932'
25+
or name = '0007_auto_20180521_0826'
26+
or name = '0008_auto_20180914_1922'
27+
)
28+
""", None)],
29+
reverse_sql=migrations.RunSQL.noop
30+
),
31+
]

requirements/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytest-django
33
pytz>dev
44
pytest<4.0.0
55
pytest-timeout
6+
ephem

tox.ini

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[tox]
22
envlist =
33
py27-django{111}
4-
py35-django{111,20}
5-
py37-django{111,20}
4+
py35-django{111,20,21,22}
5+
py36-django{111,20,21,22}
6+
py37-django{111,20,21,22}
67
pypy-django{111}
7-
8+
pypy3-django{111,20,21,22}
89
flake8
910
flakeplus
1011
apicheck
@@ -26,14 +27,13 @@ deps=
2627

2728
cov: -r{toxinidir}/requirements/test-django111.txt
2829

29-
django20: -r{toxinidir}/requirements/test-django20.txt
3030
django111: -r{toxinidir}/requirements/test-django111.txt
31+
django20: -r{toxinidir}/requirements/test-django20.txt
32+
django21: django>=2.1<2.2
3133
django22: -r{toxinidir}/requirements/test-django22.txt
3234

3335
py{27,py}: -r{toxinidir}/requirements/python2.txt
34-
py{35,37}: -r{toxinidir}/requirements/python3.txt
35-
36-
py{27,35,37,py},cov: ephem
36+
py{35,36,37,py3}: -r{toxinidir}/requirements/python3.txt
3737

3838
linkcheck,apicheck: -r{toxinidir}/requirements/docs.txt
3939
flake8,flakeplus,pydocstyle: -r{toxinidir}/requirements/pkgutils.txt
@@ -42,33 +42,97 @@ recreate = False
4242
commands =
4343
pip list
4444
py.test -xv
45-
# ensure we can migrate up, back, and up again
45+
46+
[testenv:upgradebeat111]
47+
basepython = python2.7
48+
whitelist_externals = *
49+
setenv =
50+
GIT_TAG = v1.1.1
51+
commands =
52+
# must use older versions for starting with older celery-beat
53+
pip install "django>=1.11.17,<2.0"
54+
pip install "celery<5.0.0"
55+
pip list
56+
# save current hash so we can come back to it
57+
bash -c "git rev-parse HEAD > commit.hash"
58+
# first install our starting version
59+
git fetch --tags
60+
git checkout {env:GIT_TAG}
61+
python manage.py migrate django_celery_beat
62+
# now return to previous hash and ensure all migrations continue to work
63+
bash -c "cat commit.hash | git checkout -"
4664
python manage.py migrate django_celery_beat
4765
python manage.py migrate django_celery_beat 0001
4866
python manage.py migrate django_celery_beat
4967

50-
[testenv:python37]
51-
basepython = python3.7
68+
[testenv:upgradebeat120]
69+
basepython = python2.7
5270
whitelist_externals = *
71+
setenv =
72+
GIT_TAG = v1.2.0
5373
commands =
54-
# for ubutu xenial we must fix erlang for rabbitmq-server to work
55-
sudo apt install -y wget
56-
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
57-
sudo apt-key add erlang_solutions.asc
58-
sudo apt update
59-
sudo apt install -y erlang
60-
sudo apt install -y erlang-nox
61-
sudo apt install -y rabbitmq-server
62-
sudo /etc/init.d/rabbitmq-server start
63-
sudo /etc/init.d/rabbitmq-server status
64-
65-
pip install ephem
66-
pip install -U https://github.com/celery/celery/zipball/master#egg=celery
67-
pip install -U https://github.com/celery/kombu/zipball/master#egg=kombu
74+
# must use older versions for starting with older celery-beat
75+
pip install "django>=1.11.17,<2.0"
76+
pip install "celery<5.0.0"
77+
pip list
78+
# save current hash so we can come back to it
79+
bash -c "git rev-parse HEAD > commit.hash"
80+
# first install our starting version
81+
git fetch --tags
82+
git checkout {env:GIT_TAG}
83+
python manage.py migrate django_celery_beat
84+
# now return to previous hash and ensure all migrations continue to work
85+
bash -c "cat commit.hash | git checkout -"
86+
python manage.py migrate django_celery_beat
87+
python manage.py migrate django_celery_beat 0001
88+
python manage.py migrate django_celery_beat
6889

90+
[testenv:upgradebeat130]
91+
basepython = python3.5
92+
setenv =
93+
GIT_TAG = v1.3.0
94+
whitelist_externals = *
95+
commands =
96+
# must use older versions for starting with older celery-beat
97+
pip install "django>=1.11.17,<2.0"
98+
pip install "celery<5.0.0"
6999
pip list
70-
py.test -xv
71-
# ensure we can migrate up, back, and up again
100+
# save current hash so we can come back to it
101+
bash -c "git rev-parse HEAD > commit.hash"
102+
# first install our starting version
103+
git fetch --tags
104+
git checkout {env:GIT_TAG}
105+
# run the migration for the older version
106+
python manage.py migrate django_celery_beat
107+
# now return to previous hash and ensure all migrations continue to work
108+
bash -c "cat commit.hash | git checkout -"
109+
pip install "django>=2.0.0"
110+
# now make sure migrations still work backward and forward
111+
python manage.py migrate django_celery_beat
112+
python manage.py migrate django_celery_beat 0001
113+
python manage.py migrate django_celery_beat
114+
115+
[testenv:upgradebeat140]
116+
basepython = python3.5
117+
whitelist_externals = *
118+
setenv =
119+
GIT_TAG = v1.4.0
120+
commands =
121+
# must use older versions for starting with older celery-beat
122+
pip install "django>=1.11.17,<2.0"
123+
pip install "celery<5.0.0"
124+
pip list
125+
# save current hash so we can come back to it
126+
bash -c "git rev-parse HEAD > commit.hash"
127+
# first install our starting version
128+
git fetch --tags
129+
git checkout {env:GIT_TAG}
130+
# run the migration for the older version
131+
python manage.py migrate django_celery_beat
132+
# now return to previous hash and ensure all migrations continue to work
133+
bash -c "cat commit.hash | git checkout -"
134+
pip install "django>=2.0.0"
135+
# now make sure migrations still work backward and forward
72136
python manage.py migrate django_celery_beat
73137
python manage.py migrate django_celery_beat 0001
74138
python manage.py migrate django_celery_beat

0 commit comments

Comments
 (0)