@@ -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,14 @@ 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" )
155+ . await ?;
155156
156157 let one_sec = time:: Duration :: from_secs ( 1 ) ;
157158 thread:: sleep ( one_sec) ;
@@ -175,7 +176,7 @@ mod test {
175176 }
176177
177178 // Port forward the emqx mqtt broker
178- let forward_port = port_forward_emqx ( mqtt_port) . await ?;
179+ let forward_port = port_forward_svc ( mqtt_port, "emqx" ) . await ?;
179180
180181 // Publish a message to the emqx broker
181182 let mut mqttoptions = rumqttc:: MqttOptions :: new ( "123" , "127.0.0.1" , forward_port) ;
@@ -219,20 +220,6 @@ mod test {
219220 Ok ( ( ) )
220221 }
221222
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-
236223 #[ tokio:: test]
237224 async fn spin_static_assets_test ( ) -> Result < ( ) > {
238225 let host_port = 8082 ;
@@ -270,15 +257,18 @@ mod test {
270257 }
271258 }
272259
273- async fn port_forward_redis ( redis_port : u16 ) -> Result < u16 > {
260+ async fn port_forward_svc ( svc_port : u16 , svc_name : & str ) -> Result < u16 > {
274261 let port = get_random_port ( ) ?;
275262
276- println ! ( " >>> kubectl portforward redis {}:{} " , port, redis_port) ;
263+ println ! (
264+ " >>> kubectl portforward svc {} {}:{} " ,
265+ svc_name, port, svc_port
266+ ) ;
277267
278268 Command :: new ( "kubectl" )
279269 . arg ( "port-forward" )
280- . arg ( "redis" )
281- . arg ( format ! ( "{}:{}" , port, redis_port ) )
270+ . arg ( svc_name )
271+ . arg ( format ! ( "{}:{}" , port, svc_port ) )
282272 . spawn ( ) ?;
283273 tokio:: time:: sleep ( tokio:: time:: Duration :: from_secs ( 2 ) ) . await ;
284274 Ok ( port)
0 commit comments