3 # Copyright (c) 2017 Okinawa Open Laboratory and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # pylint: disable=missing-docstring
12 """vrouter test result check module"""
18 from jinja2 import Environment, FileSystemLoader
22 """vrouter test result check class"""
24 logger = logging.getLogger(__name__)
27 self.logger.debug("init checker")
30 def load_check_rule(rule_file_dir, rule_file_name, parameter):
31 loader = FileSystemLoader(rule_file_dir,
33 env = Environment(loader=loader)
34 check_rule_template = env.get_template(rule_file_name)
35 check_rule = check_rule_template.render(parameter)
36 check_rule_data = json.loads(check_rule)
37 return check_rule_data
40 def regexp_information(response, rules):
44 for rule in rules["rules"]:
46 "test_name": rule["description"],
50 match = re.search(rule["regexp"],
52 rule["response"] = response
57 if not match.group(1) == rule["result"]:
60 result_data["result"] = "OK"
63 return status, result_data