created a mock db to remove relience on cassandra for testing

This commit is contained in:
amitgandhinz 2014-06-27 10:53:49 -04:00
parent e222acf9d4
commit 6673c2b66e
7 changed files with 7 additions and 109 deletions

View File

@ -25,7 +25,7 @@ LOG = log.getLogger(__name__)
_DRIVER_OPTIONS = [
cfg.StrOpt('transport', default='falcon',
help='Transport driver to use'),
cfg.StrOpt('storage', default='mongodb',
cfg.StrOpt('storage', default='mockdb',
help='Storage driver to use'),
]

View File

@ -1,6 +0,0 @@
"""CDN Extension for CDN"""
from cdn.provider.sample import driver
# Hoist classes into package namespace
CDNProvider = driver.CDNProvider

View File

@ -1,27 +0,0 @@
# Copyright (c) 2013 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Exports Sample CDN controllers.
Field Mappings:
In order to reduce the disk / memory space used,
fields name will be, most of the time, the first
letter of their long name. Fields mapping will be
updated and documented in each controller class.
"""
from cdn.provider.sample import services
ServiceController = services.ServiceController

View File

@ -1,38 +0,0 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""CDN Provider implementation."""
from cdn.common import decorators
from cdn.openstack.common import log as logging
from cdn import provider
from cdn.provider.sample import controllers
from oslo.config import cfg
LOG = logging.getLogger(__name__)
class CDNProvider(provider.CDNProviderBase):
def __init__(self, conf):
super(CDNProvider, self).__init__(conf)
def is_alive(self):
return True
@decorators.lazy_property(write=False)
def service_controller(self):
return controllers.ServiceController()

View File

@ -1,35 +0,0 @@
# Copyright (c) 2014 Rackspace, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# stevedore/example/simple.py
from cdn.provider import base
class ServiceController(base.ServiceBase):
def __init__(self):
super(ServiceController, self).__init__()
self.provider_resp = base.ProviderResponse("sample")
def update(self):
return self.provider_resp.updated(service_name)
def create(self, service_name, service_json):
return self.provider_resp.created(service_name)
def delete(self, service_name):
return self.provider_resp.deleted(service_name)

View File

@ -30,7 +30,7 @@ log_file = cdn.log
transport = falcon
# Storage driver module (e.g., mongodb, sqlite, cassandra)
storage = cassandra
storage = mockdb
[drivers:transport:falcon]
@ -45,5 +45,8 @@ database = cdn
cluster = "localhost"
keyspace = cdn
[drivers:storage:mockdb]
database = cdn
[drivers:provider:fastly]
apikey = "MYAPIKEY"

View File

@ -32,10 +32,11 @@ cdn.transport =
cdn.storage =
mongodb = cdn.storage.mongodb.driver:StorageDriver
cassandra = cdn.storage.cassandra.driver:StorageDriver
mockdb = cdn.storage.mockdb.driver:StorageDriver
cdn.provider =
fastly = cdn.provider.fastly.driver:CDNProvider
sample = cdn.provider.sample.driver:CDNProvider
mock = cdn.provider.mock.driver:CDNProvider
[nosetests]
where=tests