Skip to content

Commit

Permalink
adding steps to the action
Browse files Browse the repository at this point in the history
  • Loading branch information
manolo committed Jan 16, 2025
1 parent 69dfa89 commit 32af306
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 95 deletions.
32 changes: 14 additions & 18 deletions .github/workflows/a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,30 @@ jobs:
echo "export PATH='$PATH'" > path.sh
apt-get update
apt-get install -y vim iputils-ping sudo unzip wget jq curl
npm install playwright
./node_modules/.bin/playwright install-deps >/dev/null
./node_modules/.bin/playwright install chromium
# npm install playwright
# ./node_modules/.bin/playwright install-deps >/dev/null
# ./node_modules/.bin/playwright install chromium
- uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
# - uses: browser-actions/setup-chrome@latest
# with:
# chrome-version: stable
- uses: actions/setup-node@v4
with:
node-version: '18'
- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- uses: stCarolas/setup-maven@v5
with:
maven-version: '3.9.0'
# - uses: actions/setup-java@v4
# with:
# java-version: '21'
# distribution: 'temurin'
# - uses: stCarolas/setup-maven@v5
# with:
# maven-version: '3.9.0'
- name: Set up Helm
uses: azure/[email protected]
- name: Create k8s Kind Cluster
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
- name: Run PiT
env:
CC_KEY: ${{ secrets.CC_KEY }}
CC_CERT: ${{ secrets.CC_CERT }}
Expand Down
90 changes: 21 additions & 69 deletions scripts/pit/lib/lib-cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,12 @@ CC_TLS=control-center-tls
CC_CLUSTER=cc-cluster
CC_NS=control-center

getPids() {
H=`grep -a "" /proc/*/cmdline 2>/dev/null | xargs -0 | grep -v grep | perl -pe 's|/proc/(.*?)/cmdline:|$1 |g'`
if [ -n "$H" ]
then
_P=`echo "$H" | grep "$1" | awk '{print $1}'`
else
_P=`ps -feaw | grep "$1" | grep -v grep | awk '{print $2}'`
fi
[ -n "$_P" ] && echo "$_P" && return 0 || return 1
}

startCloudProvider() {
docker container inspect kind-cloud-provider >/dev/null 2>&1 && log "Docker Kind Cloud Provider already running" && return
log "Starting Docker KinD Cloud Provider"
cmd="docker run --name kind-cloud-provider --rm -d --network kind \
-v /var/run/docker.sock:/var/run/docker.sock \
rophy/cloud-provider-kind:0.4.0-20241026-r1"
echo "#" $cmd
eval "$cmd"
runCmd "$TEST" "Starting Docker KinD Cloud Provider" \
"docker run --name kind-cloud-provider --rm -d --network kind \
-v /var/run/docker.sock:/var/run/docker.sock \
rophy/cloud-provider-kind:0.4.0-20241026-r1"
}

stopCloudProvider() {
Expand All @@ -40,17 +27,18 @@ startPortForward() {
[ -z "$3" ] && echo "startPortForward name-space service port" && return 1
H=`getPids "kubectl port-forward $2"`
[ -n "$H" ] && return 0

KUBECTL=`which kubectl`
log "Starting k8s port-forward $1 $2 $3 -> $4"
if isLinux || isMac ; then
sudo KUBECONFIG="$HOME/.kube/config" kubectl port-forward $2 $4:$3 -n $1 &
log "listening to ports <1024 requires sudo, type your password if requested"
sudo true || return 1
sudo KUBECONFIG="$HOME/.kube/config" $KUBECTL port-forward $2 $4:$3 -n $1 &
else
kubectl port-forward $2 $4:$3 -n $1 &
$KUBECTL port-forward $2 $4:$3 -n $1 &
fi
}

stopPortForward() {
set -x
H=`getPids kubectl "port-forward service/$1"`
[ -z "$H" ] && return 0
log "Stoping k8s port-forward $1 (pid $H)"
Expand All @@ -66,22 +54,21 @@ stopForwardIngress() {
}

createCluster() {
log "Creating cluster"
echo "# kind create cluster --name $CC_CLUSTER"
kind create cluster --name $CC_CLUSTER || return 1
kubectl config use-context kind-$CC_CLUSTER
kubectl config set-context --current --namespace=$CC_NS
runCmd "$TEST" "Creating KinD cluster: $CC_CLUSTER" \
"kind create cluster --name $CC_CLUSTER" || return 1
runCmd "$TEST" "Setting default namespace $CC_NS" \
"kubectl config set-context --current --namespace=$CC_NS"
}

deleteCluster() {
log "Deleting cluster"
kind delete cluster --name $CC_CLUSTER
runCmd "$TEST" "Deleting Cluster $CC_CLUSTER" \
"kind delete cluster --name $CC_CLUSTER" || return 1
}

installCC() {
log "Installing Control Center"
[ -n "$DEBUG" ] && D=--debug
cmd="helm install control-center oci://docker.io/vaadin/control-center \
[ -n "$VERBOSE" ] && D=--debug
runCmd "$TEST" "Installing Vaadin Control Center" \
"helm install control-center oci://docker.io/vaadin/control-center \
-n $CC_NS --create-namespace \
--set domain=$CC_DOMAIN \
--set user.email=$CC_EMAIL \
Expand All @@ -91,8 +78,6 @@ installCC() {
--set keycloak.tlsSecret=$CC_TLS \
--set livenessProbe.failureThreshold=10 \
--wait $D"
echo "#" $cmd
eval $cmd || return 1
}

waitForCC() {
Expand All @@ -114,41 +99,6 @@ waitForCC() {
done
}

installDashBoard() {
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard \
--create-namespace --namespace kubernetes-dashboard || return 1

cat << EOF | kubectl create -n kubernetes-dashboard -f - >/dev/null 2>&1
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF
cc_auth=`kubectl -n kubernetes-dashboard create token admin-user`
[ -z "$cc_auth" ] && return 1
startPortForward kubernetes-dashboard service/kubernetes-dashboard-kong-proxy 443 8443
log "Login into dashboard with this token: $cc_auth"
}

uninstallDashBoard() {
stopPortForward kubernetes-dashboard
kubectl delete ns kubernetes-dashboard
}

uninstallCC() {
kubectl delete ns $CC_NS
kubectl delete ns ingress-nginx
Expand All @@ -160,7 +110,8 @@ installTls() {
echo -e "$CC_CERT" > $f1
f2=/tmp/cc-tls.key
echo -e "$CC_KEY" > $f2
kubectl -n $CC_NS create secret tls $CC_TLS --key "$f2" --cert "$f1"
runCmd "$TEST" "Creating TLS secret $CC_TLS" \
"kubectl -n $CC_NS create secret tls $CC_TLS --key '$f2' --cert '$f1'"
rm -f $f1 $f2
}

Expand All @@ -182,6 +133,7 @@ runControlCenter() {
test=`computeAbsolutePath`/its/cc-setup.js
checkPort 443 || return 1
runPlaywrightTests "$test" "" "prod" "control-center" --url=https://$CC_CONTROL --email=$CC_EMAIL
stopForwardIngress
deleteCluster
;;
stop)
Expand Down
2 changes: 2 additions & 0 deletions scripts/pit/lib/lib-playwright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ runPlaywrightTests() {

_pfile="playwright-$_mode-"`uname`".out"
[ -f "$_test_file" ] && checkPlaywrightInstallation "$_test_file" || return 0

set +x
_args="$* --name=$_name --mode=$_mode"
isHeadless && _args="$_args --headless"
PATH=$PATH runToFile "'$NODE' '$_test_file' $_args" "$_pfile" "$VERBOSE" true
Expand Down
16 changes: 8 additions & 8 deletions scripts/pit/lib/lib-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ restoreProKey() {

## get pids for process
getPids() {
if type pgrep >/dev/null 2>&1; then
_P=`pgrep "$1"`
elif type tasklist >/dev/null 2>&1; then
_P=`tasklist | findstr "$1" | awk '{print $2}'`
else
err "No pgrep or tasklist installed" && exit 1
H=`grep -a "" /proc/*/cmdline 2>/dev/null | xargs -0 | grep -v grep | perl -pe 's|/proc/(.*?)/cmdline:|$1 |g'`
if [ -n "$H" ]
then
_P=`echo "$H" | grep "$1" | awk '{print $1}'`
else
_P=`ps -feaw | grep "$1" | grep -v grep | awk '{print $2}'`
fi
[ -n "$_P" ] && echo "$_P" && return 0 || return 1
[ -n "$_P" ] && echo "$_P" | tr "\n" " " && return 0 || return 1
}

## Kills a process with its children and wait until complete
Expand Down Expand Up @@ -95,7 +95,7 @@ warn() {
print '> ' 0 33 "$*"
}
cmd() {
cmd_=`printf "$*" | perl -pe 's|\n|\\\\\\\n|g'`
cmd_=`printf "$*" | tr -s " " | perl -pe 's|\n|\\\\\\\n|g'`
print ' ' 1 34 " $cmd_"
}
dim() {
Expand Down

0 comments on commit 32af306

Please sign in to comment.