Пример #1
0
 def test_open_in_demand_systems(self):
     with session.begin():
         # system with waiting recipes
         system_with_waiting_recipes = data_setup.create_system()
         data_setup.create_manual_reservation(system_with_waiting_recipes,
                                              start=datetime.utcnow() - timedelta(days=self.reservation_length),
                                              user=self.user)
         recipe = data_setup.create_recipe()
         recipe.systems[:] = [system_with_waiting_recipes]
         job = data_setup.create_job_for_recipes([recipe])
         data_setup.mark_job_queued(job)
         job.recipesets[0].queue_time = datetime.utcnow() - timedelta(hours=self.waiting_recipe_age)
         # Create another system with waiting recipes and delete the job
         recipe_in_deleted_job = data_setup.create_recipe()
         recipe_in_deleted_job.systems[:] = [system_with_waiting_recipes]
         deleted_job = data_setup.create_job_for_recipes([recipe_in_deleted_job])
         data_setup.mark_job_queued(deleted_job)
         deleted_job.recipesets[0].queue_time = datetime.utcnow() - timedelta(hours=self.waiting_recipe_age)
         deleted_job.delete()
         # system with no waiting recipes
         system_without_waiting_recipes = data_setup.create_system()
         data_setup.create_manual_reservation(system_without_waiting_recipes,
                                              start=datetime.utcnow() - timedelta(days=self.reservation_length),
                                              user=self.user)
     beaker_usage = BeakerUsage(self.user, self.reservation_expiry, self.reservation_length,
                            self.waiting_recipe_age, self.delayed_job_age)
     open_in_demand_systems = beaker_usage.open_in_demand_systems()
     self.assertEqual(len(open_in_demand_systems), 1)
     self.assertEqual(open_in_demand_systems[0][1], 1)
     self.assertEqual(open_in_demand_systems[0][2], system_with_waiting_recipes.fqdn)
 def test_machine_hours(self):
     user = data_setup.create_user()
     # recipes/reservations straddle the boundary of the reporting period
     # to test we clamp them properly
     data_setup.create_completed_job(owner=user,
             distro_tree=data_setup.create_distro_tree(arch=u'ia64'),
             start_time=datetime.datetime(2012, 9, 30, 23, 0, 0),
             finish_time=datetime.datetime(2012, 10, 1, 1, 0, 0))
     data_setup.create_manual_reservation(user=user,
             system=data_setup.create_system(arch=u'ia64'),
             start=datetime.datetime(2012, 10, 31, 22, 30, 0),
             finish=datetime.datetime(2012, 11, 1, 1, 0, 0))
     data_setup.create_completed_job(owner=user,
             distro_tree=data_setup.create_distro_tree(arch=u'ppc64'),
             start_time=datetime.datetime(2012, 9, 30, 20, 0, 0),
             finish_time=datetime.datetime(2012, 10, 1, 2, 0, 0))
     data_setup.create_manual_reservation(user=user,
             system=data_setup.create_system(arch=u'ppc64'),
             start=datetime.datetime(2012, 10, 31, 23, 0, 0),
             finish=datetime.datetime(2012, 11, 1, 10, 0, 0))
     session.flush()
     rows = self.execute_reporting_query('machine-hours-by-user-arch')
     user_rows = [row for row in rows if row.username == user.user_name]
     self.assertEquals(len(user_rows), 2, user_rows)
     self.assertEquals(user_rows[0].arch, 'ia64')
     self.assertEquals(user_rows[0].machine_hours, Decimal('2.5'))
     self.assertEquals(user_rows[1].arch, 'ppc64')
     self.assertEquals(user_rows[1].machine_hours, Decimal('3.0'))
 def test_machine_hours(self):
     user = data_setup.create_user()
     # recipes/reservations straddle the boundary of the reporting period
     # to test we clamp them properly
     data_setup.create_completed_job(
         owner=user,
         distro_tree=data_setup.create_distro_tree(arch=u'ia64'),
         start_time=datetime.datetime(2012, 9, 30, 23, 0, 0),
         finish_time=datetime.datetime(2012, 10, 1, 1, 0, 0))
     data_setup.create_manual_reservation(
         user=user,
         system=data_setup.create_system(arch=u'ia64'),
         start=datetime.datetime(2012, 10, 31, 22, 30, 0),
         finish=datetime.datetime(2012, 11, 1, 1, 0, 0))
     data_setup.create_completed_job(
         owner=user,
         distro_tree=data_setup.create_distro_tree(arch=u'ppc64'),
         start_time=datetime.datetime(2012, 9, 30, 20, 0, 0),
         finish_time=datetime.datetime(2012, 10, 1, 2, 0, 0))
     data_setup.create_manual_reservation(
         user=user,
         system=data_setup.create_system(arch=u'ppc64'),
         start=datetime.datetime(2012, 10, 31, 23, 0, 0),
         finish=datetime.datetime(2012, 11, 1, 10, 0, 0))
     session.flush()
     rows = self.execute_reporting_query('machine-hours-by-user-arch')
     user_rows = [row for row in rows if row.username == user.user_name]
     self.assertEquals(len(user_rows), 2, user_rows)
     self.assertEquals(user_rows[0].arch, 'ia64')
     self.assertEquals(user_rows[0].machine_hours, Decimal('2.5'))
     self.assertEquals(user_rows[1].arch, 'ppc64')
     self.assertEquals(user_rows[1].machine_hours, Decimal('3.0'))
Пример #4
0
    def test_counts(self):
        lc = data_setup.create_labcontroller()
        manual_system = data_setup.create_system(lab_controller=lc)
        data_setup.create_manual_reservation(manual_system,
                start=datetime.datetime(2012, 1, 1, 0, 0, 0))
        recipe_system = data_setup.create_system(lab_controller=lc)
        data_setup.mark_recipe_running(
                data_setup.create_job().recipesets[0].recipes[0],
                system=recipe_system)
        idle_manual_system = data_setup.create_system(lab_controller=lc,
                status=SystemStatus.manual)
        idle_automated_system = data_setup.create_system(lab_controller=lc,
                status=SystemStatus.automated)
        idle_broken_system = data_setup.create_system(lab_controller=lc,
                status=SystemStatus.broken)
        idle_removed_system = data_setup.create_system(lab_controller=lc,
                status=SystemStatus.removed)
        session.flush()

        counts = system_utilisation_counts(System.query.filter(
                System.lab_controller == lc))
        self.assertEqual(counts['recipe'], 1)
        self.assertEqual(counts['manual'], 1)
        self.assertEqual(counts['idle_manual'], 1)
        self.assertEqual(counts['idle_automated'], 1)
        self.assertEqual(counts['idle_broken'], 1)
        self.assertEqual(counts['idle_removed'], 1)
Пример #5
0
 def setUp(self):
     with session.begin():
         user = data_setup.create_user()
         system = data_setup.create_system()
         system.user = user
         data_setup.create_manual_reservation(system,
                                              datetime.datetime(2012, 10, 31, 23, 0, 0),
                                              user=user)
     self.browser = self.get_browser()
     self.browser.get(get_server_base() + '/reports')
Пример #6
0
 def setUp(self):
     with session.begin():
         user = data_setup.create_user()
         system = data_setup.create_system()
         system.user = user
         data_setup.create_manual_reservation(system,
                                              datetime.datetime(
                                                  2012, 10, 31, 23, 0, 0),
                                              user=user)
     self.browser = self.get_browser()
     self.browser.get(get_server_base() + '/reports')
Пример #7
0
 def test_search_works_on_reserve_report(self):
     # Reserve Report is a specialisation of the regular systems grid, so we 
     # aren't testing it exhaustively, we just want to make sure that the 
     # search is wired up properly.
     with session.begin():
         included = data_setup.create_system()
         data_setup.create_manual_reservation(included)
         excluded = data_setup.create_system(fqdn=data_setup.unique_name(u'aardvark%s'))
         data_setup.create_manual_reservation(excluded)
     b = self.browser
     perform_search(b, [('System/Name', 'is', included.fqdn)],
             search_url='reports/')
     check_system_search_results(b, present=[included], absent=[excluded])
Пример #8
0
    def test_grouped_counts(self):
        lc = data_setup.create_labcontroller()
        manual_ia64_system = data_setup.create_system(lab_controller=lc, arch="ia64")
        data_setup.create_manual_reservation(manual_ia64_system, start=datetime.datetime(2012, 1, 1, 0, 0, 0))
        manual_ppc_system = data_setup.create_system(lab_controller=lc, arch="ppc")
        data_setup.create_manual_reservation(manual_ppc_system, start=datetime.datetime(2012, 1, 1, 0, 0, 0))
        recipe_ia64_system = data_setup.create_system(lab_controller=lc, arch="ia64")
        data_setup.mark_recipe_running(data_setup.create_job().recipesets[0].recipes[0], system=recipe_ia64_system)
        session.flush()

        counts = system_utilisation_counts_by_group(
            Arch.arch, System.query.join(System.arch).filter(System.lab_controller == lc)
        )
        print counts
        self.assertEqual(counts["ia64"]["recipe"], 1)
        self.assertEqual(counts["ia64"]["manual"], 1)
        self.assertEqual(counts["ppc"]["manual"], 1)
Пример #9
0
    def test_by_reserved_since(self):
        with session.begin():
            s1 = data_setup.create_system()
            data_setup.create_manual_reservation(s1, start=datetime.datetime(2003, 1, 21, 11, 30, 0))
            s2 = data_setup.create_system(fqdn='aaadvark.testdata')
            data_setup.create_manual_reservation(s2, start=datetime.datetime(2005, 1, 21, 11, 30, 0))
        b = self.browser

        perform_search(b, [('System/Reserved', 'is', '2003-01-21')])
        check_system_search_results(b, present=[s1], absent=[s2])

        perform_search(b, [('System/Reserved', 'before', '2005-1-21')])
        check_system_search_results(b, present=[s1], absent=[s2])

        perform_search(b, [('System/Reserved', 'after', '2005-1-21')])
        check_system_search_results(b, absent=[s1, s2])

        perform_search(b, [('System/Reserved', 'after', '2005-1-1')])
        check_system_search_results(b, present=[s2], absent=[s1])
Пример #10
0
 def setUpClass(cls):
     with session.begin():
         # ensure we have lots of systems
         for cores in [1, 2, 3]:
             for vendor, model, status, type, reserved_since, user in zip(
                 [u"Acer", u"Dell", u"HP"],
                 [u"slow model", u"fast model", u"big model"],
                 [u"Automated", u"Manual", u"Removed"],
                 [u"Machine", u"Prototype"],
                 [
                     datetime.datetime(2012, 10, 31, 23, 0, 0),
                     datetime.datetime(2015, 1, 1, 6, 0, 0),
                     datetime.datetime(2020, 1, 6, 10, 0, 0),
                 ],
                 [data_setup.create_user() for _ in range(3)],
             ):
                 system = data_setup.create_system(vendor=vendor, model=model, status=status, type=type)
                 system.cpu = Cpu(cores=cores)
                 system.user = user
                 system.lab_controller = data_setup.create_labcontroller()
                 data_setup.create_manual_reservation(system, reserved_since, user=user)
Пример #11
0
 def test_machine_utilization(self):
     #
     # Note: If test relies on an SQL script with hard coded time stamps in
     # 2002 or no finish reservation times.
     #
     system1 = data_setup.create_system()
     system2 = data_setup.create_system()
     system3 = data_setup.create_system()
     data_setup.create_manual_reservation(
         system=system1,
         start=datetime.datetime(2002, 6, 2, 22, 30, 0),
         finish=datetime.datetime(2002, 6, 3, 22, 30, 0))
     data_setup.create_manual_reservation(system=system2,
                                          start=datetime.datetime(
                                              2002, 5, 2, 22, 30, 0))
     data_setup.create_manual_reservation(
         system=system3,
         start=datetime.datetime(2002, 5, 2, 22, 30, 0),
         finish=datetime.datetime(2002, 5, 3, 22, 30, 0))
     session.flush()
     rows = [
         row for row in self.execute_reporting_query('machine-utilization')
     ]
     self.assertEquals(len(rows), 2, rows)
     self.assertIn((system1.fqdn, Decimal('0.0333')), rows)
     self.assertIn((system2.fqdn, Decimal('1.0000')), rows)
     # system3 should not appear
     self.assertNotIn(system3.fqdn, [row[0] for row in rows])
Пример #12
0
 def test_open_in_demand_systems(self):
     with session.begin():
         # system with waiting recipes
         system_with_waiting_recipes = data_setup.create_system()
         data_setup.create_manual_reservation(
             system_with_waiting_recipes,
             start=datetime.utcnow() -
             timedelta(days=self.reservation_length),
             user=self.user)
         recipe = data_setup.create_recipe()
         recipe.systems[:] = [system_with_waiting_recipes]
         job = data_setup.create_job_for_recipes([recipe])
         data_setup.mark_job_queued(job)
         job.recipesets[0].queue_time = datetime.utcnow() - timedelta(
             hours=self.waiting_recipe_age)
         # Create another system with waiting recipes and delete the job
         recipe_in_deleted_job = data_setup.create_recipe()
         recipe_in_deleted_job.systems[:] = [system_with_waiting_recipes]
         deleted_job = data_setup.create_job_for_recipes(
             [recipe_in_deleted_job])
         data_setup.mark_job_queued(deleted_job)
         deleted_job.recipesets[0].queue_time = datetime.utcnow(
         ) - timedelta(hours=self.waiting_recipe_age)
         deleted_job.delete()
         # system with no waiting recipes
         system_without_waiting_recipes = data_setup.create_system()
         data_setup.create_manual_reservation(
             system_without_waiting_recipes,
             start=datetime.utcnow() -
             timedelta(days=self.reservation_length),
             user=self.user)
     beaker_usage = BeakerUsage(self.user, self.reservation_expiry,
                                self.reservation_length,
                                self.waiting_recipe_age,
                                self.delayed_job_age)
     open_in_demand_systems = beaker_usage.open_in_demand_systems()
     self.assertEqual(len(open_in_demand_systems), 1)
     self.assertEqual(open_in_demand_systems[0][1], 1)
     self.assertEqual(open_in_demand_systems[0][2],
                      system_with_waiting_recipes.fqdn)
Пример #13
0
    def test_durations(self):
        system = data_setup.create_system(lab_controller=data_setup.create_labcontroller())

        # Set up the following fake history for the system:
        #   2009-12-31 00:00:00 marked broken
        #   2010-01-02 00:00:00 repaired
        #   2010-01-03 00:00:00 to 12:00:00 manually reserved
        #   2010-01-04 12:00:00 to 00:00:00 running a recipe
        system.date_added = datetime.datetime(2009, 1, 1, 0, 0, 0)
        system.status_durations.append(
            SystemStatusDuration(
                status=SystemStatus.broken,
                start_time=datetime.datetime(2009, 12, 31, 0, 0, 0),
                finish_time=datetime.datetime(2010, 1, 2, 0, 0, 0),
            )
        )
        system.status_durations.append(
            SystemStatusDuration(status=SystemStatus.automated, start_time=datetime.datetime(2010, 1, 2, 0, 0, 0))
        )
        data_setup.create_manual_reservation(
            system, start=datetime.datetime(2010, 1, 3, 0, 0, 0), finish=datetime.datetime(2010, 1, 3, 12, 0, 0)
        )
        data_setup.create_completed_job(
            system=system,
            start_time=datetime.datetime(2010, 1, 4, 12, 0, 0),
            finish_time=datetime.datetime(2010, 1, 5, 0, 0, 0),
        )
        session.flush()

        # If we report from 2010-01-01 to 2010-01-04, that should give us the
        # following durations:
        u = system_utilisation(system, datetime.datetime(2010, 1, 1, 0, 0, 0), datetime.datetime(2010, 1, 5, 0, 0, 0))
        self.assertEqual(u["recipe"], datetime.timedelta(seconds=43200))
        self.assertEqual(u["manual"], datetime.timedelta(seconds=43200))
        self.assertEqual(u["idle_manual"], datetime.timedelta(0))
        self.assertEqual(u["idle_automated"], datetime.timedelta(days=2))
        self.assertEqual(u["idle_broken"], datetime.timedelta(days=1))
        self.assertEqual(u["idle_removed"], datetime.timedelta(0))
        self.assertEqual(sum((v for k, v in u.iteritems()), datetime.timedelta(0)), datetime.timedelta(days=4))
Пример #14
0
 def setUpClass(cls):
     with session.begin():
         # ensure we have lots of systems
         for cores in [1, 2, 3]:
             for vendor, model, status, type, reserved_since, user in zip(
                 [u'Acer', u'Dell', u'HP'],
                 [u'slow model', u'fast model', u'big model'],
                 [u'Automated', u'Manual', u'Removed'],
                 [u'Machine', u'Prototype'], [
                     datetime.datetime(2012, 10, 31, 23, 0, 0),
                     datetime.datetime(2015, 1, 1, 6, 0, 0),
                     datetime.datetime(2020, 1, 6, 10, 0, 0),
                 ], [data_setup.create_user() for _ in range(3)]):
                 system = data_setup.create_system(vendor=vendor,
                                                   model=model,
                                                   status=status,
                                                   type=type)
                 system.cpu = Cpu(cores=cores)
                 system.user = user
                 system.lab_controller = data_setup.create_labcontroller()
                 data_setup.create_manual_reservation(system,
                                                      reserved_since,
                                                      user=user)
Пример #15
0
    def _create_open_reservation(self):
        system = data_setup.create_system()
        data_setup.create_manual_reservation(system,
                                             start=datetime.utcnow() - timedelta(days=self.reservation_length),
                                             user=self.user)
        recipe = data_setup.create_recipe()
        recipe.systems[:] = [system]
        job = data_setup.create_job_for_recipes([recipe])
        data_setup.mark_job_queued(job)
        job.recipesets[0].queue_time = datetime.utcnow() - timedelta(hours=self.waiting_recipe_age)
        email_content = u"""
The following systems have been allocated to you in %s for more than %s days and have other
recipes queued for longer than %s hours. Please return them if you are no longer using them.

Duration                 Waiting                  FQDN
%s                   %s                 %s
"""    % (absolute_url('/'),
          self.reservation_length,
          self.waiting_recipe_age,
          "%s days" % (datetime.utcnow() - system.reservations[0].start_time).days,
          "1 recipe",
          system.fqdn)
        return email_content
Пример #16
0
    def _create_open_reservation(self):
        system = data_setup.create_system()
        data_setup.create_manual_reservation(system,
                                             start=datetime.utcnow() - timedelta(days=self.reservation_length),
                                             user=self.user)
        recipe = data_setup.create_recipe()
        recipe.systems[:] = [system]
        job = data_setup.create_job_for_recipes([recipe])
        data_setup.mark_job_queued(job)
        job.recipesets[0].queue_time = datetime.utcnow() - timedelta(hours=self.waiting_recipe_age)
        email_content = u"""
The following systems have been allocated to you in %s for more than %s days and have other
recipes queued for longer than %s hours. Please return them if you are no longer using them.

Duration                 Waiting                  FQDN
%s                   %s                 %s
"""    % (absolute_url('/'),
          self.reservation_length,
          self.waiting_recipe_age,
          "%s days" % (datetime.utcnow() - system.reservations[0].start_time).days,
          "1 recipe",
          system.fqdn)
        return email_content
Пример #17
0
 def test_machine_utilization(self):
     system1 = data_setup.create_system()
     system2 = data_setup.create_system()
     system3 = data_setup.create_system()
     data_setup.create_manual_reservation(system=system1,
                                          start=datetime.datetime(2002, 6, 2, 22, 30, 0),
                                          finish=datetime.datetime(2002, 6, 3, 22, 30, 0))
     data_setup.create_manual_reservation(system=system2,
                                          start=datetime.datetime(2002, 5, 2, 22, 30, 0))
     data_setup.create_manual_reservation(system=system3,
                                          start=datetime.datetime(2002, 5, 2, 22, 30, 0),
                                          finish=datetime.datetime(2002, 5, 3, 22, 30, 0))
     session.flush()
     rows = [row for row in self.execute_reporting_query('machine-utilization')]
     self.assertEquals(len(rows), 2, rows)
     self.assertIn((system1.fqdn, Decimal('0.0333')), rows)
     self.assertIn((system2.fqdn, Decimal('1.0000')), rows)
     # system3 should not appear
     self.assertNotIn(system3.fqdn, [row[0] for row in rows])
Пример #18
0
    def test_cee_ops_provided_queries(self):
        # CEE Ops is a team within Red Hat who relies heavily on Beaker. These
        # queries are used by their tooling to integrate with Beaker's
        # inventory. The queries are covered here in our test suite so that
        # they will know if any Beaker schema changes will affect these
        # queries.

        cee_users = data_setup.create_group(group_name=u'cee-users')
        cee_user = data_setup.create_user(user_name=u'billybob')
        cee_users.add_member(cee_user)
        # Create a system which has been manually reserved
        reserved_system = data_setup.create_system(fqdn=u'gsslab.reserved',
                                                   status='Manual')
        data_setup.create_manual_reservation(reserved_system,
                                             user=cee_user,
                                             start=datetime.datetime(
                                                 2016, 1, 1, 0, 0))
        # Create a system which is loaned out
        loaned_system = data_setup.create_system(fqdn=u'gsslab.loaned',
                                                 status='Manual')
        data_setup.create_system_loan(loaned_system,
                                      user=cee_user,
                                      start=datetime.datetime(
                                          2016, 1, 2, 0, 0))
        # Create a system which has been provisioned with RHEL7.1
        provisioned_system = data_setup.create_system(
            fqdn=u'gsslab.provisioned',
            status='Automated',
            lab_controller=data_setup.create_labcontroller())
        recipe = data_setup.create_recipe(distro_name=u'RHEL-7.1',
                                          variant=u'Server')
        data_setup.create_job_for_recipes([recipe], owner=cee_user)
        data_setup.mark_recipe_complete(recipe, system=provisioned_system)
        # Create a non-CEE system which has been provisioned 20 times
        noncee_provisioned_system = data_setup.create_system(
            fqdn=u'noncee.provisioned',
            status='Automated',
            lab_controller=data_setup.create_labcontroller())
        for _ in range(20):
            recipe = data_setup.create_recipe()
            data_setup.create_job_for_recipes([recipe], owner=cee_user)
            data_setup.mark_recipe_complete(recipe,
                                            system=noncee_provisioned_system)
        session.flush()

        rows = self.execute_reporting_query('cee/all-systems').fetchall()
        self.assertEqual(len(rows), 3)

        rows = self.execute_reporting_query('cee/reserved-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[0].start_time,
                         datetime.datetime(2016, 1, 1, 0, 0))

        rows = self.execute_reporting_query('cee/loaned-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')

        rows = self.execute_reporting_query(
            'cee/loaned-systems-by-date').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')
        self.assertEqual(rows[0].loan_date,
                         datetime.datetime(2016, 1, 2, 0, 0))

        rows = self.execute_reporting_query('cee/system-provisions').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query(
            'cee/system-reservations').fetchall()
        self.assertEqual(len(rows), 2)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)
        self.assertEqual(rows[1].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[1].count, 1)

        rows = self.execute_reporting_query(
            'cee/system-distrotrees').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')

        rows = self.execute_reporting_query(
            'cee/provisions-by-distrotree').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query(
            'cee/provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].user_name, u'billybob')
        self.assertEqual(rows[0].count, 21)

        rows = self.execute_reporting_query(
            'cee/non-cee-provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'noncee.provisioned')
        self.assertEqual(rows[0].count, 20)
    def test_cee_ops_provided_queries(self):
        # CEE Ops is a team within Red Hat who relies heavily on Beaker. These 
        # queries are used by their tooling to integrate with Beaker's 
        # inventory. The queries are covered here in our test suite so that 
        # they will know if any Beaker schema changes will affect these 
        # queries.

        cee_users = data_setup.create_group(group_name=u'cee-users')
        cee_user = data_setup.create_user(user_name=u'billybob')
        cee_users.add_member(cee_user)
        # Create a system which has been manually reserved
        reserved_system = data_setup.create_system(fqdn=u'gsslab.reserved', status='Manual')
        data_setup.create_manual_reservation(reserved_system, user=cee_user,
                start=datetime.datetime(2016, 1, 1, 0, 0))
        # Create a system which is loaned out
        loaned_system = data_setup.create_system(fqdn=u'gsslab.loaned', status='Manual')
        data_setup.create_system_loan(loaned_system, user=cee_user,
                start=datetime.datetime(2016, 1, 2, 0, 0))
        # Create a system which has been provisioned with RHEL7.1
        provisioned_system = data_setup.create_system(fqdn=u'gsslab.provisioned',
                status='Automated', lab_controller=data_setup.create_labcontroller())
        recipe = data_setup.create_recipe(distro_name=u'RHEL-7.1', variant=u'Server')
        data_setup.create_job_for_recipes([recipe], owner=cee_user)
        data_setup.mark_recipe_complete(recipe, system=provisioned_system)
        # Create a non-CEE system which has been provisioned 20 times
        noncee_provisioned_system = data_setup.create_system(fqdn=u'noncee.provisioned',
                status='Automated', lab_controller=data_setup.create_labcontroller())
        for _ in range(20):
            recipe = data_setup.create_recipe()
            data_setup.create_job_for_recipes([recipe], owner=cee_user)
            data_setup.mark_recipe_complete(recipe, system=noncee_provisioned_system)
        session.flush()

        rows = self.execute_reporting_query('cee/all-systems').fetchall()
        self.assertEqual(len(rows), 3)

        rows = self.execute_reporting_query('cee/reserved-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[0].start_time, datetime.datetime(2016, 1, 1, 0, 0))

        rows = self.execute_reporting_query('cee/loaned-systems').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')

        rows = self.execute_reporting_query('cee/loaned-systems-by-date').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.loaned')
        self.assertEqual(rows[0].loan_date, datetime.datetime(2016, 1, 2, 0, 0))

        rows = self.execute_reporting_query('cee/system-provisions').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query('cee/system-reservations').fetchall()
        self.assertEqual(len(rows), 2)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].count, 1)
        self.assertEqual(rows[1].fqdn, u'gsslab.reserved')
        self.assertEqual(rows[1].count, 1)

        rows = self.execute_reporting_query('cee/system-distrotrees').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'gsslab.provisioned')
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')

        rows = self.execute_reporting_query('cee/provisions-by-distrotree').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].operatingsystem, u'RHEL-7.1 Server i386')
        self.assertEqual(rows[0].count, 1)

        rows = self.execute_reporting_query('cee/provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].user_name, u'billybob')
        self.assertEqual(rows[0].count, 21)

        rows = self.execute_reporting_query('cee/non-cee-provisions-by-user').fetchall()
        self.assertEqual(len(rows), 1)
        self.assertEqual(rows[0].fqdn, u'noncee.provisioned')
        self.assertEqual(rows[0].count, 20)