Skip to content

Commit

Permalink
fixed sqlite error
Browse files Browse the repository at this point in the history
  • Loading branch information
feyruzb committed Sep 2, 2024
1 parent 53c313e commit 82340db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 28 deletions.
14 changes: 7 additions & 7 deletions web/server/codechecker_server/api/product_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ def addProduct(self, product):
codechecker_api_shared.ttypes.ErrorCode.GENERAL,
msg)

# db_in_use = self.__server.get_if_database_in_use(product.connection)
# if db_in_use:
# LOG.error("Database '%s' is already in use by another product!",
# product.connection.database)
# raise codechecker_api_shared.ttypes.RequestFailed(
# codechecker_api_shared.ttypes.ErrorCode.DATABASE,
# "Database is already in use by another product!")
db_in_use = self.__server.get_if_database_in_use(product.connection)
if db_in_use:
LOG.error("Database '%s' is already in use by another product!",
product.connection.database)
raise codechecker_api_shared.ttypes.RequestFailed(
codechecker_api_shared.ttypes.ErrorCode.DATABASE,
"Database is already in use by another product!")

if self.add_product_support(product):
LOG.info("Database support added successfully.")
Expand Down
18 changes: 5 additions & 13 deletions web/server/codechecker_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,10 @@ def __check_prod_db(self, product_endpoint):
"""

product = self.server.get_product(product_endpoint)
LOG.info("####Request's product: %s", product_endpoint)
if not product:
raise ValueError(
f"The product with the given endpoint '{product_endpoint}' "
"does not exist! BITCH")
"does not exist!")

if product.db_status == DBStatus.OK:
# No reconnect needed.
Expand Down Expand Up @@ -951,7 +950,7 @@ def num_products(self):
"""
return len(self.__products)

def get_product(self, endpoint): # marker
def get_product(self, endpoint):
"""
Get the product connection object for the given endpoint, or None.
"""
Expand All @@ -966,17 +965,10 @@ def get_product(self, endpoint): # marker
# database.
try:
cfg_sess = self.config_session()
holder = cfg_sess.query(ORMProduct) \
product = cfg_sess.query(ORMProduct) \
.filter(ORMProduct.endpoint == endpoint) \
.limit(1)
LOG.info('#########################')
LOG.info('holder: %s', holder)
LOG.info('######LOW###################')
product = holder.one_or_none()
LOG.info(product)
LOG.info('######MIDDLE###################')
LOG.info(product)
LOG.info('#########################')
.limit(1).one_or_none()

if not product:
return None

Expand Down
15 changes: 7 additions & 8 deletions web/tests/functional/products/test_config_db_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,10 @@ def create_test_product(product_name, product_endpoint):

product_cfg = create_test_product('producttest_second 2',
'producttest_second_2')
self.assertTrue(self._pr_client_2.addProduct(product_cfg),
"Cannot create product on secondary server.")

# with self.assertRaises(RequestFailed):
# self._pr_client_2.addProduct(product_cfg)
with self.assertRaises(RequestFailed):
self._pr_client_2.addProduct(product_cfg)

# Product name full string match.
products = self._pr_client_2.getProducts('producttest_second', None)
self.assertEqual(len(products), 1)
Expand All @@ -185,10 +184,10 @@ def create_test_product(product_name, product_endpoint):

# Product name substring match.
products = self._pr_client_2.getProducts('producttest_second*', None)
self.assertEqual(len(products), 2)
self.assertEqual(len(products), 1)

products = self._pr_client_2.getProducts(None, 'producttest_second*')
self.assertEqual(len(products), 2)
self.assertEqual(len(products), 1)

# Use the same CodeChecker config that was used on the main server,
# but store into the secondary one.
Expand All @@ -214,8 +213,8 @@ def create_test_product(product_name, product_endpoint):
"connected through the main server.")

# Remove the product through the main server.
p_id = self._root_client.getProducts('producttest_second', None)[0].id # PROBLEM HERE
p_id2 = self._pr_client_2.getProducts('producttest_second', None)[0].id # PROBLEM HERE
p_id = self._root_client.getProducts('producttest_second', None)[0].id
p_id2 = self._pr_client_2.getProducts('producttest_second', None)[0].id
self.assertIsNotNone(p_id)
self.assertEqual(p_id, p_id2,
"The products have different ID across the two "
Expand Down

0 comments on commit 82340db

Please sign in to comment.