Skip to content

Commit ea6fb55

Browse files
committed
test : create large ca-bundle configmap in che installation namespace before running load tests
Signed-off-by: Rohan Kumar <rohaan@redhat.com>
1 parent 0ef22dc commit ea6fb55

File tree

3 files changed

+250
-2
lines changed

3 files changed

+250
-2
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# -------------------------------------------------------------------
5+
# Configuration
6+
# -------------------------------------------------------------------
7+
CHE_NAMESPACE="eclipse-che"
8+
DW_NAMESPACE="kubeadmin-che"
9+
DW_NAME="code-latest"
10+
11+
CERT_COUNT=500
12+
BUNDLE_FILE="custom-ca-certificates.pem"
13+
14+
# -------------------------------------------------------------------
15+
# Logging helpers
16+
# -------------------------------------------------------------------
17+
log_info() { echo -e "ℹ️ $*"; }
18+
log_success() { echo -e "$*"; }
19+
log_error() { echo -e "$*" >&2; }
20+
21+
# -------------------------------------------------------------------
22+
# Preconditions
23+
# -------------------------------------------------------------------
24+
log_info "Checking namespaces..."
25+
kubectl get ns "${CHE_NAMESPACE}" >/dev/null
26+
kubectl get ns "${DW_NAMESPACE}" >/dev/null
27+
28+
# -------------------------------------------------------------------
29+
# Generate dummy certificates (~1MB bundle)
30+
# -------------------------------------------------------------------
31+
log_info "Generating ${CERT_COUNT} dummy CA certificates..."
32+
rm -f "${BUNDLE_FILE}"
33+
34+
for i in $(seq 1 "${CERT_COUNT}"); do
35+
openssl req -x509 -newkey rsa:2048 -nodes -days 1 \
36+
-subj "/CN=dummy-ca-${i}" \
37+
-keyout "dummy-ca-${i}.key" \
38+
-out "dummy-ca-${i}.pem" \
39+
>/dev/null 2>&1
40+
41+
cat "dummy-ca-${i}.pem" >> "${BUNDLE_FILE}"
42+
done
43+
44+
BUNDLE_SIZE=$(stat -c%s "${BUNDLE_FILE}")
45+
log_success "Created CA bundle: $(du -h ${BUNDLE_FILE} | cut -f1)"
46+
47+
# -------------------------------------------------------------------
48+
# Create / update Che CA bundle ConfigMap
49+
# -------------------------------------------------------------------
50+
log_info "Creating Che CA bundle ConfigMap..."
51+
52+
kubectl create configmap custom-ca-certificates \
53+
--from-file=custom-ca-certificates.pem="${BUNDLE_FILE}" \
54+
-n "${CHE_NAMESPACE}" \
55+
--dry-run=client -o yaml \
56+
| kubectl apply --server-side -f -
57+
58+
59+
kubectl label configmap custom-ca-certificates \
60+
app.kubernetes.io/component=ca-bundle \
61+
app.kubernetes.io/part-of=che.eclipse.org \
62+
-n "${CHE_NAMESPACE}" \
63+
--overwrite
64+
65+
# -------------------------------------------------------------------
66+
# Configure CheCluster (disable /etc/pki mount)
67+
# -------------------------------------------------------------------
68+
log_info "Configuring CheCluster..."
69+
70+
CHECLUSTER_NAME=$(kubectl get checluster -n "${CHE_NAMESPACE}" -o jsonpath='{.items[0].metadata.name}')
71+
72+
kubectl patch checluster "${CHECLUSTER_NAME}" \
73+
-n "${CHE_NAMESPACE}" \
74+
--type=merge \
75+
-p '{
76+
"spec": {
77+
"devEnvironments": {
78+
"trustedCerts": {
79+
"disableWorkspaceCaBundleMount": true
80+
}
81+
}
82+
}
83+
}'
84+
85+
# -------------------------------------------------------------------
86+
# Restart Che to apply configuration
87+
# -------------------------------------------------------------------
88+
log_info "Restarting Che..."
89+
kubectl rollout status deploy/che -n "${CHE_NAMESPACE}" --timeout=5m
90+
kubectl wait pod -n "${CHE_NAMESPACE}" -l app=che --for=condition=Ready --timeout=5m
91+
92+
log_success "Che restarted with updated CA settings"
93+
94+
# -------------------------------------------------------------------
95+
# Create DevWorkspace
96+
# -------------------------------------------------------------------
97+
log_info "Creating DevWorkspace '${DW_NAME}'..."
98+
curl -sL https://gist.githubusercontent.com/rohanKanojia/f755717e3fac6a1f45921c3c2883c6d2/raw/1a256c6f7b9d6dcd8650135ecc492d9f08010a80/che-owned-code-latest.yaml \
99+
| sed "s/name: code-latest/name: ${DW_NAME}/" \
100+
| kubectl apply -n "${DW_NAMESPACE}" -f -
101+
102+
# -------------------------------------------------------------------
103+
# Wait for DevWorkspace
104+
# -------------------------------------------------------------------
105+
log_info "Waiting for DevWorkspace to be Ready..."
106+
kubectl wait devworkspace/"${DW_NAME}" \
107+
-n "${DW_NAMESPACE}" \
108+
--for=condition=Ready \
109+
--timeout=5m
110+
111+
# -------------------------------------------------------------------
112+
# Wait for workspace pod
113+
# -------------------------------------------------------------------
114+
log_info "Waiting for workspace pod..."
115+
kubectl wait pod \
116+
-n "${DW_NAMESPACE}" \
117+
-l controller.devfile.io/devworkspace_name="${DW_NAME}" \
118+
--for=condition=Ready \
119+
--timeout=5m
120+
121+
POD_NAME=$(kubectl get pod \
122+
-n "${DW_NAMESPACE}" \
123+
-l controller.devfile.io/devworkspace_name="${DW_NAME}" \
124+
-o jsonpath='{.items[0].metadata.name}')
125+
126+
log_success "Workspace pod '${POD_NAME}' is Ready"
127+
128+
# -------------------------------------------------------------------
129+
# Verify CA bundle certificate count
130+
# -------------------------------------------------------------------
131+
log_info "Verifying CA bundle certificate count inside workspace..."
132+
133+
CERT_PATH_PUBLIC="/public-certs/tls-ca-bundle.pem"
134+
135+
if ! kubectl exec "${POD_NAME}" -n "${DW_NAMESPACE}" -- test -f "${CERT_PATH_PUBLIC}"; then
136+
log_error "CA bundle not found at ${CERT_PATH_PUBLIC}"
137+
exit 1
138+
fi
139+
140+
MOUNTED_CERT_COUNT=$(kubectl exec "${POD_NAME}" -n "${DW_NAMESPACE}" -- \
141+
sh -c "grep -c 'BEGIN CERTIFICATE' ${CERT_PATH_PUBLIC}")
142+
143+
log_info "Generated certificates : ${CERT_COUNT}"
144+
log_info "Mounted certificates : ${MOUNTED_CERT_COUNT}"
145+
146+
if [ "${MOUNTED_CERT_COUNT}" -gt "${CERT_COUNT}" ]; then
147+
log_success "Mounted certificate count is greater than generated count ✅"
148+
else
149+
log_error "Mounted certificate count is NOT greater than generated count ❌"
150+
exit 1
151+
fi
152+
153+
154+
# -------------------------------------------------------------------
155+
# Debug: mounted volumes
156+
# -------------------------------------------------------------------
157+
log_info "Mounted volumes:"
158+
kubectl get pod "${POD_NAME}" \
159+
-n "${DW_NAMESPACE}" \
160+
-o jsonpath='{.spec.volumes[*].name}'
161+
162+
# -------------------------------------------------------------------
163+
# Done
164+
# -------------------------------------------------------------------
165+
kubectl delete dw ${DW_NAME} ${DW_NAMESPACE}
166+
rm *.pem
167+
rm *.key
168+
log_success "END-TO-END verification complete (1MB CA bundle) 🎉"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
provision_che_workspace_namespace() {
2+
local LOAD_TEST_NAMESPACE="$1"
3+
4+
########################################
5+
# Config (override via env if needed)
6+
########################################
7+
local CHE_NAMESPACE="${CHE_NAMESPACE:-che}"
8+
local CHE_CLUSTER_NAME="${CHE_CLUSTER_NAME:-che}"
9+
10+
########################################
11+
# Validation
12+
########################################
13+
if [[ -z "${LOAD_TEST_NAMESPACE}" ]]; then
14+
echo "ERROR: LOAD_TEST_NAMESPACE argument is required"
15+
echo "Usage: provision_che_workspace_namespace <namespace>"
16+
return 1
17+
fi
18+
19+
if ! command -v oc >/dev/null 2>&1; then
20+
echo "ERROR: oc CLI not found"
21+
return 1
22+
fi
23+
24+
########################################
25+
# Get OpenShift username
26+
########################################
27+
local USERNAME
28+
USERNAME="$(oc whoami)"
29+
30+
echo "Provisioning Che workspace namespace"
31+
echo " User : ${USERNAME}"
32+
echo " Namespace : ${LOAD_TEST_NAMESPACE}"
33+
34+
########################################
35+
# Disable auto-provisioning (idempotent)
36+
########################################
37+
oc patch checluster "${CHE_CLUSTER_NAME}" \
38+
-n "${CHE_NAMESPACE}" \
39+
--type=merge \
40+
-p '{
41+
"spec": {
42+
"devEnvironments": {
43+
"defaultNamespace": {
44+
"autoProvision": false
45+
}
46+
}
47+
}
48+
}' >/dev/null
49+
50+
########################################
51+
# Create namespace with labels/annotations
52+
########################################
53+
cat <<EOF | oc apply -f -
54+
apiVersion: v1
55+
kind: Namespace
56+
metadata:
57+
name: ${LOAD_TEST_NAMESPACE}
58+
labels:
59+
app.kubernetes.io/part-of: che.eclipse.org
60+
app.kubernetes.io/component: workspaces-namespace
61+
annotations:
62+
che.eclipse.org/username: ${USERNAME}
63+
EOF
64+
65+
########################################
66+
# Verification (best-effort)
67+
########################################
68+
oc get namespace "${LOAD_TEST_NAMESPACE}" >/dev/null
69+
70+
echo "✔ Namespace '${LOAD_TEST_NAMESPACE}' provisioned for user '${USERNAME}'"
71+
}

test/load/runk6.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

3-
#!/bin/bash
3+
source ./provision_che_workspace_namespace.sh
4+
45

56
MODE="binary" # or 'operator'
67
LOAD_TEST_NAMESPACE="loadtest-devworkspaces"
@@ -19,6 +20,7 @@ SEPARATE_NAMESPACES="false"
1920
DELETE_DEVWORKSPACE_AFTER_READY="true"
2021
MAX_DEVWORKSPACES="-1"
2122
CREATE_AUTOMOUNT_RESOURCES="false"
23+
RUN_WITH_ECLIPSE_CHE="false"
2224
LOGS_DIR="logs"
2325
TEST_DURATION_IN_MINUTES="25"
2426
MIN_KUBECTL_VERSION="1.24.0"
@@ -29,7 +31,12 @@ MIN_K6_VERSION="1.1.0"
2931
main() {
3032
parse_arguments "$@"
3133
check_prerequisites
32-
create_namespace
34+
if [[ "$RUN_WITH_ECLIPSE_CHE" == "false" ]]; then
35+
create_namespace
36+
else
37+
provision_che_workspace_namespace "$LOAD_TEST_NAMESPACE"
38+
source ./provision-che-large-cert-bundle.sh
39+
fi
3340
create_rbac
3441
start_background_watchers
3542

@@ -97,6 +104,8 @@ parse_arguments() {
97104
LOGS_DIR="$2"; shift 2;;
98105
--test-duration-minutes)
99106
TEST_DURATION_IN_MINUTES="$2"; shift 2;;
107+
--run-with-eclipse-che)
108+
RUN_WITH_ECLIPSE_CHE="$2"; shift 2;;
100109
-h|--help)
101110
print_help; exit 0;;
102111
*)

0 commit comments

Comments
 (0)