Skip to content

Commit f3d882a

Browse files
committed
rename vars and check port 443
1 parent af42337 commit f3d882a

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

scripts/pit/its/test-utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ async function createPage(headless, ignoreHTTPSErrors) {
6565
const browser = await chromium.launch({
6666
headless: headless,
6767
chromiumSandbox: false,
68+
slowMo: 500,
6869
args: ['--window-position=0,0']
6970
});
7071
const context = await browser.newContext({ignoreHTTPSErrors: ignoreHTTPSErrors, viewport: { width: 1792, height: 970 } });

scripts/pit/lib/lib-ccenter.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ CC_TLS_K=cc-control-login-tls
1414
## Ingress names
1515
CC_ING_A=control-center
1616
CC_ING_K=control-center-keycloak-ingress
17-
## K8s cluster and namespace
18-
CC_CLUSTER=cc-cluster
17+
# Namespace used for CC
1918
CC_NS=control-center
2019

2120
## UI tests to run after the control-center is installed
@@ -86,6 +85,7 @@ getTLs() {
8685
}
8786

8887
checkTls() {
88+
[ -n "$TEST" ] && return 0
8989
log "Checking TLS certificates for all ingresses hosted in the cluster"
9090
[ -n "$TEST" -o -n "$SKIPHELM" ] && return 0
9191
for i in `kubectl get ingresses -n $CC_NS | grep nginx | awk '{print $1}'`; do
@@ -97,6 +97,7 @@ reloadIngress() {
9797
[ -n "$TEST" ] && return 0
9898
pod=`kubectl -n $CC_NS get pods | grep control-center-ingress-nginx-controller | awk '{print $1}'` || return 1
9999
[ -n "$pod" ] && runCmd "$TEST" "Reloading nginx in $pod" "kubectl exec $pod -n "$CC_NS" -- nginx -s reload" || return 1
100+
[ -z "$TEST" ] && sleep 3
100101
}
101102

102103
## Configure secrets for the control-center and the keycloak servers
@@ -155,12 +156,11 @@ runPwTests() {
155156
if [ "$f" = cc-install-apps.js ]; then
156157
reloadIngress && checkTls || return 1
157158
fi
158-
sleep 3
159159
done
160160
}
161161

162162
setClusterContext() {
163-
[ "$1" = "$CC_CLUSTER" ] && current=kind-$1 || current=$1
163+
[ "$1" = "$KIND_CLUSTER" ] && current=kind-$1 || current=$1
164164
ns=$2
165165
H=`kubectl config get-contexts | tr '*' ' ' | awk '{print $1}' | egrep "^$current$"`
166166
[ -z "$H" ] && log "Cluster $current not found in kubectl contexts" && return 1
@@ -173,13 +173,13 @@ setClusterContext() {
173173

174174
## Main method for running control center
175175
runControlCenter() {
176-
CLUSTER=${CLUSTER:-$CC_CLUSTER}
176+
CLUSTER=${CLUSTER:-$KIND_CLUSTER}
177177

178178
checkCommands docker kubectl helm unzip || return 1
179179
checkDockerRunning || return 1
180180

181181
## Start a new kind cluster if needed
182-
[ "$CLUSTER" != "$CC_CLUSTER" ] || createKindCluster $CC_CLUSTER $CC_NS || return 1
182+
[ "$CLUSTER" != "$KIND_CLUSTER" ] || createKindCluster $CLUSTER $CC_NS || return 1
183183

184184
## Set the context to the cluster
185185
setClusterContext "$CLUSTER" "$CC_NS" || return 1
@@ -199,15 +199,17 @@ runControlCenter() {
199199
installTls && checkTls || return 1
200200

201201
## Forward the ingress (it needs root access since it uses port 443)
202-
# checkBusyPort "443"
203-
checkPort 443 || forwardIngress $CC_NS || return 1
202+
# checkPort "443"
203+
[ "$CLUSTER" != "$KIND_CLUSTER" ] || forwardIngress $CC_NS || return 1
204204

205205
## Run Playwright tests for the control-center
206206
runPwTests || return 1
207-
if [ -z "$TEST" -a -z "$KEEPCC" ]; then
208-
stopForwardIngress || return 1
209-
[ "$CLUSTER" != "$CC_CLUSTER" ] || deleteKindCluster $CC_CLUSTER || return 1
210-
fi
207+
stopForwardIngress || return 1
208+
209+
## Delete the KinD cluster if it was created in this test
210+
[ -n "$TEST" -o -n "$KEEPCC" -o "$CLUSTER" != "$KIND_CLUSTER" ] || deleteKindCluster "$CLUSTER" || return 1
211+
[ -n "$TEST" -o -n "$KEEPCC" -o "$CLUSTER" = "$KIND_CLUSTER" ] || uninstallCC || return 1
212+
211213
return 0
212214
}
213215

scripts/pit/lib/lib-k8s-kind.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
. `dirname $0`/lib/lib-utils.sh
22

3+
## Kind cluster to use if not provided
4+
KIND_CLUSTER=cc-cluster
5+
36
## Check that the command has SUID bit set
47
# $1: command
58
hasSUID() {
@@ -37,6 +40,7 @@ setSuid() {
3740
# $3: port in guest
3841
# $4: target port in host
3942
startPortForward() {
43+
checkPort "$4" && err "Port $4 is already in use" && return 1
4044
H=`getPids "kubectl port-forward $2"`
4145
[ -n "$H" ] && log "Already running k8s port-forward $1 $2 $3 -> $4 with pid $H" && return 0
4246
[ -z "$TEST" ] && log "Starting k8s port-forward $1 $2 $3 -> $4"
@@ -45,7 +49,8 @@ startPortForward() {
4549
rm -f "$bgf"
4650
runInBackgroundToFile "$K port-forward $2 $4:$3 -n $1" "$bgf"
4751
sleep 2
48-
egrep 'Forwarding from' "$bgf"
52+
tail "$bgf"
53+
egrep -q 'Forwarding from' "$bgf"
4954
}
5055

5156
##

0 commit comments

Comments
 (0)