Beispiel #1
0
    def testSameMode(self):
        for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
            lu = _FakeLuWithLocks(
                {
                    level: ["foo"],
                    locking.LEVEL_NODE_ALLOC: locking.ALL_SET,
                }, {
                    level: 1,
                    locking.LEVEL_NODE_ALLOC: 1,
                })
            glm = _FakeGlm(True)

            try:
                mcpu._VerifyLocks(lu,
                                  glm,
                                  _mode_whitelist=[_FakeLuWithLocks],
                                  _nal_whitelist=[])
            except AssertionError, err:
                self.assertTrue(
                    "whitelisted to use different modes" in str(err))
            else:
                self.fail("Exception not raised")

            # Once more without the whitelist
            mcpu._VerifyLocks(lu, glm, _mode_whitelist=[], _nal_whitelist=[])
Beispiel #2
0
 def testNoLocks(self):
     lu = _FakeLuWithLocks({}, {})
     glm = _FakeGlm(False)
     mcpu._VerifyLocks(lu,
                       glm,
                       _mode_whitelist=NotImplemented,
                       _nal_whitelist=NotImplemented)
 def testNotAllSameMode(self):
     for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
         lu = _FakeLuWithLocks({
             level: ["foo"],
         }, {
             level: 0,
             locking.LEVEL_NODE_ALLOC: 0,
         })
         mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
 def testNotAllSameMode(self):
   for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
     lu = _FakeLuWithLocks({
       level: ["foo"],
       }, {
       level: 0,
       locking.LEVEL_NODE_ALLOC: 0,
       })
     mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
  def testDifferentMode(self):
    for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
      lu = _FakeLuWithLocks({
        level: ["foo"],
        }, {
        level: 0,
        locking.LEVEL_NODE_ALLOC: 1,
        })
      try:
        mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
      except AssertionError, err:
        self.assertTrue("using the same mode as nodes" in str(err))
      else:
        self.fail("Exception not raised")

      # Once more with the whitelist
      mcpu._VerifyLocks(lu, _mode_whitelist=[_FakeLuWithLocks],
                        _nal_whitelist=[])
    def testDifferentMode(self):
        for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
            lu = _FakeLuWithLocks({
                level: ["foo"],
            }, {
                level: 0,
                locking.LEVEL_NODE_ALLOC: 1,
            })
            try:
                mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
            except AssertionError, err:
                self.assertTrue("using the same mode as nodes" in str(err))
            else:
                self.fail("Exception not raised")

            # Once more with the whitelist
            mcpu._VerifyLocks(lu,
                              _mode_whitelist=[_FakeLuWithLocks],
                              _nal_whitelist=[])
  def testAllWithoutAllocLock(self):
    for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
      lu = _FakeLuWithLocks({
        level: locking.ALL_SET,
        }, {
        level: 0,
        locking.LEVEL_NODE_ALLOC: 0,
        })

      try:
        mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
      except AssertionError, err:
        self.assertTrue("allocation lock must be used if" in str(err))
      else:
        self.fail("Exception not raised")

      # Once more with the whitelist
      mcpu._VerifyLocks(lu, _mode_whitelist=[],
                        _nal_whitelist=[_FakeLuWithLocks])
    def testAllWithoutAllocLock(self):
        for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
            lu = _FakeLuWithLocks({
                level: locking.ALL_SET,
            }, {
                level: 0,
                locking.LEVEL_NODE_ALLOC: 0,
            })

            try:
                mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
            except AssertionError, err:
                self.assertTrue("allocation lock must be used if" in str(err))
            else:
                self.fail("Exception not raised")

            # Once more with the whitelist
            mcpu._VerifyLocks(lu,
                              _mode_whitelist=[],
                              _nal_whitelist=[_FakeLuWithLocks])
  def testSameMode(self):
    for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
      lu = _FakeLuWithLocks({
        level: ["foo"],
        locking.LEVEL_NODE_ALLOC: locking.ALL_SET,
        }, {
        level: 1,
        locking.LEVEL_NODE_ALLOC: 1,
        })

      try:
        mcpu._VerifyLocks(lu, _mode_whitelist=[_FakeLuWithLocks],
                          _nal_whitelist=[])
      except AssertionError, err:
        self.assertTrue("whitelisted to use different modes" in str(err))
      else:
        self.fail("Exception not raised")

      # Once more without the whitelist
      mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
  def testAllWithAllocLock(self):
    for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
      lu = _FakeLuWithLocks({
        level: locking.ALL_SET,
        locking.LEVEL_NODE_ALLOC: locking.ALL_SET,
        }, {
        level: 0,
        locking.LEVEL_NODE_ALLOC: 0,
        })
      lu.locks = [locking.NAL]

      try:
        mcpu._VerifyLocks(lu, _mode_whitelist=[],
                          _nal_whitelist=[_FakeLuWithLocks])
      except AssertionError, err:
        self.assertTrue("whitelisted for not acquiring" in str(err))
      else:
        self.fail("Exception not raised")

      # Once more without the whitelist
      mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
    def testAllWithAllocLock(self):
        for level in [locking.LEVEL_NODE, locking.LEVEL_NODE_RES]:
            lu = _FakeLuWithLocks(
                {
                    level: locking.ALL_SET,
                    locking.LEVEL_NODE_ALLOC: locking.ALL_SET,
                }, {
                    level: 0,
                    locking.LEVEL_NODE_ALLOC: 0,
                })
            lu.locks = [locking.NAL]

            try:
                mcpu._VerifyLocks(lu,
                                  _mode_whitelist=[],
                                  _nal_whitelist=[_FakeLuWithLocks])
            except AssertionError, err:
                self.assertTrue("whitelisted for not acquiring" in str(err))
            else:
                self.fail("Exception not raised")

            # Once more without the whitelist
            mcpu._VerifyLocks(lu, _mode_whitelist=[], _nal_whitelist=[])
 def testNoLocks(self):
   lu = _FakeLuWithLocks({}, {})
   mcpu._VerifyLocks(lu,
                     _mode_whitelist=NotImplemented,
                     _nal_whitelist=NotImplemented)