Example #1
0
 def test_get_outliers_cpus(self):
     """
         Test whether the function returns the right values.
     """
     from flask_monitoringdashboard.database.outlier import get_outliers_cpus
     expected_cpus = []
     for i in range(OUTLIER_COUNT):
         expected_cpus.append('[%d, %d, %d, %d]' % (i, i + 1, i + 2, i + 3))
     with session_scope() as db_session:
         self.assertEqual(get_outliers_cpus(db_session, ENDPOINT_ID),
                          expected_cpus)
Example #2
0
def get_outlier_graph(session, endpoint_id):
    """
    :param session: session for the database
    :param endpoint_id: id of the endpoint
    :return: a list with data about each CPU performance
    """
    all_cpus = get_outliers_cpus(session, endpoint_id)
    cpu_data = [ast.literal_eval(cpu) for cpu in all_cpus]

    return [
        {'name': 'CPU core %d' % idx, 'values': simplify(data, 50), 'color': get_color(idx)}
        for idx, data in enumerate(zip(*cpu_data))
    ]
Example #3
0
def test_get_outliers_cpus(session, endpoint):
    expected_cpus = [
        '[{0}, {1}, {2}, {3}]'.format(i, i + 1, i + 2, i + 3) for i in range(2)
    ]
    assert get_outliers_cpus(session, endpoint.id) == expected_cpus