Exemplo n.º 1
0
 def test_run_results(self):
     run_name = 'teuthology-2014-03-27_00:00:00-x-x-x-x-x'
     new_run = Run(run_name)
     stats_in = {
         'pass': 9,
         'fail': 1,
         'dead': 6,
         'running': 5,
         'sha1': None,
         'waiting': 1,
         'unknown': 1,
         'queued': 1
     }
     statuses = stats_in.keys()
     stats_in['total'] = sum(_ for _ in stats_in.values() if _)
     stats_out = {}
     for i in range(stats_in['total']):
         for status in statuses:
             count = stats_out.get(status, 0)
             count += 1
             if count <= stats_in[status]:
                 break
         Job(dict(job_id=i, status=status), new_run)
         stats_out[status] = count
     assert new_run.get_results() == stats_in
Exemplo n.º 2
0
 def test_empty_run_deletion(self):
     run_name = 'test_empty_run_deletion'
     new_run = Run(run_name)
     models.commit()
     new_run.delete()
     models.commit()
     assert not Run.filter_by(name=run_name).first()
Exemplo n.º 3
0
 def test_updated(self):
     run_name = 'test_updated'
     new_run = Run(run_name)
     for i in range(1, 5):
         Job(dict(job_id=i), new_run)
     models.commit()
     new_run = Run.filter_by(name=run_name).first()
     assert new_run.updated == new_run.get_jobs()[-1].updated
Exemplo n.º 4
0
 def test_job_deletion(self):
     run_name = 'test_job_deletion'
     new_run = Run(run_name)
     Job({'job_id': '42'}, new_run)
     Job({'job_id': '9999'}, new_run)
     models.commit()
     new_run.delete()
     models.commit()
     assert not Job.filter_by(job_id='9999').first()
Exemplo n.º 5
0
 def test_jobs_count(self):
     Run.query.delete()
     Job.query.delete()
     new_run = Run('test_jobs_count')
     Job({}, new_run)
     Job({}, new_run)
     models.commit()
     run_as_json = Run.get(1).__json__()
     assert run_as_json['jobs_count'] == 2
Exemplo n.º 6
0
 def test_run_deletion(self):
     run_name = 'test_run_deletion'
     new_run = Run(run_name)
     Job({'job_id': '42'}, new_run)
     Job({'job_id': '120'}, new_run)
     Job({'job_id': '4'}, new_run)
     models.commit()
     new_run.delete()
     models.commit()
     assert not Run.filter_by(name=run_name).first()
Exemplo n.º 7
0
 def test_job_started_queued(self):
     run_name = 'test_job_started_queued'
     run = Run(run_name)
     job_id = '42'
     job = Job(dict(name=run_name, job_id=job_id, status='queued'), run)
     job.update(dict(status='running'))
     assert job.started is not None
Exemplo n.º 8
0
 def test_job_creates_node(self):
     run_name = 'test_job_creates_node'
     node_name = 'node.name'
     targets = {'foo@' + node_name: ''}
     new_run = Run(run_name)
     Job(dict(targets=targets), new_run)
     assert Node.get(1).name == node_name
Exemplo n.º 9
0
 def test_basic_deletion(self):
     new_run = Run('test_basic_deletion')
     new_job = Job({'job_id': '42'}, new_run)
     models.commit()
     new_job.delete()
     models.commit()
     assert not Job.filter_by(job_id='42').first()
Exemplo n.º 10
0
 def test_run_status_queued_to_running(self):
     run_name = "run_status_queued_to_running"
     new_run = Run(run_name)
     job = Job(dict(job_id=1, status='queued'), new_run)
     Job(dict(job_id=2, status='queued'), new_run)
     job.update(dict(status='running'))
     assert new_run.status == 'running'
Exemplo n.º 11
0
 def test_run_multi_machine_type(self):
     run_name = 'teuthology-2014-10-06_19:30:01-upgrade:dumpling-firefly-x:stress-split-giant-distro-basic-multi'
     new_run = Run(run_name)
     machine_type = 'plana,mira,burnupi'
     Job(dict(job_id=1, machine_type=machine_type), new_run)
     models.commit()
     assert new_run.machine_type == machine_type
Exemplo n.º 12
0
 def test_scheduled(self):
     run_name = 'teuthology-2013-10-23_01:35:02-upgrade-small-next-testing-basic-vps'  # noqa
     new_run = Run(run_name)
     scheduled_aware = pytz.utc.localize(new_run.scheduled)
     localtz = tzlocal.get_localzone()
     scheduled_local = scheduled_aware.astimezone(localtz)
     scheduled_local_naive = scheduled_local.replace(tzinfo=None)
     assert str(scheduled_local_naive) == '2013-10-23 01:35:02'
Exemplo n.º 13
0
 def test_job_slice_valid_many(self):
     run_name = 'test_job_slice_valid_many'
     new_run = Run(run_name)
     new_job = Job({'job_id': '9', 'description': 'describe the test'},
                   new_run)
     job_slice = new_job.slice('description,job_id,href')
     assert ('description' in job_slice and 'job_id' in job_slice and 'href'
             in job_slice)
Exemplo n.º 14
0
 def test_run_results(self):
     run_name = 'teuthology-2014-03-27_00:00:00-x-x-x-x-x'
     new_run = Run(run_name)
     stats_in = {'pass': 9, 'fail': 1, 'dead': 6, 'running': 5,
                 'waiting': 1, 'unknown': 1, 'queued': 1}
     statuses = stats_in.keys()
     stats_in['total'] = sum(stats_in.values())
     stats_out = {}
     for i in range(stats_in['total']):
         for status in statuses:
             count = stats_out.get(status, 0)
             count += 1
             if count <= stats_in[status]:
                 break
         Job(dict(job_id=i, status=status), new_run)
         stats_out[status] = count
     assert new_run.get_results() == stats_in
Exemplo n.º 15
0
 def test_allows_waiting_status(self):
     self.app.post_json('/runs/', dict(name="foo"))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=1,
         status="waiting",
     ))
     new_run = Run.get(1)
     assert new_run.status == 'waiting'
Exemplo n.º 16
0
 def test_allows_waiting_status(self):
     self.app.post_json('/runs/', dict(name="foo"))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=1,
         status="waiting",
     ))
     new_run = Run.get(1)
     assert new_run.status == 'waiting'
Exemplo n.º 17
0
 def test_delete_empties_run(self):
     new_run = Run('test_delete_empties_run')
     new_job = Job(dict(job_id='42', status='queued'), new_run)
     models.commit()
     assert new_run.status == 'queued'
     new_job.delete()
     models.commit()
     new_run_copy = Run.query.filter(Run.name == new_run.name).one()
     assert not new_run_copy.status == 'empty'
Exemplo n.º 18
0
 def test_run_suite_gets_corrected(self):
     run_name = 'teuthology-2014-05-01_07:54:18-new-suite-name:new-subsuite:new-subsub-new-branch-testing-basic-plana'  # noqa
     suite_name = 'new-suite-name:new-subsuite:new-subsub'
     branch_name = 'new-branch'
     new_run = Run(run_name)
     Job(dict(job_id='11', suite=suite_name, branch=branch_name), new_run)
     models.commit()
     assert new_run.suite == suite_name
     assert new_run.branch == branch_name
Exemplo n.º 19
0
 def test_job_creates_many_nodes(self):
     run_name = 'test_job_creates_many_nodes'
     node_names = ['node1.name', 'node2.name', 'node3.name']
     targets = {}
     for name in node_names:
         targets['foo@' + name] = ''
     new_run = Run(run_name)
     Job(dict(targets=targets), new_run)
     assert sorted([node.name for node in Node.query.all()]) == node_names
Exemplo n.º 20
0
 def test_success_updates_status(self):
     run_name = 'test_success_updates_status'
     run = Run(run_name)
     job_id = '27'
     job = Job(dict(name=run_name, job_id=job_id, status='running'), run)
     models.commit()
     job.update(dict(success=True))
     models.commit()
     assert job.status == 'pass'
Exemplo n.º 21
0
 def test_run_status_dead_to_running(self):
     run_name = "run_status_dead_to_running"
     new_run = Run(run_name)
     jobs = []
     job_count = 5
     for i in range(job_count):
         jobs.append(Job(dict(job_id=i+1, status='dead'), new_run))
     for job in jobs:
         job.update(dict(status='running'))
     assert new_run.status == 'running'
Exemplo n.º 22
0
 def test_force_updated_time(self):
     run_name = 'test_force_updated_time'
     run = Run(run_name)
     time_stamp = '2014-03-31 21:25:43'
     Job(dict(updated=time_stamp), run)
     models.commit()
     local_dt = datetime.strptime(time_stamp, '%Y-%m-%d %H:%M:%S')
     utc_dt = local_datetime_to_utc(local_dt)
     job = Run.query.filter(Run.name == run.name).one().jobs[0]
     assert str(job.updated) == str(utc_dt)
Exemplo n.º 23
0
 def test_job_adds_node(self):
     run_name = 'test_job_adds_node'
     node_name = 'added_node'
     assert Node.query.filter(Node.name == node_name).all() == []
     node = Node(name=node_name)
     targets = {'foo@' + node_name: ''}
     new_run = Run(run_name)
     job = Job(dict(targets=targets), new_run)
     assert Node.query.filter(Node.name == node_name).one()
     assert Job.query.filter(Job.target_nodes.contains(node)).one() == job
Exemplo n.º 24
0
 def test_status_dead_ignored_when_success_true(self):
     run_name = 'test_status_dead_ignored_when_success_set'
     run = Run(run_name)
     job_id = '27'
     job = Job(dict(name=run_name, job_id=job_id, status='running'), run)
     models.commit()
     job.update(dict(success=True))
     models.commit()
     job.update(dict(status='dead'))
     models.commit()
     assert job.status == 'pass'
Exemplo n.º 25
0
 def test_running_status_with_waiting_and_running_jobs(self):
     self.app.post_json('/runs/', dict(name="foo"))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=1,
         status="running",
     ))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=2,
         status="waiting",
     ))
     new_run = Run.get(1)
     assert new_run.status == 'running'
Exemplo n.º 26
0
 def test_running_status_with_waiting_and_running_jobs(self):
     self.app.post_json('/runs/', dict(name="foo"))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=1,
         status="running",
     ))
     self.app.post_json('/runs/foo/jobs/', dict(
         job_id=2,
         status="waiting",
     ))
     new_run = Run.get(1)
     assert new_run.status == 'running'
Exemplo n.º 27
0
 def index_post(self):
     # save to DB here
     try:
         name = request.json.get('name')
     except ValueError:
         rollback()
         error('/errors/invalid/', 'could not decode JSON body')
     if not name:
         error('/errors/invalid/', "could not find required key: 'name'")
     if not Run.query.filter_by(name=name).first():
         log.info("Creating run: %s", name)
         Run(name)
         return dict()
     else:
         error('/errors/invalid/', "run with name %s already exists" % name)
Exemplo n.º 28
0
 def test_statsd_update(self, m_get_client):
     m_client = Mock()
     m_counter = Mock()
     m_client.get_counter.return_value = m_counter
     m_get_client.return_value = m_client
     run_name = 'test_statsd_update'
     run = Run(run_name)
     job_id = '27'
     job = Job(dict(name=run_name, job_id=job_id, status='running'), run)
     models.commit()
     job.update({'status': 'pass'})
     models.commit()
     assert job.status == 'pass'
     assert m_get_client.called_once_with()
     assert m_client.get_counter.called_once_with('jobs.status')
     assert m_counter.increment.called_once_with('pass')
Exemplo n.º 29
0
 def test_run_suite_weird(self):
     run_name = 'teuthology-2013-10-23_00:30:38-rgw-next---basic-saya'
     new_run = Run(run_name)
     assert new_run.suite == 'rgw'
Exemplo n.º 30
0
 def test_run_suite_hyphenated(self):
     run_name = \
         'teuthology-2013-10-22_03:00:02-ceph-deploy-next-testing-basic-plana'  # noqa
     new_run = Run(run_name)
     assert new_run.suite == 'ceph-deploy'
Exemplo n.º 31
0
 def test_run_suite_typical(self):
     run_name = \
         'teuthology-2013-10-22_03:00:02-big-next-testing-basic-plana'
     new_run = Run(run_name)
     assert new_run.suite == 'big'
Exemplo n.º 32
0
 def test_run_slice_invalid(self):
     run_name = 'test_run_slice_invalid'
     new_run = Run(run_name)
     with pytest.raises(AttributeError):
         new_run.slice('bullcrap')
Exemplo n.º 33
0
 def test_run_slice_valid_many(self):
     run_name = 'test_run_slice_valid_many'
     new_run = Run(run_name)
     run_slice = new_run.slice('posted,name,status')
     assert ('posted' in run_slice and 'name' in run_slice and 'status'
             in run_slice)
Exemplo n.º 34
0
 def test_run_slice_valid(self):
     run_name = 'test_run_slice_valid'
     new_run = Run(run_name)
     assert 'posted' in new_run.slice('posted')
Exemplo n.º 35
0
 def test_create_new_run(self):
     self.app.post_json('/runs/', dict(name="foo"))
     new_run = Run.get(1)
     assert new_run.name == 'foo'