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 02c5199
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ jobs:
uses: helm/kind-action@v1
with:
install_only: false
- name: Instal Kind and Control Center
# - 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 }}
CC_CERT: ${{ secrets.CC_CERT }}
Expand Down
42 changes: 21 additions & 21 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,19 +39,27 @@ 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
f=/tmp/kubectl-port-forward.logs
touch $f
chmod 777 $f

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"
else
kubectl port-forward $2 $port:$3 -n $1 > /tmp/kubectl-port-forward.logs 2>&1 &
fi
sudo KUBECONFIG="$HOME/.kube/config" kubectl port-forward $2 $4:$3 -n $1 &

# if checkCommands socat; then
# log "Starting socat port-forward $1 $2 $3 -> 4$3"
# kubectl port-forward $2 4$3:$3 -n $1 &
# log "Starting socat port-forward 4$3 -> $3"
# sudo socat tcp-listen:$3,fork,reuseaddr tcp:localhost:4$3 &
# else
# log "Starting socat port-forward $1 $2 $3 -> $4"
# kubectl port-forward $2 $4:$3 -n $1 &
# fi
# set +x
}

stopPortForward() {
Expand Down Expand Up @@ -182,18 +181,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 02c5199

Please sign in to comment.