Fixing keystone singleton problem
Change-Id: I15adbf83b8445e5c952fda846c9e2e5b3f975d35
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,3 +12,4 @@ root
|
|||||||
AUTHORS
|
AUTHORS
|
||||||
ChangeLog
|
ChangeLog
|
||||||
*.egg*
|
*.egg*
|
||||||
|
.*.sw*
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ import monasca_agent.common.singleton as singleton
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Make this a singleton class so we don't get the token every time
|
||||||
|
# the class is created
|
||||||
|
@six.add_metaclass(singleton.Singleton)
|
||||||
class Keystone(object):
|
class Keystone(object):
|
||||||
# Make this a singleton class so we don't get the token every time
|
|
||||||
# the class is created
|
|
||||||
six.add_metaclass(singleton.Singleton)
|
|
||||||
|
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|||||||
17
tests/test_keystone.py
Normal file
17
tests/test_keystone.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import os.path
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from monasca_agent.common.keystone import Keystone
|
||||||
|
from monasca_agent.common.util import is_valid_hostname
|
||||||
|
from monasca_agent.common.util import PidFile
|
||||||
|
|
||||||
|
|
||||||
|
class TestConfig(unittest.TestCase):
|
||||||
|
def testKeyStoneIsSingleton(self):
|
||||||
|
keystone_1 = Keystone({})
|
||||||
|
keystone_2 = Keystone({})
|
||||||
|
keystone_3 = Keystone({})
|
||||||
|
|
||||||
|
self.assertTrue(keystone_1 is keystone_2)
|
||||||
|
self.assertTrue(keystone_1 is keystone_3)
|
||||||
Reference in New Issue
Block a user