# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
-from __future__ import print_function
-
import sys
import os
import logging
+import collections
# ixload uses its own py2. So importing jsonutils fails. So adding below
# workaround to support call from yardstick
except ImportError:
import json as jsonutils
-from yardstick.common.utils import join_non_strings
-from yardstick.common.utils import ErrorClass
+from yardstick.common import exceptions
try:
from IxLoad import IxLoad, StatCollectorUtils
except ImportError:
- IxLoad = ErrorClass
- StatCollectorUtils = ErrorClass
+ IxLoad = exceptions.ErrorClass
+ StatCollectorUtils = exceptions.ErrorClass
+
LOG = logging.getLogger(__name__)
CSV_FILEPATH_NAME = 'IxL_statResults.csv'
"""
+def validate_non_string_sequence(value, default=None, raise_exc=None):
+ if isinstance(value, collections.Sequence) and not isinstance(value, str):
+ return value
+ if raise_exc:
+ raise raise_exc # pylint: disable=raising-bad-type
+ return default
+
+
+def join_non_strings(separator, *non_strings):
+ try:
+ non_strings = validate_non_string_sequence(non_strings[0], raise_exc=RuntimeError)
+ except (IndexError, RuntimeError):
+ pass
+ return str(separator).join(str(non_string) for non_string in non_strings)
+
+
class IXLOADHttpTest(object):
def __init__(self, test_input):
- self.test_input = jsonutils.loads(test_input)
- self.parse_run_test()
self.ix_load = None
self.stat_utils = None
self.remote_server = None
self.chassis = None
self.card = None
self.ports_to_reassign = None
+ self.test_input = jsonutils.loads(test_input)
+ self.parse_run_test()
@staticmethod
def format_ports_for_reassignment(ports):
# ---- Remap ports ----
try:
self.reassign_ports(test, repository, self.ports_to_reassign)
- except Exception:
+ except Exception: # pylint: disable=broad-except
LOG.exception("Exception occurred during reassign_ports")
# -----------------------------------------------------------------------
ixload_obj.start_http_test()
if __name__ == '__main__':
+ LOG.info("Start http_ixload test")
main(sys.argv)