1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 from __future__ import print_function
11 from __future__ import absolute_import
15 from yardstick.benchmark.scenarios import base
16 from yardstick.common import exceptions as y_exc
18 LOG = logging.getLogger(__name__)
21 class CheckValue(base.Scenario):
22 """Check values between value1 and value2
25 operator: equal(eq) and not equal(ne)
31 __scenario_type__ = "CheckValue"
33 def __init__(self, scenario_cfg, context_cfg):
34 self.scenario_cfg = scenario_cfg
35 self.context_cfg = context_cfg
36 self.options = self.scenario_cfg['options']
39 """execute the test"""
41 op = self.options.get("operator")
42 LOG.debug("options=%s", self.options)
43 value1 = str(self.options.get("value1"))
44 value2 = str(self.options.get("value2"))
45 if (op == "eq" and value1 != value2) or (op == "ne" and
47 raise y_exc.ValueCheckError(
48 value1=value1, operator=op, value2=value2)
50 LOG.info("Check result is %s", check_result)
51 keys = self.scenario_cfg.get('output', '').split()
52 values = [check_result]
53 return self._push_to_outputs(keys, values)