Ejemplo n.º 1
0
class GetProcMeminfoTestCase(LepvTestCase):
    def setUp(self):
        self.profiler = MemoryProfiler('')

    def validate(self, expected, actual, expected_match_type):

        print("Actual:")
        pprint(actual)

        compare_result = DictUtil.compare(actual, expected)

        if expected_match_type == 'equals':
            self.assertEqual(compare_result, 0,
                             "Expected and Actual does not match")
        elif expected_match_type == 'contains':
            self.assertIn(compare_result, [0, 1],
                          "Actual does not contain the expected")
        else:
            print("")

    @file_data("unittests.json")
    def test(self, kernel, os, cpu, note, lepdResult, expected,
             expected_match_type):
        self.describe(kernel, os, cpu, note, expected_match_type, expected)

        # getStatus -> GetProcMeminfo
        actual = self.profiler.getStatus(lepdResult)
        self.validate(expected, actual, expected_match_type)
Ejemplo n.º 2
0
def getMemoryStatus(server):

    profiler = MemoryProfiler(server)
    data = profiler.getStatus()

    if 'request_id' in request.args:
        data['response_id'] = request.args['request_id']

    return jsonify(data)
Ejemplo n.º 3
0
def get_memory_status(request):
    print('received memory.status.req: ' + request['server'])

    server = request['server']
    profiler = MemoryProfiler(server)
    data = {}
    data = profiler.getStatus()

    if "request_id" in request:
        data['response_id'] = request['request_id']

    emit('memory.status.res', data)