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 import functest.core.testcase_base as testcase_base
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(testcase_base.TestcaseBase):
24 SDNVPN_REPO_TESTS = os.path.join(
25 ft_constants.SDNVPN_REPO_DIR, "tests/functest")
26 logger = ft_logger.Logger("sdnvpn").getLogger()
29 super(SdnVpnTests, self).__init__()
30 self.project_name = "sdnvpn"
31 self.case_name = "bgpvpn"
33 def main(self, **kwargs):
34 os.chdir(self.SDNVPN_REPO_TESTS)
36 log_file = os.path.join(
37 ft_constants.FUNCTEST_RESULTS_DIR, "sdnvpn.log")
38 start_time = time.time()
40 ret = ft_utils.execute_command(cmd,
43 stop_time = time.time()
45 self.logger.info("%s OK" % self.case_name)
48 self.logger.info("%s FAILED" % self.case_name)
51 # report status only if tests run (FAIL OR PASS)
52 self.criteria = status
53 self.start_time = start_time
54 self.stop_time = stop_time
59 return self.main(**kwargs)
62 if __name__ == '__main__':
63 parser = argparse.ArgumentParser()
64 parser.add_argument("-r", "--report",
65 help="Create json result file",
67 args = vars(parser.parse_args())
68 sdnvpn = SdnVpnTests()
70 result = sdnvpn.main(**args)
71 if result != testcase_base.TestcaseBase.EX_OK:
74 sys.exit(sdnvpn.push_to_db())
76 sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)