From 0edfa2eaab08a0756bf3ec7818cdc9a8a379ba87 Mon Sep 17 00:00:00 2001
From: Tao Bai <baitaosh@cn.ibm.com>
Date: Fri, 20 Jun 2014 02:56:23 -0700
Subject: [PATCH] test_storwize_vdisk_copy_ops fails if green thread context
 switch

There is loopingcall(green thread)will cause _rm_vdisk_copy_op() run
twice.On the second time, the exception KeyError is not caught.

Closes-Bug: #1302670

Change-Id: I788f07c33f76693a13f0d581e687a32c6736a394
---
 cinder/tests/test_storwize_svc.py                  | 9 ---------
 cinder/volume/drivers/ibm/storwize_svc/__init__.py | 2 +-
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/cinder/tests/test_storwize_svc.py b/cinder/tests/test_storwize_svc.py
index 91021242c..bf32c4fbc 100644
--- a/cinder/tests/test_storwize_svc.py
+++ b/cinder/tests/test_storwize_svc.py
@@ -21,7 +21,6 @@ Tests for the IBM Storwize family and SVC volume driver.
 import mock
 import random
 import re
-import testtools
 
 from cinder import context
 from cinder import exception
@@ -1504,15 +1503,8 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         self.driver.db = self.db
         self.driver.do_setup(None)
         self.driver.check_for_setup_error()
-        self.sleeppatch = mock.patch('eventlet.greenthread.sleep')
-        self.sleeppatch.start()
         self.driver._helpers.check_fcmapping_interval = 0
 
-    def tearDown(self):
-        if self.USESIM:
-            self.sleeppatch.stop()
-        super(StorwizeSVCDriverTestCase, self).tearDown()
-
     def _set_flag(self, flag, value):
         group = self.driver.configuration.config_group
         self.driver.configuration.set_override(flag, value, group)
@@ -2371,7 +2363,6 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             self.assertEqual((7, 2, 0, 0), res['code_level'],
                              'Get code level error')
 
-    @testtools.skip("Bug #1302670")
     def test_storwize_vdisk_copy_ops(self):
         ctxt = testutils.get_test_admin_context()
         volume = self._create_volume()
diff --git a/cinder/volume/drivers/ibm/storwize_svc/__init__.py b/cinder/volume/drivers/ibm/storwize_svc/__init__.py
index def370117..810535643 100644
--- a/cinder/volume/drivers/ibm/storwize_svc/__init__.py
+++ b/cinder/volume/drivers/ibm/storwize_svc/__init__.py
@@ -613,7 +613,7 @@ class StorwizeSVCDriver(san.SanDriver):
             if not len(self._vdiskcopyops):
                 self._vdiskcopyops_loop.stop()
                 self._vdiskcopyops_loop = None
-        except IndexError:
+        except KeyError:
             msg = (_('_rm_vdisk_copy_op: Volume %s does not have any '
                      'registered vdisk copy operations.') % volume['id'])
             LOG.error(msg)
-- 
2.45.2