diff options
author | Linda Wang <wangwulin@huawei.com> | 2018-03-22 07:14:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-03-22 07:14:50 +0000 |
commit | c8f31c082aff3e99a30a9bb6dafaba2b30abf985 (patch) | |
tree | ebfedb3bc734cc5aad614272a8db27c9ae1a4a8c | |
parent | effbcd570ff6db48742e67954c70507a8c999f06 (diff) | |
parent | 9447a0f6fb4a7cedcfb168cf196890a452ce6a7c (diff) |
Merge "Remove KUBECONFIG from env vars"
-rw-r--r-- | functest_kubernetes/k8stest.py | 23 | ||||
-rw-r--r-- | functest_kubernetes/test_k8stest.py | 4 |
2 files changed, 12 insertions, 15 deletions
diff --git a/functest_kubernetes/k8stest.py b/functest_kubernetes/k8stest.py index 65c8acfc..d851d9ef 100644 --- a/functest_kubernetes/k8stest.py +++ b/functest_kubernetes/k8stest.py @@ -30,6 +30,7 @@ class K8sTesting(testcase.TestCase): def __init__(self, **kwargs): super(K8sTesting, self).__init__(**kwargs) + self.config = '/root/.kube/config' self.cmd = [] self.result = 0 self.start_time = 0 @@ -51,24 +52,24 @@ class K8sTesting(testcase.TestCase): i = 0 while i < len(lines): if '[k8s.io]' in lines[i]: - if i != 0 and 'seconds' in lines[i-1]: - self.__logger.debug(lines[i-1]) - while lines[i] != '-'*len(lines[i]): + if i != 0 and 'seconds' in lines[i - 1]: + self.__logger.debug(lines[i - 1]) + while lines[i] != '-' * len(lines[i]): if lines[i].startswith('STEP:') or ('INFO:' in lines[i]): break self.__logger.debug(lines[i]) - i = i+1 + i = i + 1 success = 'SUCCESS!' in lines[i] failure = 'FAIL!' in lines[i] if success or failure: - if i != 0 and 'seconds' in lines[i-1]: - remarks.append(lines[i-1]) + if i != 0 and 'seconds' in lines[i - 1]: + remarks.append(lines[i - 1]) remarks = remarks + lines[i].replace('--', '|').split('|') break - i = i+1 + i = i + 1 - self.__logger.debug('-'*10) + self.__logger.debug('-' * 10) self.__logger.info("Remarks:") for remark in remarks: if 'seconds' in remark: @@ -87,7 +88,7 @@ class K8sTesting(testcase.TestCase): def run(self, **kwargs): - if not os.path.isfile(os.getenv('KUBECONFIG')): + if not os.path.isfile(self.config): self.__logger.error( "Cannot run k8s testcases. Config file not found ") return self.EX_RUN_ERROR @@ -107,7 +108,6 @@ class K8sTesting(testcase.TestCase): """Check if required environment variables are set""" try: assert 'DEPLOY_SCENARIO' in os.environ - assert 'KUBECONFIG' in os.environ assert 'KUBE_MASTER_IP' in os.environ assert 'KUBERNETES_PROVIDER' in os.environ assert 'KUBE_MASTER_URL' in os.environ @@ -135,4 +135,5 @@ class K8sConformanceTest(K8sTesting): super(K8sConformanceTest, self).__init__(**kwargs) self.check_envs() self.cmd = ['/src/k8s.io/kubernetes/_output/bin/e2e.test', - '--ginkgo.focus', 'Conformance'] + '-ginkgo.focus', 'Conformance', + '-kubeconfig', self.config] diff --git a/functest_kubernetes/test_k8stest.py b/functest_kubernetes/test_k8stest.py index 02c8f7e6..eb46ac83 100644 --- a/functest_kubernetes/test_k8stest.py +++ b/functest_kubernetes/test_k8stest.py @@ -23,7 +23,6 @@ class K8sTests(unittest.TestCase): def setUp(self): os.environ["DEPLOY_SCENARIO"] = "k8-test" - os.environ["KUBECONFIG"] = "/home/config" os.environ["KUBE_MASTER_IP"] = "127.0.0.1" os.environ["KUBE_MASTER_URL"] = "https://127.0.0.1:6443" os.environ["KUBERNETES_PROVIDER"] = "local" @@ -36,9 +35,6 @@ class K8sTests(unittest.TestCase): def test_no_deploy_scenario(self): self._test_no_env_var("DEPLOY_SCENARIO") - def test_no_kubeconfig(self): - self._test_no_env_var("KUBECONFIG") - def test_no_kube_master_ip(self): self._test_no_env_var("KUBE_MASTER_IP") |