Put vnf_test pass if more than 80% of vnf test result are OK
[functest.git] / functest / opnfv_tests / vnf / router / vyos_vrouter.py
1 #!/usr/bin/env python
2 #
3 #  Copyright 2017 Okinawa Open Laboratory
4 #
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
9 import functest.core.feature as base
10 import json
11 import os
12
13 RESULT_DETAILS_FILE = "test_result.json"
14
15
16 class VrouterVnf(base.Feature):
17     def __init__(self, **kwargs):
18         kwargs["repo"] = 'dir_repo_vrouter'
19         if "case_name" not in kwargs:
20             kwargs["case_name"] = "vyos_vrouter"
21         super(VrouterVnf, self).__init__(**kwargs)
22         self.cmd = 'cd %s && ./run.sh' % self.repo
23
24     def set_result_details(self):
25         filepath = os.path.join(self.repo, RESULT_DETAILS_FILE)
26         if os.path.exists(filepath):
27             f = open(filepath, 'r')
28             self.details = json.load(f)
29             f.close()
30
31     def log_results(self):
32         if self.result == 'PASS':
33             self.set_result_details()
34         super(VrouterVnf, self).log_results()