1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

fact save test performance

This commit is contained in:
Chris Meyers 2015-07-14 08:52:27 -04:00
parent fef3d5d2b0
commit d784b72adb
2 changed files with 155035 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,12 @@
# Python
from __future__ import absolute_import
from django.utils.timezone import now
from dateutil.relativedelta import relativedelta
import os
import json
# Django
from django.utils.timezone import now
from dateutil.relativedelta import relativedelta
# AWX
from awx.fact.models.fact import * # noqa
@ -57,6 +59,26 @@ class FactTest(BaseFactTest):
self.assertEqual(v.fact.id, f_obj.id)
self.assertEqual(v.fact.module, 'packages')
# Note: Take the failure of this with a grain of salt.
# The test almost entirely depends on the specs of the system running on.
def test_add_fact_performance_4mb_file(self):
timestamp = now().replace(microsecond=0)
host = FactHost(hostname="hosty", inventory_id=1).save()
from awx.fact import tests
with open('%s/data/file_scan.json' % os.path.dirname(os.path.realpath(tests.__file__))) as f:
data = json.load(f)
t1 = now()
(f_obj, v_obj) = Fact.add_fact(host=host, timestamp=timestamp, module='packages', fact=data)
t2 = now()
diff = (t2-t1).total_seconds()
print("add_fact save time: %s (s)" % diff)
self.assertLessEqual(diff, 4)
f = Fact.objects.get(id=f_obj.id)
v = FactVersion.objects.get(id=v_obj.id)
class FactGetHostVersionTest(BaseFactTest):
def setUp(self):
super(FactGetHostVersionTest, self).setUp()