def testWaitForFlusherAndGarbageCollect(self, deleteMetricMock, getAllCustomMetricsMock, _timeSleepMock):
        oldFlusherMetricName = delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "0"

        flusherMetricName = delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "1"

        getAllCustomMetricsResultGroups = [
            [{"name": "XIGNITE.FOOBAR.CLOSINGPRICE"}],
            [{"name": "XIGNITE.FOOBAR.CLOSINGPRICE"}, {"name": oldFlusherMetricName}],
            [{"name": "XIGNITE.FOOBAR.CLOSINGPRICE"}, {"name": flusherMetricName}],
        ]

        # Patch getAllCustomMetrics to return all negatives and positives
        getAllCustomMetricsMock.side_effect = iter(getAllCustomMetricsResultGroups)

        # Execute
        delete_companies._waitForFlusherAndGarbageCollect(
            engineServer="host", engineApiKey="apikey", flusherMetricName=flusherMetricName
        )

        # Validate

        self.assertEqual(getAllCustomMetricsMock.call_count, len(getAllCustomMetricsResultGroups))

        expectedDeleteMetricCalls = [
            mock.call(host="host", apiKey="apikey", metricName=oldFlusherMetricName),
            mock.call(host="host", apiKey="apikey", metricName=flusherMetricName),
        ]

        self.assertSequenceEqual(deleteMetricMock.mock_calls, expectedDeleteMetricCalls)
Beispiel #2
0
    def testWaitForFlusherAndGarbageCollect(self, deleteMetricMock,
                                            getAllCustomMetricsMock,
                                            _timeSleepMock):
        oldFlusherMetricName = (
            delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "0")

        flusherMetricName = (
            delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "1")

        getAllCustomMetricsResultGroups = [
            [{
                "name": "XIGNITE.FOOBAR.CLOSINGPRICE"
            }],
            [{
                "name": "XIGNITE.FOOBAR.CLOSINGPRICE"
            }, {
                "name": oldFlusherMetricName
            }],
            [{
                "name": "XIGNITE.FOOBAR.CLOSINGPRICE"
            }, {
                "name": flusherMetricName
            }],
        ]

        # Patch getAllCustomMetrics to return all negatives and positives
        getAllCustomMetricsMock.side_effect = iter(
            getAllCustomMetricsResultGroups)

        # Execute
        delete_companies._waitForFlusherAndGarbageCollect(
            engineServer="host",
            engineApiKey="apikey",
            flusherMetricName=flusherMetricName)

        # Validate

        self.assertEqual(getAllCustomMetricsMock.call_count,
                         len(getAllCustomMetricsResultGroups))

        expectedDeleteMetricCalls = [
            mock.call(host="host",
                      apiKey="apikey",
                      metricName=oldFlusherMetricName),
            mock.call(host="host",
                      apiKey="apikey",
                      metricName=flusherMetricName)
        ]

        self.assertSequenceEqual(deleteMetricMock.mock_calls,
                                 expectedDeleteMetricCalls)
    def testWaitForFlusherAndGarbageCollectWithFlusherNotFound(self, getAllCustomMetricsMock, timeMock, sleepMock):

        time_test_utils.configureTimeAndSleepMocks(timeMock, sleepMock)

        flusherMetricName = delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "1"

        # Patch getAllCustomMetrics to return all negatives and positives
        getAllCustomMetricsMock.return_value = [{"name": "XIGNITE.FOOBAR.CLOSINGPRICE"}]

        # Execute and validate
        with self.assertRaises(delete_companies.FlusherMetricNotFound):
            delete_companies._waitForFlusherAndGarbageCollect(
                engineServer="host", engineApiKey="apikey", flusherMetricName=flusherMetricName
            )
Beispiel #4
0
    def testWaitForFlusherAndGarbageCollectWithFlusherNotFound(
            self, getAllCustomMetricsMock, timeMock, sleepMock):

        time_test_utils.configureTimeAndSleepMocks(timeMock, sleepMock)

        flusherMetricName = (
            delete_companies._DATA_PATH_FLUSHER_METRIC_PREFIX + "1")

        # Patch getAllCustomMetrics to return all negatives and positives
        getAllCustomMetricsMock.return_value = [{
            "name":
            "XIGNITE.FOOBAR.CLOSINGPRICE"
        }]

        # Execute and validate
        with self.assertRaises(delete_companies.FlusherMetricNotFound):
            delete_companies._waitForFlusherAndGarbageCollect(
                engineServer="host",
                engineApiKey="apikey",
                flusherMetricName=flusherMetricName)