← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1560437] [NEW] Logic of nova-cells test case 'test_cells_scheduler.test_filter_schedule_skipping' is odd

 

Public bug reported:

Logic of nova-cells test case
'nova.tests.unit.cells.test_cells_scheduler.test_filter_schedule_skipping'[1]
is really odd:

def test_filter_schedule_skipping(self):
 # if a filter handles scheduling, short circuit

 def _grab(filter_properties):
  return None

 self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)

 def _test(self, *args):
  raise test.TestingException("shouldn't be called")

 try:
  self.scheduler._schedule_build_to_cells(None, None, None, _test,
            None)
 except test.TestingException:
  self.fail("Scheduling did not properly short circuit")

It uses a try-except block to ensure that '_test()' function will not be
called during case execution, which is odd and poorly readable.

[1]https://github.com/openstack/nova/blob/13.0.0.0rc1/nova/tests/unit/cells/test_cells_scheduler.py#L354-L369

** Affects: nova
     Importance: Undecided
     Assignee: Wenzhi Yu (yuywz)
         Status: New

** Changed in: nova
     Assignee: (unassigned) => Wenzhi Yu (yuywz)

** Description changed:

  Logic of nova-cells test case
  'nova.tests.cells.test_cells_scheduler.test_filter_schedule_skipping' is
  really odd:
  
  def test_filter_schedule_skipping(self):
- 	# if a filter handles scheduling, short circuit
+  # if a filter handles scheduling, short circuit
  
- 	def _grab(filter_properties):
- 		return None
+  def _grab(filter_properties):
+   return None
  
-         self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
+  self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)
  
- 	def _test(self, *args):
- 		raise test.TestingException("shouldn't be called")
+  def _test(self, *args):
+   raise test.TestingException("shouldn't be called")
  
- 	try:
- 		self.scheduler._schedule_build_to_cells(None, None, None, _test,
- 												None)
- 	except test.TestingException:
- 		self.fail("Scheduling did not properly short circuit")
+  try:
+   self.scheduler._schedule_build_to_cells(None, None, None, _test,
+             None)
+  except test.TestingException:
+   self.fail("Scheduling did not properly short circuit")
  
- It uses a try-except block to ensure that '_test()' function will not be called during case execution,
- which is odd and poorly readable.
+ It uses a try-except block to ensure that '_test()' function will not be
+ called during case execution, which is odd and poorly readable.

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1560437

Title:
  Logic of nova-cells test case
  'test_cells_scheduler.test_filter_schedule_skipping' is odd

Status in OpenStack Compute (nova):
  New

Bug description:
  Logic of nova-cells test case
  'nova.tests.unit.cells.test_cells_scheduler.test_filter_schedule_skipping'[1]
  is really odd:

  def test_filter_schedule_skipping(self):
   # if a filter handles scheduling, short circuit

   def _grab(filter_properties):
    return None

   self.stubs.Set(self.scheduler, '_grab_target_cells', _grab)

   def _test(self, *args):
    raise test.TestingException("shouldn't be called")

   try:
    self.scheduler._schedule_build_to_cells(None, None, None, _test,
              None)
   except test.TestingException:
    self.fail("Scheduling did not properly short circuit")

  It uses a try-except block to ensure that '_test()' function will not
  be called during case execution, which is odd and poorly readable.

  [1]https://github.com/openstack/nova/blob/13.0.0.0rc1/nova/tests/unit/cells/test_cells_scheduler.py#L354-L369

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1560437/+subscriptions


Follow ups