From 53c313e310eb17f65568900ed424e2bb75a44ad4 Mon Sep 17 00:00:00 2001 From: Baghirov Feyruz Date: Fri, 30 Aug 2024 15:42:49 +0200 Subject: [PATCH] commit to check if test cases will work --- .../codechecker_server/api/product_server.py | 14 +++++++------- web/server/codechecker_server/server.py | 18 +++++++++++++----- .../products/test_config_db_share.py | 17 ++++++++--------- 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/web/server/codechecker_server/api/product_server.py b/web/server/codechecker_server/api/product_server.py index e9ce9ff4f2..bcf9b841f1 100644 --- a/web/server/codechecker_server/api/product_server.py +++ b/web/server/codechecker_server/api/product_server.py @@ -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.") diff --git a/web/server/codechecker_server/server.py b/web/server/codechecker_server/server.py index f7c8f30341..7554a51ef6 100644 --- a/web/server/codechecker_server/server.py +++ b/web/server/codechecker_server/server.py @@ -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. @@ -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. """ @@ -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 diff --git a/web/tests/functional/products/test_config_db_share.py b/web/tests/functional/products/test_config_db_share.py index 601971094d..44b2e52c8c 100644 --- a/web/tests/functional/products/test_config_db_share.py +++ b/web/tests/functional/products/test_config_db_share.py @@ -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) @@ -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. @@ -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 "