Skip to content

Commit

Permalink
commit to check if test cases will work
Browse files Browse the repository at this point in the history
  • Loading branch information
feyruzb committed Aug 30, 2024
1 parent ae8750c commit 53c313e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 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: 13 additions & 5 deletions web/server/codechecker_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,11 @@ 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!")
"does not exist! BITCH")

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

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

.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('#########################')
if not product:
return None

Expand Down
17 changes: 8 additions & 9 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,11 @@ 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.")
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 +185,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), 1)
self.assertEqual(len(products), 2)

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

# Use the same CodeChecker config that was used on the main server,
# but store into the secondary one.
Expand All @@ -214,9 +214,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
p_id2 = self._pr_client_2.getProducts('producttest_second', None)[0].id

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
self.assertIsNotNone(p_id)
self.assertEqual(p_id, p_id2,
"The products have different ID across the two "
Expand Down

0 comments on commit 53c313e

Please sign in to comment.