Skip to content

Commit

Permalink
check port
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jan 16, 2025
1 parent a53b4f3 commit 7642dbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ jobs:
uses: helm/kind-action@v1
with:
install_only: false
- name: Install Socat
run: |
sudo apt-get update
sudo apt-get install -y socat
- name: Instal Kind and Control Center
env:
CC_KEY: ${{ secrets.CC_KEY }}
Expand Down
37 changes: 17 additions & 20 deletions scripts/pit/lib/lib-cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ CC_TLS=control-center-tls
CC_CLUSTER=cc-cluster
CC_NS=control-center

checkCcCommands() {
type command >/dev/null 2>&1 || return 1
for command_name in $*; do
if ! command -v "$command_name" >/dev/null 2>&1; then
err "Command: '$command_name' is not installed" && return 1
fi
done
}

getPids() {
H=`grep -a "" /proc/*/cmdline 2>/dev/null | xargs -0 | grep -v grep | perl -pe 's|/proc/(.*?)/cmdline:|$1 |g'`
if [ -n "$H" ]
Expand Down Expand Up @@ -48,18 +39,23 @@ stopCloudProvider() {
startPortForward() {
[ -z "$3" ] && echo "startPortForward name-space service port" && return 1
H=`getPids "kubectl port-forward $2"`
set -x
sudo ls
id
echo "$H"
[ -n "$H" ] && return 0

port="${4:-3}"
log "Starting k8s port-forward $1 $2 -> ${3:-2}"
if [ "$port" -le 1024 ];
then
cmd=`which kubectl`" port-forward $2 $port:$3 -n $1 > /tmp/kubectl-port-forward.logs 2>&1 &"
echo "# $cmd"
sudo bash -c "$cmd"
f=/tmp/kubectl-port-forward.logs
touch $f
chmod 777 $f

if checkCommands socat; then
log "Starting socat port-forward $1 $2 $3 -> 4$3"
kubectl port-forward $2 4$3:$3 -n $1 & || return 1
log "Starting socat port-forward 4$3 -> $3"
sudo socat tcp-listen:$3,fork,reuseaddr tcp:$2:$3 & || return 1
else
kubectl port-forward $2 $port:$3 -n $1 > /tmp/kubectl-port-forward.logs 2>&1 &
log "Starting socat port-forward $1 $2 $3 -> $4"
kubectl port-forward $2 $4:$3 -n $1 & || return 1
fi
}

Expand Down Expand Up @@ -182,18 +178,19 @@ runControlCenter() {
computeNpm
case "$1" in
start)
checkCcCommands kind helm docker kubectl || return 1
checkCommands kind helm docker kubectl || return 1
deleteCluster
createCluster || return 1
stopCloudProvider
startCloudProvider || return 1
installCC || waitForCC 400 || return 1
[ -n "$CC_KEY" -a -n "$CC_CERT" ] && installTls || return 1
forwardIngress || return 1
sleep 2
tmp_pass=`kubectl -n $CC_NS get secret control-center-user -o go-template="{{ .data.password | base64decode | println }}"`
log "Control Center installed, login to https://$CC_CONTROL with the username $CC_EMAIL and password: $tmp_pass"
test=`computeAbsolutePath`/its/cc-setup.js
echo "$test"
checkPort 443 || return 1
runPlaywrightTests "$test" "" "prod" "control-center" --url=https://$CC_CONTROL --email=$CC_EMAIL
deleteCluster
;;
Expand Down

0 comments on commit 7642dbd

Please sign in to comment.