Пример #1
0
    def get_top_consumers_for_period_test(self):
        self._cleanup()

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(0, 100):
            collection.insert({
                'server_id': self.server['_id'],
                't': i,
                'data': [{
                    'p': process['_id'],
                    'm': i,
                    'c': 99
                }]
            })

        result = process_model.get_top_consumers_for_period(date_from=10,
                                                            date_to=20,
                                                            server=self.server,
                                                            metric_type='cpu')

        for r in result:
            eq_(r['name'], 'test')
            eq_(r['c'], 99)
Пример #2
0
    def get_cpu_data_test(self):
        self._cleanup()

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(0, 100):
            collection.insert({
                'server_id': self.server['_id'],
                't': i,
                'data': [{
                    'p': process['_id'],
                    'm': i,
                    'c': 99
                }]
            })

        result = process_model.get_data_after(timestamp=10,
                                              enddate=20,
                                              server=self.server,
                                              process=process,
                                              check='cpu')

        chart_data = result[0]['data']

        eq_(len(chart_data), 11)

        for entry in chart_data:
            assert entry['x'] >= 10
            assert entry['x'] <= 20

            assert entry['y'] == 99
Пример #3
0
    def get_all_for_server_test(self):
        self._cleanup()

        for i in range(0, 10):
            process_model.insert({'name': i, 'server': self.server['_id']})

        result = process_model.get_all_for_server(self.server['_id'])

        eq_(result.count(), 10)
Пример #4
0
    def get_all_for_server_test(self):
        self._cleanup()

        for i in range(0, 10):
            process_model.insert({'name': i, 'server': self.server['_id']})
        
        result = process_model.get_all_for_server(self.server['_id'])

        eq_(result.count(), 10)
Пример #5
0
    def get_first_check_date_test(self):
        self._cleanup()


        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(11, 100):
            collection.insert({'server_id': self.server['_id'], 't': i, 'data': [{'p': process['_id'], 'm': i, 'c': 99}]})
        

        result = process_model.get_first_check_date( server=self.server)

        eq_(result, 11)
Пример #6
0
    def setUp(self):
        User.objects.all().delete()

        self.c = Client()
        self.user = User.objects.create_user(password='******',
                                             email='*****@*****.**')

        self.account_id = 1
        self.c.login(username='******', password='******')

        server_model.add('testserver', account_id=self.account_id)
        self.server = server_model.collection.find_one()
        self.server_id = self.server['_id']

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        self.process = process_model.collection.find_one()
Пример #7
0
    def get_top_consumers_for_period_test(self):
        self._cleanup()
        

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(0, 100):
            collection.insert({'server_id': self.server['_id'], 't': i, 'data': [{'p': process['_id'], 'm': i, 'c': 99}]})
        

        result = process_model.get_top_consumers_for_period(date_from=10, date_to=20, server=self.server, metric_type='cpu')

        for r in result:
            eq_(r['name'], 'test')
            eq_(r['c'], 99)
Пример #8
0
    def setUp(self):
        User.objects.all().delete()
        
        self.c = Client()
        self.user = User.objects.create_user(password='******', email='*****@*****.**')
        

        self.account_id = 1
        self.c.login(username='******', password='******')


        server_model.add('testserver', account_id=self.account_id)
        self.server = server_model.collection.find_one()
        self.server_id = self.server['_id']


        process_model.insert({'name': 'test', 'server': self.server['_id']})
        self.process = process_model.collection.find_one()
Пример #9
0
    def get_first_check_date_test(self):
        self._cleanup()

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(11, 100):
            collection.insert({
                'server_id': self.server['_id'],
                't': i,
                'data': [{
                    'p': process['_id'],
                    'm': i,
                    'c': 99
                }]
            })

        result = process_model.get_first_check_date(server=self.server)

        eq_(result, 11)
Пример #10
0
    def get_cpu_data_test(self):
        self._cleanup()
        

        process_model.insert({'name': 'test', 'server': self.server['_id']})
        process = process_model.collection.find_one()

        collection = process_model.mongo.get_collection("process_data")
        for i in range(0, 100):
            collection.insert({'server_id': self.server['_id'], 't': i, 'data': [{'p': process['_id'], 'm': i, 'c': 99}]})
        

        result = process_model.get_data_after(timestamp=10, enddate=20, server=self.server, process=process, check='cpu')

        chart_data = result[0]['data']
        
        eq_(len(chart_data), 11)

        for entry in chart_data:
            assert entry['x'] >= 10
            assert entry['x'] <= 20

            assert entry['y'] == 99