-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to ensure kubernetes client threadpool is cleaned up
- Loading branch information
1 parent
1460b1f
commit e745897
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# coding: utf-8 | ||
|
||
|
||
import atexit | ||
import weakref | ||
import unittest | ||
|
||
import kubernetes | ||
|
||
|
||
class TestApiClient(unittest.TestCase): | ||
|
||
def test_context_manager_closes_threadpool(self): | ||
with kubernetes.client.ApiClient() as client: | ||
self.assertIsNotNone(client.pool) | ||
pool_ref = weakref.ref(client._pool) | ||
self.assertIsNotNone(pool_ref()) | ||
self.assertIsNone(pool_ref()) | ||
|
||
def test_atexit_closes_threadpool(self): | ||
client = kubernetes.client.ApiClient() | ||
self.assertIsNotNone(client.pool) | ||
self.assertIsNotNone(client._pool) | ||
atexit._run_exitfuncs() | ||
self.assertIsNone(client._pool) |