diff --git a/test/e2e/lib/install.bash b/test/e2e/lib/install.bash index 580103e0e..cf3242a71 100755 --- a/test/e2e/lib/install.bash +++ b/test/e2e/lib/install.bash @@ -4,6 +4,8 @@ source "${E2E_DIR}/lib/defer.bash" # shellcheck disable=SC1090 source "${E2E_DIR}/lib/template.bash" +# shellcheck disable=SC1090 +source "${E2E_DIR}/lib/poll.bash" function install_tiller() { if ! helm version > /dev/null 2>&1; then # only if helm isn't already installed @@ -95,20 +97,25 @@ function install_git_srv() { kubectl apply -n "${FLUX_NAMESPACE}" -k "${E2E_DIR}/fixtures/kustom/${kustomization_dir}" >&3 - # Wait for the git server to be ready + # Wait for the git server to be rolled out kubectl -n "${FLUX_NAMESPACE}" rollout status deployment/gitsrv + local git_srv_podname + git_srv_podname=$(kubectl get pod -n "${FLUX_NAMESPACE}" -l name=gitsrv -o jsonpath="{['items'][0].metadata.name}") + coproc kubectl port-forward -n "${FLUX_NAMESPACE}" "$git_srv_podname" :22 + local local_port + read -r local_port <&"${COPROC[0]}"- + # shellcheck disable=SC2001 + local_port=$(echo "$local_port" | sed 's%.*:\([0-9]*\).*%\1%') + local ssh_cmd="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $gen_dir/id_rsa -p $local_port" + # Wait for the git server to be ready + GIT_SSH_COMMAND="${ssh_cmd}" poll_until_true 'gitsrv to be ready' 'git ls-remote ssh://git@localhost/git-server/repos/cluster.git master > /dev/null' + if [ -n "$external_access_result_var" ]; then - local git_srv_podname - git_srv_podname=$(kubectl get pod -n "${FLUX_NAMESPACE}" -l name=gitsrv -o jsonpath="{['items'][0].metadata.name}") - coproc kubectl port-forward -n "${FLUX_NAMESPACE}" "$git_srv_podname" :22 - local local_port - read -r local_port <&"${COPROC[0]}"- - # shellcheck disable=SC2001 - local_port=$(echo "$local_port" | sed 's%.*:\([0-9]*\).*%\1%') - local ssh_cmd="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i $gen_dir/id_rsa -p $local_port" # return the ssh command needed for git, and the PID of the port-forwarding PID into a variable of choice eval "${external_access_result_var}=('$ssh_cmd' '$COPROC_PID')" + else + kill "${COPROC_PID}" > /dev/null fi }