@@ -40,38 +40,30 @@ if [ -z $COMPLETITIONS_COUNT ]; then
40
40
export COMPLETITIONS_COUNT=3
41
41
fi
42
42
43
- # Checkout to user devspaces namespace
44
- export userName=$( kubectl config view --minify -o jsonpath=' {.users[0].name}' | sed ' s|/.*||' )
45
- kubectl config set-context --current --namespace=$userName -devspaces
46
-
47
43
# Delete all dw and dwt objects from test namespace
48
44
cleanup
49
45
50
46
# Delete logs
51
- rm dw* || true
47
+ rm dw* || true > /dev/null
52
48
53
- # Get Openshift DevSpaces url and path to sample devfile yaml from devfile-registry
54
- export devworkspaceUrl=$( kubectl config view --minify -o jsonpath=' {.clusters[0].cluster.server}' | sed ' s/:6443//' | sed ' s/api/devspaces.apps/' )
55
- export testDevfilePath=" devfile-registry/devfiles/TP__cpp__c-plus-plus/devworkspace-che-code-latest.yaml"
56
49
57
- echo " Download the devfile"
58
- curl --insecure " $devworkspaceUrl /$testDevfilePath " -o devfile.yaml
50
+ for (( i= 1 ; i<= $COMPLETITIONS_COUNT ; i++ )) ; do
51
+ cat devfile.yaml | sed " 0,/name: code-latest/s//name: dw$i /" | kubectl apply -f - &
52
+ done
59
53
60
- echo " Start workspaces from sample devfile"
61
- csplit devfile.yaml /---/
62
- mv xx00 dwt.yaml
63
- mv xx01 dw.yaml
64
- kubectl apply -f dwt.yaml
54
+ wait
65
55
66
56
for (( i= 1 ; i<= $COMPLETITIONS_COUNT ; i++ )) ; do
67
- cat dw.yaml | sed " 0,/name: cpp/s//name: dw$i / " | kubectl apply -f -
57
+ kubectl wait --for=condition=Ready " dw/ dw$i " --timeout=180s || true &
68
58
done
69
59
60
+ wait
61
+
70
62
total_time=0
71
63
succeeded=0
72
64
echo " Wait for all workspaces are started and calculate average workspaces starting time"
73
65
for (( i= 1 ; i<= $COMPLETITIONS_COUNT ; i++ )) ; do
74
- if kubectl wait --for=condition=Ready " dw/dw $i " --timeout=120s ; then
66
+ if [ " $( kubectl get dw dw $i --template= ' {{.status.phase}} ' ) " == " Running " ] ; then
75
67
start_time=$( kubectl get dw dw$i --template=' {{range .status.conditions}}{{if eq .type "Started"}}{{.lastTransitionTime}}{{end}}{{end}}' )
76
68
end_time=$( kubectl get dw dw$i --template=' {{range .status.conditions}}{{if eq .type "Ready"}}{{.lastTransitionTime}}{{end}}{{end}}' )
77
69
start_timestamp=$( date -d $start_time +%s)
@@ -84,13 +76,14 @@ for ((i=1; i<=$COMPLETITIONS_COUNT; i++)); do
84
76
else
85
77
print_error " Timeout waiting for dw$i to become ready or an error occurred."
86
78
kubectl describe dw dw$i > dw$i -log.log
87
- kubectl logs $( oc get dw dw$i --template=' {{.status.devworkspaceId}}' ) > dw$i -pod.log || true
88
- fi
79
+ kubectl logs $( kubectl get dw dw$i --template=' {{.status.devworkspaceId}}' ) > dw$i -pod.log || true
80
+ fi
89
81
done
90
82
83
+ wait
84
+
91
85
print " ==================== Test results ===================="
92
86
print " Average workspace starting time for $succeeded workspaces from $COMPLETITIONS_COUNT started: $(( total_time / succeeded)) seconds"
93
87
print " $(( COMPLETITIONS_COUNT - succeeded)) workspaces failed. See failed workspace pod logs in the current folder for details."
94
88
95
89
trap cleanup ERR EXIT
96
-
0 commit comments