@@ -94,7 +94,7 @@ mod test {
9494 anyhow:: bail!( "kubectl is not installed" ) ;
9595 }
9696
97- let forward_port = port_forward_redis ( redis_port) . await ?;
97+ let forward_port = port_forward_svc ( redis_port, "redis" ) . await ?;
9898
9999 let client = redis:: Client :: open ( format ! ( "redis://localhost:{}" , forward_port) ) ?;
100100 let mut con = client. get_multiplexed_async_connection ( ) . await ?;
@@ -145,13 +145,13 @@ mod test {
145145 anyhow:: bail!( "kubectl is not installed" ) ;
146146 }
147147
148- let forward_port = port_forward_redis ( redis_port) . await ?;
148+ let forward_port = port_forward_svc ( redis_port, "redis" ) . await ?;
149149
150150 let client = redis:: Client :: open ( format ! ( "redis://localhost:{}" , forward_port) )
151151 . context ( "connecting to redis" ) ?;
152152 let mut con = client. get_multiplexed_async_connection ( ) . await ?;
153153
154- con. publish ( "testchannel" , "some-payload" ) . await ?;
154+ con. publish :: < _ , _ , ( ) > ( "testchannel" , "some-payload" ) . await ?;
155155
156156 let one_sec = time:: Duration :: from_secs ( 1 ) ;
157157 thread:: sleep ( one_sec) ;
@@ -175,7 +175,7 @@ mod test {
175175 }
176176
177177 // Port forward the emqx mqtt broker
178- let forward_port = port_forward_emqx ( mqtt_port) . await ?;
178+ let forward_port = port_forward_svc ( mqtt_port, "emqx" ) . await ?;
179179
180180 // Publish a message to the emqx broker
181181 let mut mqttoptions = rumqttc:: MqttOptions :: new ( "123" , "127.0.0.1" , forward_port) ;
@@ -219,20 +219,6 @@ mod test {
219219 Ok ( ( ) )
220220 }
221221
222- async fn port_forward_emqx ( emqx_port : u16 ) -> Result < u16 > {
223- let port = get_random_port ( ) ?;
224-
225- println ! ( " >>> kubectl portforward emqx {}:{} " , port, emqx_port) ;
226-
227- Command :: new ( "kubectl" )
228- . arg ( "port-forward" )
229- . arg ( "emqx" )
230- . arg ( format ! ( "{}:{}" , port, emqx_port) )
231- . spawn ( ) ?;
232- tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 2 ) ) . await ;
233- Ok ( port)
234- }
235-
236222 #[ tokio:: test]
237223 async fn spin_static_assets_test ( ) -> Result < ( ) > {
238224 let host_port = 8082 ;
@@ -270,19 +256,20 @@ mod test {
270256 }
271257 }
272258
273- async fn port_forward_redis ( redis_port : u16 ) -> Result < u16 > {
259+ async fn port_forward_svc ( svc_port : u16 , svc_name : & str ) -> Result < u16 > {
274260 let port = get_random_port ( ) ?;
275261
276- println ! ( " >>> kubectl portforward redis {}:{} " , port, redis_port ) ;
262+ println ! ( " >>> kubectl portforward svc {} {} :{} " , svc_name , port, svc_port ) ;
277263
278264 Command :: new ( "kubectl" )
279265 . arg ( "port-forward" )
280- . arg ( "redis" )
281- . arg ( format ! ( "{}:{}" , port, redis_port ) )
266+ . arg ( svc_name )
267+ . arg ( format ! ( "{}:{}" , port, svc_port ) )
282268 . spawn ( ) ?;
283269 tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 2 ) ) . await ;
284270 Ok ( port)
285271 }
272+
286273
287274 async fn get_logs_by_label ( label : & str ) -> Result < String > {
288275 let output = tokio:: process:: Command :: new ( "kubectl" )
0 commit comments