@@ -26,13 +26,10 @@ class TestClient(unittest.TestCase):
26
26
27
27
@classmethod
28
28
def setUpClass (cls ):
29
- cls .API_URL = 'http://127.0.0.1:8080/'
30
- cls .config = configuration
29
+ cls .config = base .get_e2e_configuration ()
31
30
32
- @unittest .skipUnless (
33
- base .is_k8s_running (), "Kubernetes is not available" )
34
31
def test_pod_apis (self ):
35
- client = api_client .ApiClient (self . API_URL , config = self .config )
32
+ client = api_client .ApiClient (config = self .config )
36
33
api = core_v1_api .CoreV1Api (client )
37
34
38
35
name = 'busybox-test-' + str (uuid .uuid4 ())
@@ -79,16 +76,22 @@ def test_pod_apis(self):
79
76
print ('EXEC response : %s' % resp )
80
77
self .assertEqual (3 , len (resp .splitlines ()))
81
78
79
+ exec_command = 'uptime'
80
+ resp = api .connect_post_namespaced_pod_exec (name , 'default' ,
81
+ command = exec_command ,
82
+ stderr = False , stdin = False ,
83
+ stdout = True , tty = False )
84
+ print ('EXEC response : %s' % resp )
85
+ self .assertEqual (1 , len (resp .splitlines ()))
86
+
82
87
number_of_pods = len (api .list_pod_for_all_namespaces ().items )
83
88
self .assertTrue (number_of_pods > 0 )
84
89
85
90
resp = api .delete_namespaced_pod (name = name , body = {},
86
91
namespace = 'default' )
87
92
88
- @unittest .skipUnless (
89
- base .is_k8s_running (), "Kubernetes is not available" )
90
93
def test_service_apis (self ):
91
- client = api_client .ApiClient (self . API_URL , config = self .config )
94
+ client = api_client .ApiClient (config = self .config )
92
95
api = core_v1_api .CoreV1Api (client )
93
96
94
97
name = 'frontend-' + str (uuid .uuid4 ())
@@ -126,10 +129,8 @@ def test_service_apis(self):
126
129
resp = api .delete_namespaced_service (name = name ,
127
130
namespace = 'default' )
128
131
129
- @unittest .skipUnless (
130
- base .is_k8s_running (), "Kubernetes is not available" )
131
132
def test_replication_controller_apis (self ):
132
- client = api_client .ApiClient (self . API_URL , config = self .config )
133
+ client = api_client .ApiClient (config = self .config )
133
134
api = core_v1_api .CoreV1Api (client )
134
135
135
136
name = 'frontend-' + str (uuid .uuid4 ())
@@ -161,10 +162,8 @@ def test_replication_controller_apis(self):
161
162
resp = api .delete_namespaced_replication_controller (
162
163
name = name , body = {}, namespace = 'default' )
163
164
164
- @unittest .skipUnless (
165
- base .is_k8s_running (), "Kubernetes is not available" )
166
165
def test_configmap_apis (self ):
167
- client = api_client .ApiClient (self . API_URL , config = self .config )
166
+ client = api_client .ApiClient (config = self .config )
168
167
api = core_v1_api .CoreV1Api (client )
169
168
170
169
name = 'test-configmap-' + str (uuid .uuid4 ())
@@ -199,21 +198,11 @@ def test_configmap_apis(self):
199
198
resp = api .list_namespaced_config_map ('kube-system' , pretty = True )
200
199
self .assertEqual ([], resp .items )
201
200
202
- @unittest .skipUnless (
203
- base .is_k8s_running (), "Kubernetes is not available" )
204
201
def test_node_apis (self ):
205
- client = api_client .ApiClient (self . API_URL , config = self .config )
202
+ client = api_client .ApiClient (config = self .config )
206
203
api = core_v1_api .CoreV1Api (client )
207
204
208
205
for item in api .list_node ().items :
209
206
node = api .read_node (name = item .metadata .name )
210
207
self .assertTrue (len (node .metadata .labels ) > 0 )
211
- self .assertTrue (isinstance (node .metadata .labels , dict ))
212
-
213
-
214
- class TestClientSSL (TestClient ):
215
-
216
- @classmethod
217
- def setUpClass (cls ):
218
- cls .API_URL = 'https://127.0.0.1:8443/'
219
- cls .config = base .setSSLConfiguration ()
208
+ self .assertTrue (isinstance (node .metadata .labels , dict ))
0 commit comments