Пример #1
0
    def test_editing_endpoint(self):
        """
        Test if the product can successfully change its endpoint and keep
        the data.
        """

        pr_client = env.setup_product_client(self.test_workspace,
                                             product=self.product_name)
        product_id = pr_client.getCurrentProduct().id
        config = self._pr_client.getProductConfiguration(product_id)

        old_endpoint = config.endpoint
        new_endpoint = "edited_endpoint"

        # Save a new endpoint.
        config.endpoint = new_endpoint
        self.assertTrue(self._root_client.editProduct(product_id, config),
                        "Product edit didn't conclude.")

        # Check if the configuration now uses the new values.
        config = self._pr_client.getProductConfiguration(product_id)
        self.assertEqual(config.endpoint, new_endpoint,
                         "Server didn't save new endpoint.")

        # The old product is gone. Thus, connection should NOT happen.
        res = self._cc_client.getRunData(None, None, 0, None)
        self.assertIsNone(res)

        # The new product should connect and have the data.
        codechecker_cfg = self.test_cfg['codechecker_cfg']
        token = self._auth_client.performLogin("Username:Password", "cc:test")
        new_client = env.get_viewer_client(
            host=codechecker_cfg['viewer_host'],
            port=codechecker_cfg['viewer_port'],
            product=new_endpoint,  # Use the new product URL.
            endpoint='/CodeCheckerService',
            session_token=token)
        self.assertEqual(len(new_client.getRunData(None, None, 0, None)), 1,
                         "The new product did not serve the stored data.")

        # Set back to the old endpoint.
        config.endpoint = old_endpoint
        self.assertTrue(self._root_client.editProduct(product_id, config),
                        "Product configuration restore didn't conclude.")

        config = self._pr_client.getProductConfiguration(product_id)
        self.assertEqual(config.endpoint, old_endpoint,
                         "Server didn't save back to old endpoint.")

        # The old product should have its data available again.
        runs = self._cc_client.getRunData(None, None, 0, None)
        self.assertEqual(
            len(runs), 1,
            "We connected to old database but the run was missing.")
Пример #2
0
    def test_editing_endpoint(self):
        """
        Test if the product can successfully change its endpoint and keep
        the data.
        """

        pr_client = env.setup_product_client(
            self.test_workspace, product=self.product_name)
        product_id = pr_client.getCurrentProduct().id
        config = self._pr_client.getProductConfiguration(product_id)

        old_endpoint = config.endpoint
        new_endpoint = "edited_endpoint"

        # Save a new endpoint.
        config.endpoint = new_endpoint
        self.assertTrue(self._root_client.editProduct(product_id, config),
                        "Product edit didn't conclude.")

        # Check if the configuration now uses the new values.
        config = self._pr_client.getProductConfiguration(product_id)
        self.assertEqual(config.endpoint, new_endpoint,
                         "Server didn't save new endpoint.")

        # The old product is gone. Thus, connection should NOT happen.
        res = self._cc_client.getRunData(None)
        self.assertIsNone(res)

        # The new product should connect and have the data.
        codechecker_cfg = self.test_cfg['codechecker_cfg']
        token = self._auth_client.performLogin("Username:Password", "cc:test")
        new_client = env.get_viewer_client(
            host=codechecker_cfg['viewer_host'],
            port=codechecker_cfg['viewer_port'],
            product=new_endpoint,  # Use the new product URL.
            endpoint='/CodeCheckerService',
            session_token=token)
        self.assertEqual(len(new_client.getRunData(None)), 1,
                         "The new product did not serve the stored data.")

        # Set back to the old endpoint.
        config.endpoint = old_endpoint
        self.assertTrue(self._root_client.editProduct(product_id, config),
                        "Product configuration restore didn't conclude.")

        config = self._pr_client.getProductConfiguration(product_id)
        self.assertEqual(config.endpoint, old_endpoint,
                         "Server didn't save back to old endpoint.")

        # The old product should have its data available again.
        runs = self._cc_client.getRunData(None)
        self.assertEqual(
            len(runs), 1,
            "We connected to old database but the run was missing.")