Merge "Cleanup kube_config temp files between test runs"

This commit is contained in:
Zuul 2019-05-13 14:40:04 +00:00 committed by Gerrit Code Review
commit 50c1d0eafa
1 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,7 @@
import glob
import itertools
import kubernetes.config.kube_config
import logging
import os
import random
@ -189,6 +190,16 @@ class BaseTestCase(testtools.TestCase):
LoggingPopenFactory))
self.setUpFakes()
self.addCleanup(self._cleanup)
def _cleanup(self):
# This is a hack to cleanup kubernetes temp files during test runs.
# The kube_config maintains a global dict of temporary files. During
# running the tests those can get deleted during the cleanup phase of
# the tests without kube_config knowing about this so forcefully tell
# kube_config to clean this up.
kubernetes.config.kube_config._cleanup_temp_files()
def setUpFakes(self):
clouds_path = os.path.join(os.path.dirname(__file__),
'fixtures', 'clouds.yaml')