...
 
Commits (5)
......@@ -21,6 +21,7 @@
######################
*.db*
*.ini
privatekey.pem
autoProcessTV.cfg
/.imdbpie_cache/
/server.crt
......
# Changelog
- * 818f9c550 - 2019-07-13: Raised SQLite pool size to 200
- * 3e7748e54 - 2019-07-13: Refactoring database tests.
- * 63d34e6d1 - 2019-07-13: Pre-Release v9.4.133.dev1
- * fc3b30179 - 2019-07-13: Release v9.4.132
- * 999475fc0 - 2019-07-13: Updated git release flow.
- * f51300562 - 2019-07-13: Fixed issues with TornadoHTTP handler and self-signed SSL certificates. Fixed issue #382
- * 1fbb04ce4 - 2019-07-13: Fixes issues with generating self-signed SSL certificates on startup.
......
......@@ -147,7 +147,7 @@ class SRDatabase(object):
@property
def engine(self):
if self.db_type == 'sqlite':
return create_engine('sqlite:///{}'.format(self.db_path), echo=False, pool_size=100, poolclass=QueuePool,
return create_engine('sqlite:///{}'.format(self.db_path), echo=False, pool_size=200, poolclass=QueuePool,
connect_args={'check_same_thread': False, 'timeout': 10})
elif self.db_type == 'mysql':
mysql_engine = create_engine('mysql+pymysql://{}:{}@{}:{}/'.format(self.db_username, self.db_password, self.db_host, self.db_port), echo=False)
......
......@@ -203,6 +203,6 @@ class BaseHandler(RequestHandler, ABC):
def on_finish(self):
if self.db_session:
self.db_session.commit()
self.db_session.remove()
self.db_session.close()
super(BaseHandler, self).on_finish()
9.4.132
\ No newline at end of file
9.4.133
\ No newline at end of file
......@@ -26,6 +26,9 @@ import sys
import threading
import unittest
from sickrage.core.helpers import encryption
from sickrage.core.databases.main import MainDB
PROG_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'sickrage'))
if not (PROG_DIR in sys.path):
sys.path, remainder = sys.path[:1], sys.path[1:]
......@@ -42,8 +45,6 @@ LOCALE_DIR = os.path.join(PROG_DIR, 'locale')
gettext.install('messages', LOCALE_DIR, codeset='UTF-8', names=["ngettext"])
import sickrage
from sickrage.core.databases.cache import CacheDB
from sickrage.core.databases.main import MainDB
from sickrage.core.tv import episode
from sickrage.core import Core, Config, NameCache, Logger
from sickrage.providers import SearchProviders
......@@ -76,9 +77,18 @@ class SiCKRAGETestCase(unittest.TestCase):
sickrage.app.log = Logger()
sickrage.app.config = Config()
sickrage.app.web_host = '0.0.0.0'
sickrage.app.data_dir = self.TESTDIR
sickrage.app.config_file = self.TEST_CONFIG
sickrage.app.main_db = MainDB(db_type='sqlite',
db_prefix='sickrage',
db_host='localhost',
db_port='3306',
db_username='sickrage',
db_password='sickrage')
encryption.initialize()
sickrage.app.config.load()
sickrage.app.config.naming_pattern = 'Season.%0S/%S.N.S%0SE%0E.%E.N'
......@@ -88,7 +98,7 @@ class SiCKRAGETestCase(unittest.TestCase):
def setUp(self, **kwargs):
if self.TESTALL and self.__module__ in self.TESTSKIPPED:
raise unittest.SkipTest()
raise unittest.SkipTest('Skipping Test')
if not os.path.exists(self.FILEDIR):
os.makedirs(self.FILEDIR)
......@@ -125,12 +135,8 @@ class SiCKRAGETestDBCase(SiCKRAGETestCase):
def tearDown(self):
super(SiCKRAGETestDBCase, self).tearDown()
for db in [sickrage.app.main_db, sickrage.app.cache_db]:
db.close()
if os.path.exists(self.TESTDB_DIR):
shutil.rmtree(self.TESTDB_DIR)
if os.path.exists(self.TESTDBBACKUP_DIR):
shutil.rmtree(self.TESTDBBACKUP_DIR)
if os.path.isfile(sickrage.app.main_db.db_path):
os.unlink(sickrage.app.main_db.db_path)
def load_tests(loader, tests):
......
vcrpy-unittest==0.1.6
\ No newline at end of file
......@@ -19,46 +19,54 @@
import datetime
import threading
import unittest
import sickrage
import tests
from sickrage.core.tv.show.helpers import find_show
from sickrage.core.common import UNAIRED
from sickrage.core.databases.main import MainDB
from sickrage.core.tv.episode import TVEpisode
from sickrage.core.tv.show import TVShow
from sickrage.core.databases.main import MainDB
class DBBasicTests(tests.SiCKRAGETestDBCase):
def setUp(self):
@MainDB.with_session
def setUp(self, session=None):
super(DBBasicTests, self).setUp()
show = TVShow(1, 0o0001, "en")
sickrage.app.showlist += [show]
show = TVShow(**{'indexer': 1, 'indexer_id': 0o0001, 'lang': 'en'})
session.add(show)
session.commit()
ep = TVEpisode(show, 1, 1)
ep = TVEpisode(**{'showid': show.indexer_id, 'indexer': 1, 'season': 1, 'episode': 1, 'location': ''})
session.add(ep)
ep.indexer_id = 1
ep.name = "test episode 1"
ep.airdate = datetime.date.fromordinal(733832)
ep.status = UNAIRED
ep.save_to_db()
ep = TVEpisode(show, 1, 2)
session.commit()
ep = TVEpisode(**{'showid': show.indexer_id, 'indexer': 1, 'season': 1, 'episode': 2, 'location': ''})
session.add(ep)
ep.indexer_id = 2
ep.name = "test episode 2"
ep.airdate = datetime.date.fromordinal(733832)
ep.status = UNAIRED
ep.save_to_db()
ep = TVEpisode(show, 1, 3)
session.commit()
ep = TVEpisode(**{'showid': show.indexer_id, 'indexer': 1, 'season': 1, 'episode': 3, 'location': ''})
session.add(ep)
ep.indexer_id = 3
ep.name = "test episode 3"
ep.airdate = datetime.date.fromordinal(733832)
ep.status = UNAIRED
ep.save_to_db()
session.commit()
def test_unaired(self):
@MainDB.with_session
def test_unaired(self, session=None):
count = 0
for episode_obj in sickrage.app.main_db.session().query(TVEpisode):
for episode_obj in session.query(TVEpisode):
if all([episode_obj.status == UNAIRED, episode_obj.season > 0, episode_obj.airdate > datetime.date.min]):
count += 1
......@@ -70,6 +78,18 @@ class DBBasicTests(tests.SiCKRAGETestDBCase):
self.assertEqual(count, 3)
@MainDB.with_session
def test_multithread(self, session=None):
threads = []
for __ in range(1, 200):
threads.append(threading.Thread(target=lambda: session.query(TVEpisode).all()))
for t in threads:
t.start()
for t in threads:
t.join()
if __name__ == '__main__':
print("==================")
......