34
34
35
35
IMAGE_NAME = "quay.io/cilium/cilium:v{}" .format (CILIUM_VERSION )
36
36
PORTS = [AGENT_PORT , OPERATOR_PORT ]
37
- CLUSTER_NAME = ' cluster-{}-{}' .format (' cilium' , get_active_env ())
37
+ CLUSTER_NAME = " cluster-{}-{}" .format (" cilium" , get_active_env ())
38
38
39
39
40
40
def setup_cilium ():
@@ -110,7 +110,7 @@ def setup_cilium():
110
110
)
111
111
if result .stderr :
112
112
raise Exception (result .stderr )
113
- pods = result .stdout .split (' ' )
113
+ pods = result .stdout .split (" " )
114
114
115
115
for pod in pods :
116
116
result = run_command (
@@ -135,35 +135,35 @@ def setup_cilium():
135
135
136
136
def get_instances (agent_host , agent_port , operator_host , operator_port , use_openmetrics ):
137
137
return {
138
- ' instances' : [
138
+ " instances" : [
139
139
{
140
- ' agent_endpoint' : ' http://{}:{}/metrics' .format (agent_host , agent_port ),
141
- ' use_openmetrics' : use_openmetrics ,
140
+ " agent_endpoint" : " http://{}:{}/metrics" .format (agent_host , agent_port ),
141
+ " use_openmetrics" : use_openmetrics ,
142
142
},
143
143
{
144
- ' operator_endpoint' : ' http://{}:{}/metrics' .format (operator_host , operator_port ),
145
- ' use_openmetrics' : use_openmetrics ,
144
+ " operator_endpoint" : " http://{}:{}/metrics" .format (operator_host , operator_port ),
145
+ " use_openmetrics" : use_openmetrics ,
146
146
},
147
147
]
148
148
}
149
149
150
150
151
- @pytest .fixture (scope = ' session' )
151
+ @pytest .fixture (scope = " session" )
152
152
def dd_environment ():
153
- use_openmetrics = CILIUM_LEGACY == ' false'
154
- kind_config = os .path .join (HERE , ' kind' , ' kind-config.yaml' )
155
- with TempDir (' helm_dir' ) as helm_dir :
153
+ use_openmetrics = CILIUM_LEGACY == " false"
154
+ kind_config = os .path .join (HERE , " kind" , " kind-config.yaml" )
155
+ with TempDir (" helm_dir" ) as helm_dir :
156
156
with kind_run (
157
157
conditions = [setup_cilium ],
158
158
kind_config = kind_config ,
159
159
env_vars = {
160
- "HELM_CACHE_HOME" : path_join (helm_dir , ' Caches' ),
161
- "HELM_CONFIG_HOME" : path_join (helm_dir , ' Preferences' ),
160
+ "HELM_CACHE_HOME" : path_join (helm_dir , " Caches" ),
161
+ "HELM_CONFIG_HOME" : path_join (helm_dir , " Preferences" ),
162
162
},
163
163
) as kubeconfig :
164
164
with ExitStack () as stack :
165
165
ip_ports = [
166
- stack .enter_context (port_forward (kubeconfig , ' cilium' , port , ' deployment' , ' cilium-operator' ))
166
+ stack .enter_context (port_forward (kubeconfig , " cilium" , port , " deployment" , " cilium-operator" ))
167
167
for port in PORTS
168
168
]
169
169
@@ -176,50 +176,50 @@ def dd_environment():
176
176
177
177
@pytest .fixture (scope = "session" )
178
178
def check ():
179
- return lambda instance : CiliumCheck (' cilium' , {}, [instance ])
179
+ return lambda instance : CiliumCheck (" cilium" , {}, [instance ])
180
180
181
181
182
182
@pytest .fixture (scope = "session" )
183
183
def agent_instance_use_openmetrics ():
184
184
return lambda use_openmetrics : {
185
- ' agent_endpoint' : AGENT_URL ,
186
- ' tags' : [' pod_test' ],
187
- ' use_openmetrics' : use_openmetrics ,
185
+ " agent_endpoint" : AGENT_URL ,
186
+ " tags" : [" pod_test" ],
187
+ " use_openmetrics" : use_openmetrics ,
188
188
}
189
189
190
190
191
191
@pytest .fixture
192
192
def operator_instance_use_openmetrics ():
193
193
return lambda use_openmetrics : {
194
- ' operator_endpoint' : OPERATOR_URL ,
195
- ' tags' : [' operator_test' ],
196
- ' use_openmetrics' : use_openmetrics ,
194
+ " operator_endpoint" : OPERATOR_URL ,
195
+ " tags" : [" operator_test" ],
196
+ " use_openmetrics" : use_openmetrics ,
197
197
}
198
198
199
199
200
200
@pytest .fixture ()
201
201
def mock_agent_data ():
202
- f_name = os .path .join (os .path .dirname (__file__ ), ' fixtures' , ' agent_metrics.txt' )
203
- with open (f_name , 'r' ) as f :
202
+ f_name = os .path .join (os .path .dirname (__file__ ), " fixtures" , " agent_metrics.txt" )
203
+ with open (f_name , "r" ) as f :
204
204
text_data = f .read ()
205
205
with mock .patch (
206
- ' requests.get' ,
206
+ " requests.get" ,
207
207
return_value = mock .MagicMock (
208
- status_code = 200 , iter_lines = lambda ** kwargs : text_data .split ("\n " ), headers = {' Content-Type' : "text/plain" }
208
+ status_code = 200 , iter_lines = lambda ** kwargs : text_data .split ("\n " ), headers = {" Content-Type" : "text/plain" }
209
209
),
210
210
):
211
211
yield
212
212
213
213
214
214
@pytest .fixture ()
215
215
def mock_operator_data ():
216
- f_name = os .path .join (os .path .dirname (__file__ ), ' fixtures' , ' operator_metrics.txt' )
217
- with open (f_name , 'r' ) as f :
216
+ f_name = os .path .join (os .path .dirname (__file__ ), " fixtures" , " operator_metrics.txt" )
217
+ with open (f_name , "r" ) as f :
218
218
text_data = f .read ()
219
219
with mock .patch (
220
- ' requests.get' ,
220
+ " requests.get" ,
221
221
return_value = mock .MagicMock (
222
- status_code = 200 , iter_lines = lambda ** kwargs : text_data .split ("\n " ), headers = {' Content-Type' : "text/plain" }
222
+ status_code = 200 , iter_lines = lambda ** kwargs : text_data .split ("\n " ), headers = {" Content-Type" : "text/plain" }
223
223
),
224
224
):
225
225
yield
0 commit comments