mirror of
https://github.com/ansible/awx.git
synced 2026-02-27 15:58:45 -03:30
fact save test performance
This commit is contained in:
155011
awx/fact/tests/data/file_scan.json
Normal file
155011
awx/fact/tests/data/file_scan.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
# Python
|
# Python
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from django.utils.timezone import now
|
import os
|
||||||
from dateutil.relativedelta import relativedelta
|
import json
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
|
from django.utils.timezone import now
|
||||||
|
from dateutil.relativedelta import relativedelta
|
||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx.fact.models.fact import * # noqa
|
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.id, f_obj.id)
|
||||||
self.assertEqual(v.fact.module, 'packages')
|
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):
|
class FactGetHostVersionTest(BaseFactTest):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(FactGetHostVersionTest, self).setUp()
|
super(FactGetHostVersionTest, self).setUp()
|
||||||
|
|||||||
Reference in New Issue
Block a user