3 # Copyright (c) 2016 All rights reserved
4 # 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
8 # http://www.apache.org/licenses/LICENSE-2.0
17 from functest.core import TestCasesBase
18 import functest.utils.functest_constants as ft_constants
19 import functest.utils.functest_logger as ft_logger
20 import functest.utils.functest_utils as ft_utils
23 class SdnVpnTests(TestCasesBase.TestCasesBase):
24 SDNVPN_REPO = ft_constants.SDNVPN_REPO_DIR
25 SDNVPN_REPO_TESTS = os.path.join(SDNVPN_REPO, "tests/functest")
26 RESULTS_DIR = ft_constants.FUNCTEST_RESULTS_DIR
27 logger = ft_logger.Logger("sdnvpn").getLogger()
30 super(SdnVpnTests, self).__init__()
31 self.project_name = "sdnvpn"
32 self.case_name = "bgpvpn"
34 def main(self, **kwargs):
35 os.chdir(self.SDNVPN_REPO_TESTS)
37 log_file = os.path.join(self.RESULTS_DIR, "sdnvpn.log")
38 start_time = time.time()
40 ret = ft_utils.execute_command(cmd,
43 stop_time = time.time()
44 duration = round(stop_time - start_time, 1)
45 if ret == 0 and duration > 1:
46 self.logger.info("%s OK" % self.case_name)
48 elif ret == 0 and duration <= 1:
49 self.logger.info("%s TEST SKIPPED" % self.case_name)
52 self.logger.info("%s FAILED" % self.case_name)
55 # report status only if tests run (FAIL OR PASS)
56 if status is not "SKIP":
57 self.criteria = status
58 self.start_time = start_time
59 self.stop_time = stop_time
64 return self.main(**kwargs)
66 if __name__ == '__main__':
67 parser = argparse.ArgumentParser()
68 parser.add_argument("-r", "--report",
69 help="Create json result file",
71 args = vars(parser.parse_args())
72 sdnvpn = SdnVpnTests()
74 result = sdnvpn.main(**args)
75 if result != TestCasesBase.TestCasesBase.EX_OK:
78 sys.exit(sdnvpn.push_to_db())
80 sys.exit(TestCasesBase.TestCasesBase.EX_RUN_ERROR)