Skip to content

Commit bc1c5fb

Browse files
committed
mock
Signed-off-by: Javan Lacerda <javanlacerda@google.com>
1 parent 036b6bb commit bc1c5fb

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/clusterfuzz/_internal/datastore/ndb_init.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,21 @@ def context():
5151
# multiprocessing.set_start_method to not fork.
5252
context_module._state.context = None # pylint: disable=protected-access
5353

54-
with _client().context() as ndb_context:
55-
# Disable NDB caching, as NDB on GCE VMs do not use memcache and therefore
56-
# can't invalidate the memcache cache.
57-
ndb_context.set_memcache_policy(False)
54+
current_context = context_module.get_context(False)
55+
if current_context:
56+
yield current_context
5857

59-
# Disable the in-context cache, as it can use up a lot of memory for
60-
# longer running tasks such as cron jobs.
61-
ndb_context.set_cache_policy(False)
58+
else:
59+
with _client().context() as ndb_context:
60+
# Disable NDB caching, as NDB on GCE VMs do not use memcache and therefore
61+
# can't invalidate the memcache cache.
62+
ndb_context.set_memcache_policy(False)
6263

63-
yield ndb_context
64+
# Disable the in-context cache, as it can use up a lot of memory for
65+
# longer running tasks such as cron jobs.
66+
ndb_context.set_cache_policy(False)
67+
68+
yield ndb_context
6469

6570

6671
def thread_wrapper(func):

src/clusterfuzz/_internal/tests/core/kubernetes/kubernetes_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class KubernetesJobClientTest(unittest.TestCase):
3232

3333
def setUp(self):
3434
helpers.patch(self, [
35+
'clusterfuzz._internal.k8s.service.KubernetesService._load_gke_credentials',
3536
'kubernetes.config.load_kube_config',
3637
'kubernetes.client.CoreV1Api',
3738
'kubernetes.client.BatchV1Api',

0 commit comments

Comments
 (0)