Skip to content

Commit

Permalink
Allow running of sql against the live DB.
Browse files Browse the repository at this point in the history
Reordered the tables in the domain downgrade script to avoid breaking the integrity constraints

To run the test:
./run_tests.sh -N  test_sql_upgrade

This version removed all of the code specific to running against a live DB and merged it into the
standard tests.

Fixed a couple downgrade functions that were failing.  They had not
been tested

Change-Id: Ie1214e5543bd08fde95652af2464cc9c80db449d
  • Loading branch information
Adam Young committed Jan 16, 2013
1 parent acc810d commit ed252e0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions tests/backend_sql.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[sql]
connection = sqlite://
#To Test MySQL:
#connection = mysql://root:keystone@localhost/keystone?charset=utf8
#To Test PostgreSQL:
#connection = postgresql://keystone:keystone@localhost/keystone?client_encoding=utf8
idle_timeout = 200

[identity]
Expand Down
17 changes: 16 additions & 1 deletion tests/test_sql_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,18 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""
To run these tests against a live database:
1. Modify the file `tests/backend_sql.conf` to use the connection for your
live database
2. Set up a blank, live database.
3. run the tests using
./run_tests.sh -N test_sql_upgrade
WARNING::
Your database will be wiped.
Do not do this against a Database with valuable data as
all data will be lost.
"""
import copy
import json
import uuid
Expand Down Expand Up @@ -54,6 +65,10 @@ def setUp(self):
self.repo_path, 0)

def tearDown(self):
table = sqlalchemy.Table("migrate_version", self.metadata,
autoload=True)
self.downgrade(0)
table.drop(self.engine, checkfirst=True)
super(SqlUpgradeTests, self).tearDown()

def test_blank_db_to_start(self):
Expand Down

0 comments on commit ed252e0

Please sign in to comment.