From e3cef871ac5a92d38d42fe09d9ac2dbe4404f679 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 11 Oct 2013 10:54:56 +0200 Subject: [PATCH] Add support for keystoneclient 0.4.0 Keystoneclient auth_middleware changed the way it parses the datetime returned from the cache, breaking the Ceilometer unit tests. This patch fixes the fake cache system that's used in unit test, so it works with all keystoneclient versions. This also update the sample configuration files to include the new options provided by keystoneclient 0.4.0. Fixes-Bug: #1238529 Change-Id: Iecfd50d9e9801aeb919f2c09a728e4ea15245a5e --- etc/ceilometer/ceilometer.conf.sample | 11 +++++++++++ tests/api/v2/test_acl_scenarios.py | 19 ++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/etc/ceilometer/ceilometer.conf.sample b/etc/ceilometer/ceilometer.conf.sample index e3b30980b..41928ca78 100644 --- a/etc/ceilometer/ceilometer.conf.sample +++ b/etc/ceilometer/ceilometer.conf.sample @@ -742,6 +742,10 @@ # server. (boolean value) #http_connect_timeout= +# How many times are we trying to reconnect when communicating +# with Identity API Server. (integer value) +#http_request_max_retries=3 + # Allows to pass in the name of a fake http_handler callback # function used instead of httplib.HTTPConnection or # httplib.HTTPSConnection. Useful for unit testing where @@ -774,6 +778,13 @@ # (string value) #keyfile= +# A PEM encoded Certificate Authority to use when verifying +# HTTPs connections. Defaults to system CAs. (string value) +#cafile= + +# Verify HTTPS connections. (boolean value) +#insecure=false + # Directory used to cache files related to PKI tokens (string # value) #signing_dir= diff --git a/tests/api/v2/test_acl_scenarios.py b/tests/api/v2/test_acl_scenarios.py index 0f39f2aef..144112b73 100644 --- a/tests/api/v2/test_acl_scenarios.py +++ b/tests/api/v2/test_acl_scenarios.py @@ -27,6 +27,7 @@ from ceilometer import sample from ceilometer.api import acl from ceilometer.publisher import rpc from ceilometer.tests import db as tests_db +from ceilometer.openstack.common import timeutils from .base import FunctionalTest @@ -37,12 +38,8 @@ VALID_TOKEN2 = '4562138218392832' class FakeMemcache(object): - def __init__(self): - self.set_key = None - self.set_value = None - self.token_expiration = None - - def get(self, key): + @staticmethod + def get(key): if key == "tokens/%s" % VALID_TOKEN: dt = datetime.datetime.now() + datetime.timedelta(minutes=5) return json.dumps(({'access': { @@ -55,7 +52,7 @@ class FakeMemcache(object): 'roles': [ {'name': 'admin'}, ]}, - }}, dt.strftime("%s"))) + }}, timeutils.isotime(dt))) if key == "tokens/%s" % VALID_TOKEN2: dt = datetime.datetime.now() + datetime.timedelta(minutes=5) return json.dumps(({'access': { @@ -68,11 +65,11 @@ class FakeMemcache(object): 'roles': [ {'name': 'Member'}, ]}, - }}, dt.strftime("%s"))) + }}, timeutils.isotime(dt))) - def set(self, key, value, **kwargs): - self.set_value = value - self.set_key = key + @staticmethod + def set(key, value, **kwargs): + pass class TestAPIACL(FunctionalTest,