def test_database_counts(organization_factory, job_template_factory, workflow_job_template_factory): objs = organization_factory("org", superusers=["admin"]) jt = job_template_factory( "test", organization=objs.organization, inventory="test_inv", project="test_project", credential="test_cred", ) workflow_job_template_factory("test") models.Team(organization=objs.organization).save() models.Host(inventory=jt.inventory).save() models.Schedule( rrule="DTSTART;TZID=America/New_York:20300504T150000", unified_job_template=jt.job_template, ).save() models.CustomInventoryScript(organization=objs.organization).save() counts = collectors.counts(None) for key in ( "organization", "team", "user", "inventory", "credential", "project", "job_template", "workflow_job_template", "host", "schedule", "custom_inventory_script", ): assert counts[key] == 1
def test_metrics_counts(organization_factory, job_template_factory, workflow_job_template_factory): objs = organization_factory('org', superusers=['admin']) jt = job_template_factory('test', organization=objs.organization, inventory='test_inv', project='test_project', credential='test_cred') workflow_job_template_factory('test') models.Team(organization=objs.organization).save() models.Host(inventory=jt.inventory).save() models.Schedule(rrule='DTSTART;TZID=America/New_York:20300504T150000', unified_job_template=jt.job_template).save() models.CustomInventoryScript(organization=objs.organization).save() output = metrics() gauges = text_string_to_metric_families(output.decode('UTF-8')) for gauge in gauges: for sample in gauge.samples: # name, label, value, timestamp, exemplar name, _, value, _, _ = sample assert EXPECTED_VALUES[name] == value
def test_database_counts(organization_factory, job_template_factory, workflow_job_template_factory): objs = organization_factory('org', superusers=['admin']) jt = job_template_factory('test', organization=objs.organization, inventory='test_inv', project='test_project', credential='test_cred') workflow_job_template_factory('test') models.Team(organization=objs.organization).save() models.Host(inventory=jt.inventory).save() models.Schedule(rrule='DTSTART;TZID=America/New_York:20300504T150000', unified_job_template=jt.job_template).save() models.CustomInventoryScript(organization=objs.organization).save() counts = collectors.counts(None) for key in ('organization', 'team', 'user', 'inventory', 'credential', 'project', 'job_template', 'workflow_job_template', 'host', 'schedule', 'custom_inventory_script'): assert counts[key] == 1