Skip to content

Commit

Permalink
ci(utilities): stable tests when using original listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Sep 19, 2024
1 parent 7e675f5 commit b30b73f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions tests/utilities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::TcpListener;
use tokio::sync::oneshot;
use tokio::time::{sleep, timeout};
use tokio::{join, spawn};
use tokio::{join, select, spawn};
use tokio_stream::wrappers::TcpListenerStream;
use vaultrs::client::{VaultClient, VaultClientSettingsBuilder};
use vaultrs::kv2;
Expand Down Expand Up @@ -277,19 +277,20 @@ pub async fn open_argocd_server_port_forward(kubectl: &Client) -> (u16, oneshot:
let listener = TcpListener::bind("127.0.0.1:0")
.await
.expect("Failed to find free random port");
let addr = listener.local_addr().unwrap();
let bound_port = addr.port();
let bound_port = listener
.local_addr()
.expect("Failed to unwrap TCP listener address")
.port();

let (stop_sender, stop_receiver) = oneshot::channel::<()>();
let is_running = Arc::new(AtomicBool::new(true));

let pod_name = get_pod_name_matching_label_filter(&pods, ARGOCD_SERVER_LABEL_SELECTOR).await;

let port_forward = async move {
let listener = TcpListener::bind(addr).await.unwrap();
let mut incoming = TcpListenerStream::new(listener);

tokio::select! {
select! {
_ = stop_receiver => {
is_running.store(false, Ordering::SeqCst);
}
Expand Down

0 comments on commit b30b73f

Please sign in to comment.