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
17 LOG = logging.getLogger(__name__)
20 class CheckValue(base.Scenario):
21 """Check values between value1 and value2
24 operator: equal(eq) and not equal(ne)
30 __scenario_type__ = "CheckValue"
32 def __init__(self, scenario_cfg, context_cfg):
33 self.scenario_cfg = scenario_cfg
34 self.context_cfg = context_cfg
35 self.options = self.scenario_cfg['options']
37 def run(self, result):
38 """execute the test"""
40 op = self.options.get("operator")
41 LOG.debug("options=%s", self.options)
42 value1 = str(self.options.get("value1"))
43 value2 = str(self.options.get("value2"))
45 if op == "eq" and value1 != value2:
46 LOG.info("value1=%s, value2=%s, error: should equal!!!", value1,
49 assert value1 == value2, "Error %s!=%s" % (value1, value2)
50 elif op == "ne" and value1 == value2:
51 LOG.info("value1=%s, value2=%s, error: should not equal!!!",
54 assert value1 != value2, "Error %s==%s" % (value1, value2)
55 LOG.info("Check result is %s", check_result)
56 keys = self.scenario_cfg.get('output', '').split()
57 values = [check_result]
58 return self._push_to_outputs(keys, values)