def test_result_size_limit(self): db = connect() assert db.result_size_limit == 256 db.build('<x:int64>[i=1:1000; j=1:1000]', 'i')[:] db.result_size_limit = 1 assert db.result_size_limit == 1 # with pytest.raises(requests.exceptions.HTTPError) as exc: # db.build('<x:int64>[i=1:1000; j=1:1000]', 'i')[:] # assert 'SCIDB_LE_FILE_WRITE_ERROR' in str(exc.value) db = connect(result_size_limit=1) assert db.result_size_limit == 1
def test_admin(self): db_admin = connect(admin=True) assert db_admin.admin is True ar = 'test_admin' db_admin.build('<x:double>[i=1:10000;j=1:1000]', 'random()').store(ar) st = time.time() for _ in range(5): th = threading.Thread( target=lambda: connect(no_ops=True).iquery( 'op_count(sort({}))'.format(ar))) th.start() time.sleep(5) que = """project( filter( list('queries'), query_string='op_count(sort({}))'), query_id)""".format(ar) qids = db_admin.iquery_readlines(que) while qids: for qid in qids: try: db_admin.cancel(qid) except requests.HTTPError as e: if e.response.status_code == 502: db_admin = connect(admin=True) break elif e.response.status_code != 406: raise e time.sleep(5) qids = db_admin.iquery_readlines(que) # Should finish in less then five minutes assert time.time() - st < 5 * 60 db_admin.remove(ar)
def db(): return connect()
def test_connect_exception(self, args): with pytest.raises(Exception): connect(**args)
def test_flood(self): for i in range(100): db = connect() del db gc.collect()