- Fix some other group_by clauses

- Fix garbage_collect for an empty list (fixes a test)
- Add a script which runs the full test suite against mysql and postgres (note: QueueTest's are broken for MySQL, but they obviously work in production, so they need to be fixed)
This commit is contained in:
Joseph Schorr 2014-11-13 12:51:37 -05:00
parent a2e2dcb010
commit d73747ce1d
5 changed files with 104 additions and 17 deletions

60
test/fulldbtest.sh Executable file
View file

@ -0,0 +1,60 @@
set -e
up_mysql() {
# Run a SQL database on port 3306 inside of Docker.
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql
# Sleep for 5s to get MySQL get started.
echo 'Sleeping for 10...'
sleep 10
# Add the database to mysql.
docker run --rm --link mysql:mysql mysql sh -c 'echo "create database genschema" | mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -ppassword'
}
down_mysql() {
docker kill mysql
docker rm mysql
}
up_postgres() {
# Run a SQL database on port 5432 inside of Docker.
docker run --name postgres -p 5432:5432 -d postgres
# Sleep for 5s to get SQL get started.
echo 'Sleeping for 5...'
sleep 5
# Add the database to postgres.
docker run --rm --link postgres:postgres postgres sh -c 'echo "create database genschema" | psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
}
down_postgres() {
docker kill postgres
docker rm postgres
}
run_tests() {
TEST_DATABASE_URI=$1 TEST=true python -m unittest discover
}
# Test (and generate, if requested) via MySQL.
echo '> Starting MySQL'
up_mysql
echo '> Running Full Test Suite (mysql)'
set +e
run_tests "mysql+pymysql://root:password@192.168.59.103/genschema"
set -e
down_mysql
# Test via Postgres.
echo '> Starting Postgres'
up_postgres
echo '> Running Full Test Suite (postgres)'
set +e
run_tests "postgresql://postgres@192.168.59.103/genschema"
set -e
down_postgres

View file

@ -1328,7 +1328,9 @@ class TestRepoBuilds(ApiTestCase):
status_json = self.getJsonResponse(RepositoryBuildStatus,
params=dict(repository=ADMIN_ACCESS_USER + '/building', build_uuid=build['id']))
self.assertEquals(status_json, build)
self.assertEquals(status_json['id'], build['id'])
self.assertEquals(status_json['resource_key'], build['resource_key'])
self.assertEquals(status_json['trigger'], build['trigger'])
class TestRequestRepoBuild(ApiTestCase):
def test_requestrepobuild(self):
@ -2051,7 +2053,14 @@ class TestOrganizationApplications(ApiTestCase):
json = self.getJsonResponse(OrganizationApplications, params=dict(orgname=ORGANIZATION))
self.assertEquals(2, len(json['applications']))
self.assertEquals(FAKE_APPLICATION_CLIENT_ID, json['applications'][0]['client_id'])
found = False
for application in json['applications']:
if application['client_id'] == FAKE_APPLICATION_CLIENT_ID:
found = True
break
self.assertTrue(found)
# Add a new application.
json = self.postJsonResponse(OrganizationApplications, params=dict(orgname=ORGANIZATION),
@ -2063,7 +2072,6 @@ class TestOrganizationApplications(ApiTestCase):
# Retrieve the apps list again
list_json = self.getJsonResponse(OrganizationApplications, params=dict(orgname=ORGANIZATION))
self.assertEquals(3, len(list_json['applications']))
self.assertEquals(json, list_json['applications'][2])
class TestOrganizationApplicationResource(ApiTestCase):

View file

@ -1,3 +1,5 @@
import os
from datetime import datetime, timedelta
from config import DefaultConfig
@ -14,8 +16,11 @@ class FakeTransaction(object):
class TestConfig(DefaultConfig):
TESTING = True
DB_URI = 'sqlite:///:memory:'
DB_CONNECTION_ARGS = {}
DB_URI = os.environ.get('TEST_DATABASE_URI', 'sqlite:///:memory:')
DB_CONNECTION_ARGS = {
'threadlocals': True,
'autorollback': True
}
@staticmethod
def create_transaction(db):