Esempio n. 1
0
 def test_recipe_running_then_cancelled(self):
     """ This tests the case where the recipe is running, has a valid
     reservation request, but is cancelled before it's completed.
     """
     with session.begin():
         recipe = data_setup.create_recipe(
             task_list=[Task.by_name(u'/distribution/install')] * 2,
             reservesys=True)
         job = data_setup.create_job_for_recipes([recipe])
         job_id = job.id
         data_setup.mark_recipe_running(recipe)
         data_setup.mark_recipe_installation_finished(recipe)
         # we want at least one task to be Completed here
         # https://bugzilla.redhat.com/show_bug.cgi?id=1195558
         job.recipesets[0].recipes[0].tasks[0].stop()
         job.recipesets[0].recipes[0].tasks[1].start()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.running)
         job.recipesets[0].cancel()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.cancelled)
Esempio n. 2
0
 def test_recipe_running_then_cancelled(self):
     """ This tests the case where the recipe is running, has a valid
     reservation request, but is cancelled before it's completed.
     """
     with session.begin():
         recipe = data_setup.create_recipe(
             task_list=[Task.by_name(u'/distribution/install')] * 2,
             reservesys=True)
         job = data_setup.create_job_for_recipes([recipe])
         job_id = job.id
         data_setup.mark_recipe_running(recipe)
         data_setup.mark_recipe_installation_finished(recipe)
         # we want at least one task to be Completed here
         # https://bugzilla.redhat.com/show_bug.cgi?id=1195558
         job.recipesets[0].recipes[0].tasks[0].stop()
         job.recipesets[0].recipes[0].tasks[1].start()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.running)
         job.recipesets[0].cancel()
     beakerd.update_dirty_jobs()
     with session.begin():
         job = Job.by_id(job_id)
         self.assertEqual(job.recipesets[0].recipes[0].status,
                          TaskStatus.cancelled)
Esempio n. 3
0
    def test_reserved_openstack_instance(self):
        with session.begin():
            owner = data_setup.create_user(
                email_address=u'*****@*****.**')
            distro_tree = data_setup.create_distro_tree(
                distro_name=u'MicrowaveOS',
                variant=u'ThreeHeats',
                arch=u'x86_64')
            job = data_setup.create_running_job(
                owner=owner,
                virt=True,
                instance_id=uuid.UUID('00000000-1111-2222-3333-444444444444'),
                distro_tree=distro_tree,
                whiteboard=u'Operation Righteous Cowboy Lightning',
                recipe_whiteboard=u'Everything Sunny All the Time Always')
            recipe = job.recipesets[0].recipes[0]
            data_setup.mark_recipe_installation_finished(
                recipe, fqdn=u'bitenuker.ge.invalid')

        with session.begin():
            bkr.server.mail.reservesys_notify(recipe)
        self.assertEqual(len(self.mail_capture.captured_mails), 1)
        sender, rcpts, raw_msg = self.mail_capture.captured_mails[0]
        self.assertEqual(rcpts, [owner.email_address])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], owner.email_address)
        self.assertEqual(msg['Subject'],
                         '[Beaker System Reserved] bitenuker.ge.invalid')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-reservation')

        expected_mail_body = u"""\
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **
                 This System is reserved by [email protected]

 To return this system early, you can click on 'Release System' against this recipe
 from the Web UI. Ensure you have your logs off the system before returning to
 Beaker.
  %(base)srecipes/%(recipeid)s

 For system details, see:
  http://openstack.example.invalid/dashboard/project/instances/00000000-1111-2222-3333-444444444444/

 For the default root password, see:
  %(base)sprefs

      Beaker Test information:
                         HOSTNAME=bitenuker.ge.invalid
                            JOBID=%(jobid)s
                         RECIPEID=%(recipeid)s
                           DISTRO=MicrowaveOS ThreeHeats x86_64
                     ARCHITECTURE=x86_64

      Job Whiteboard: Operation Righteous Cowboy Lightning

      Recipe Whiteboard: Everything Sunny All the Time Always
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **""" \
            % dict(base=get_server_base(), recipeid=recipe.id, jobid=job.id)
        actual_mail_body = msg.get_payload(decode=True)
        self.assertMultiLineEqual(actual_mail_body, expected_mail_body)
Esempio n. 4
0
    def test_reserved_openstack_instance(self):
        with session.begin():
            owner = data_setup.create_user(
                    email_address=u'*****@*****.**')
            distro_tree = data_setup.create_distro_tree(distro_name=u'MicrowaveOS',
                    variant=u'ThreeHeats', arch=u'x86_64')
            job = data_setup.create_running_job(owner=owner,
                    virt=True, instance_id=uuid.UUID('00000000-1111-2222-3333-444444444444'),
                    distro_tree=distro_tree,
                    whiteboard=u'Operation Righteous Cowboy Lightning',
                    recipe_whiteboard=u'Everything Sunny All the Time Always')
            recipe = job.recipesets[0].recipes[0]
            data_setup.mark_recipe_installation_finished(recipe,
                    fqdn=u'bitenuker.ge.invalid')

        with session.begin():
            bkr.server.mail.reservesys_notify(recipe)
        self.assertEqual(len(self.mail_capture.captured_mails), 1)
        sender, rcpts, raw_msg = self.mail_capture.captured_mails[0]
        self.assertEqual(rcpts, [owner.email_address])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], owner.email_address)
        self.assertEqual(msg['Subject'],
                '[Beaker System Reserved] bitenuker.ge.invalid')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-reservation')

        expected_mail_body = u"""\
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **
                 This System is reserved by [email protected]

 To return this system early, you can click on 'Release System' against this recipe
 from the Web UI. Ensure you have your logs off the system before returning to
 Beaker.
  %(base)srecipes/%(recipeid)s

 For system details, see:
  http://openstack.example.invalid/dashboard/project/instances/00000000-1111-2222-3333-444444444444/

 For the default root password, see:
  %(base)sprefs

      Beaker Test information:
                         HOSTNAME=bitenuker.ge.invalid
                            JOBID=%(jobid)s
                         RECIPEID=%(recipeid)s
                           DISTRO=MicrowaveOS ThreeHeats x86_64
                     ARCHITECTURE=x86_64

      Job Whiteboard: Operation Righteous Cowboy Lightning

      Recipe Whiteboard: Everything Sunny All the Time Always
**  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **  **""" \
            % dict(base=get_server_base(), recipeid=recipe.id, jobid=job.id)
        actual_mail_body = msg.get_payload(decode=True)
        self.assertMultiLineEqual(actual_mail_body, expected_mail_body)
Esempio n. 5
0
 def test_status_is_Waiting_when_installation_is_finished_but_tasks_have_not_started(self):
     # Beah <= 0.7.9 will consider 'Installing' to mean that the recipe is 
     # finished, so we want the status to go back to 'Waiting' once the 
     # installation is finished.
     job = data_setup.create_job()
     recipe = job.recipesets[0].recipes[0]
     data_setup.mark_recipe_installing(recipe)
     data_setup.mark_recipe_installation_finished(recipe)
     self.assertEqual(recipe.tasks[0].status, TaskStatus.waiting)
     self.assertIsNone(recipe.tasks[0].start_time)
     self.assertEqual(recipe.status, TaskStatus.waiting)
Esempio n. 6
0
 def test_install_failure_is_not_reported_after_installation_is_finished(self):
     anaconda_success = 'blah blah installing... done\n'
     open(self.console_log, 'w').write(anaconda_success)
     wait_for_condition(self.check_console_log_registered)
     wait_for_condition(lambda: self.check_cached_log_contents(anaconda_success))
     with session.begin():
         data_setup.mark_recipe_installation_finished(self.recipe)
     anaconda_failure = "Press 'OK' to reboot your system.\n"
     open(self.console_log, 'a').write(anaconda_failure)
     wait_for_condition(lambda: self.check_cached_log_contents(
             anaconda_success + anaconda_failure))
     with session.begin():
         task = self.recipe.tasks[0]
         session.refresh(task)
         self.assertEquals(task.status, TaskStatus.running)
Esempio n. 7
0
 def test_install_failure_is_not_reported_after_installation_is_finished(self):
     anaconda_success = 'blah blah installing... done\n'
     open(self.console_log, 'w').write(anaconda_success)
     wait_for_condition(self.check_console_log_registered)
     wait_for_condition(lambda: self.check_cached_log_contents(anaconda_success))
     with session.begin():
         data_setup.mark_recipe_installation_finished(self.recipe)
         data_setup.mark_recipe_running(self.recipe, only=True)
     anaconda_failure = "Press 'OK' to reboot your system.\n"
     open(self.console_log, 'a').write(anaconda_failure)
     wait_for_condition(lambda: self.check_cached_log_contents(
             anaconda_success + anaconda_failure))
     with session.begin():
         task = self.recipe.tasks[0]
         session.refresh(task)
         self.assertEquals(task.status, TaskStatus.running)