Files
storlets/tests/unit/__init__.py
Takashi Kajinami 95cdd1663e Create storlets package
Previously, we had multiple packages, like storlet_middleware,
storlet_gateway and so on, in our storlets repository.
This patch integrates these packages into one package, to follow
general manner of python packaging.

Also, this patch replaces previous install system using ant by
new install system using python setup.py.

(top directory)
 + bin          <- executable files
 + etc          <- configration samples
 + src          <- non-python codes
 |  + c         <- c codes
 |  | + sbus    <- Previously Engine/SBus/SBusTransportLayer
 |  + java      <- java codes
 |    + SBus    <- Previously Engine/SBus/SBusJavaFacade
 |    + SCommon <- Previously Engine/SBus/SCommon
 |    + SDaemon <- Previously Engine/SBus/SDaemon
 + storlets     <- python codes.
 |  + agent
 |  | + daemon         <- Previously Engine/agent/storlet_daemon
 |  | + daemon_factory <- Previously Engine/agent/storlet_daemon_factory
 |  + gateway          <- Previously Engine/swift/storlet_gateway
 |  + sbus             <- Previously Engine/SBus/SBusPythonFacade
 |  + swift_middleware <- Previously Engine/swift/storlet_middleware
 |  + tools            <- Previously tools
 + tests        <- test codes
 + scripts      <- Previously Engine/SMScripts
 + install_libs.sh     <- Script used to build/install c/java codes
 + setup.cfg
 + setup.py

NOTE1:
Currently we have an independent installation tool for c/java, as the
other existing OpenStack projects (ex. Monasca) do. To install c/java
modules, run './install_libs.sh' at the top directory. It installs
required files under /usr/local/lib/storlets, so you may need root
privilege.

NOTE2:
We install agent resources also on host, but this is currently kept
to be used for our future plan to let containers use agent resources
by mounting it from host node.

NOTE3:
This patch also removes outdated ansible playbooks.

Co-Authored-By: Eran Rom <eran@itsonlyme.name>
Change-Id: Icdcafdf6e6d06917d715ad9a8cba45305613a6fb
2016-12-01 10:28:43 +09:00

77 lines
2.1 KiB
Python

# Copyright (c) 2010-2016 OpenStack Foundation
#
# 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.
import sys
import traceback
import functools
from collections import defaultdict
from shutil import rmtree
from tempfile import mkdtemp
def with_tempdir(f):
"""
Decorator to give a single test a tempdir as argument to test method.
"""
@functools.wraps(f)
def wrapped(*args, **kwargs):
tempdir = mkdtemp()
args = list(args)
args.append(tempdir)
try:
return f(*args, **kwargs)
finally:
rmtree(tempdir)
return wrapped
class MockSBus(object):
@classmethod
def send(self, path, datagram):
# return success code
return 0
class FakeLogger(object):
def __init__(self, *args, **kwargs):
self._log_lines = defaultdict(list)
def _print_log(self, level, msg):
self._log_lines[level.lower()].append(msg)
print('%s: %s' % (level, msg))
def get_log_lines(self, level):
return self._log_lines[level.lower()]
def debug(self, msg):
self._print_log('DEBUG', msg)
def info(self, msg):
self._print_log('INFO', msg)
def warning(self, msg):
self._print_log('WARN', msg)
warn = warning
def error(self, msg):
self._print_log('ERROR', msg)
def exception(self, msg):
exc_type, exc_value, exc_traceback = sys.exc_info()
exc_msg = traceback.format_exception(exc_type, exc_value,
exc_traceback)
new_msg = '%s: %s' % (msg, exc_msg)
self._print_log('EXCEPTION', new_msg)