Skip to content

Commit 23f5c3c

Browse files
committed
add application testing for kots install
1 parent b464cf1 commit 23f5c3c

File tree

1 file changed

+93
-10
lines changed

1 file changed

+93
-10
lines changed

.github/workflows/mlflow-ci.yml

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,14 @@ jobs:
317317
echo "No custom values file provided. Using default values."
318318
fi
319319
320-
# Create namespace if it doesn't exist
321-
KUBECONFIG="$KUBECONFIG_FILE" kubectl create namespace values-test 2>/dev/null || true
320+
# Install into default namespace for consistency with KOTS install
321+
echo "Using namespace: default"
322322
323323
# Install infra chart from Replicated registry
324324
echo "Installing infra chart from Replicated registry..."
325325
echo "Chart path: $OCI_URL/infra"
326326
KUBECONFIG="$KUBECONFIG_FILE" helm upgrade --install infra $OCI_URL/infra \
327-
--namespace values-test \
327+
--namespace default \
328328
--wait --timeout 5m --debug || {
329329
echo "ERROR: Failed to install infra chart from $OCI_URL/infra"
330330
echo "Please check that registry login was successful and the chart exists in the registry."
@@ -336,7 +336,7 @@ jobs:
336336
echo "Chart path: $OCI_URL/mlflow"
337337
echo "Using values args: $MLFLOW_VALUES_ARGS"
338338
KUBECONFIG="$KUBECONFIG_FILE" helm upgrade --install mlflow $OCI_URL/mlflow \
339-
--namespace values-test \
339+
--namespace default \
340340
$MLFLOW_VALUES_ARGS \
341341
--wait --timeout 5m --debug || {
342342
echo "ERROR: Failed to install mlflow chart from $OCI_URL/mlflow"
@@ -370,21 +370,21 @@ jobs:
370370
# The Helm installation with --wait should already ensure services are ready
371371
# But let's verify the services are present
372372
echo "Verifying MLflow service exists..."
373-
KUBECONFIG="$KUBECONFIG_FILE" kubectl get svc -n values-test
373+
KUBECONFIG="$KUBECONFIG_FILE" kubectl get svc -n default
374374
375375
# Check pod status and wait for them to be running
376376
echo "Checking pod status..."
377-
KUBECONFIG="$KUBECONFIG_FILE" kubectl get pods -n values-test
377+
KUBECONFIG="$KUBECONFIG_FILE" kubectl get pods -n default
378378
379379
echo "Waiting for MLflow pods to be running..."
380-
KUBECONFIG="$KUBECONFIG_FILE" kubectl wait --for=condition=Ready pods --selector=app.kubernetes.io/name=mlflow -n values-test --timeout=2m || {
380+
KUBECONFIG="$KUBECONFIG_FILE" kubectl wait --for=condition=Ready pods --selector=app.kubernetes.io/name=mlflow -n default --timeout=2m || {
381381
echo "WARNING: Timed out waiting for pods to be ready, will try port-forwarding anyway"
382-
KUBECONFIG="$KUBECONFIG_FILE" kubectl describe pods -n values-test
382+
KUBECONFIG="$KUBECONFIG_FILE" kubectl describe pods -n default
383383
}
384384
385385
# Set up port forwarding in the background
386386
echo "Setting up port forwarding to run in the background"
387-
nohup bash -c "KUBECONFIG='$KUBECONFIG_FILE' kubectl port-forward -n values-test svc/mlflow $PORT:5000 &>/tmp/port-forward-${{ github.run_id }}.log" &
387+
nohup bash -c "KUBECONFIG='$KUBECONFIG_FILE' kubectl port-forward -n default svc/mlflow $PORT:5000 &>/tmp/port-forward-${{ github.run_id }}.log" &
388388
PORT_FORWARD_PID=$!
389389
echo "port_forward_pid=$PORT_FORWARD_PID" >> $GITHUB_OUTPUT
390390
echo "Set up port forwarding with PID: $PORT_FORWARD_PID"
@@ -409,7 +409,7 @@ jobs:
409409
410410
# If port-forward failed, check pod logs
411411
echo "Pod logs:"
412-
KUBECONFIG="$KUBECONFIG_FILE" kubectl logs -n values-test -l app.kubernetes.io/name=mlflow --tail=20 || true
412+
KUBECONFIG="$KUBECONFIG_FILE" kubectl logs -n default -l app.kubernetes.io/name=mlflow --tail=20 || true
413413
fi
414414
env:
415415
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
@@ -542,6 +542,89 @@ jobs:
542542
wait-duration: 10m
543543
shared-password: 'replicatedmlflow'
544544

545+
# Set up port forwarding after KOTS installation is complete
546+
- name: Set up port forwarding
547+
id: port-forward
548+
run: |
549+
# Use kubeconfig file
550+
KUBECONFIG_FILE="/tmp/kubeconfig-kots-test-${{ github.run_id }}"
551+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
552+
echo "Saved kubeconfig to $KUBECONFIG_FILE"
553+
554+
# Hardcoded port 5000 for simplicity
555+
PORT="5000"
556+
echo "Using port: $PORT for testing"
557+
558+
# Verify services are present
559+
echo "Verifying MLflow service exists..."
560+
KUBECONFIG="$KUBECONFIG_FILE" kubectl get svc -n default
561+
562+
# Check pod status and wait for them to be running
563+
echo "Checking pod status..."
564+
KUBECONFIG="$KUBECONFIG_FILE" kubectl get pods -n default
565+
566+
echo "Waiting for MLflow pods to be running..."
567+
KUBECONFIG="$KUBECONFIG_FILE" kubectl wait --for=condition=Ready pods --selector=app.kubernetes.io/name=mlflow -n default --timeout=2m || {
568+
echo "WARNING: Timed out waiting for pods to be ready, will try port-forwarding anyway"
569+
KUBECONFIG="$KUBECONFIG_FILE" kubectl describe pods -n default
570+
}
571+
572+
# Set up port forwarding in the background
573+
echo "Setting up port forwarding to run in the background"
574+
nohup bash -c "KUBECONFIG='$KUBECONFIG_FILE' kubectl port-forward -n default svc/mlflow $PORT:5000 &>/tmp/port-forward-kots-${{ github.run_id }}.log" &
575+
PORT_FORWARD_PID=$!
576+
echo "port_forward_pid=$PORT_FORWARD_PID" >> $GITHUB_OUTPUT
577+
echo "Set up port forwarding with PID: $PORT_FORWARD_PID"
578+
579+
# Set hostname for testing
580+
echo "hostname=localhost:$PORT" >> $GITHUB_OUTPUT
581+
echo "Test endpoint will be: localhost:$PORT"
582+
583+
# Give port-forward more time to establish
584+
echo "Waiting for port-forward to establish..."
585+
sleep 15
586+
587+
# Basic connectivity check
588+
echo "Checking connectivity to MLflow..."
589+
if curl -s -o /dev/null -w "%{http_code}" http://localhost:$PORT/; then
590+
echo "Successfully connected to MLflow service!"
591+
else
592+
echo "Warning: Initial connection attempt failed, service may still be starting"
593+
# Show the port-forward log for debugging
594+
echo "Port-forward log:"
595+
cat /tmp/port-forward-kots-${{ github.run_id }}.log || true
596+
597+
# If port-forward failed, check pod logs
598+
echo "Pod logs:"
599+
KUBECONFIG="$KUBECONFIG_FILE" kubectl logs -n default -l app.kubernetes.io/name=mlflow --tail=20 || true
600+
fi
601+
env:
602+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
603+
604+
# Application testing with our consolidated test file
605+
- name: Run Application Tests
606+
run: |
607+
cd applications/mlflow
608+
609+
# Use the same kubeconfig file from previous steps
610+
KUBECONFIG_FILE="/tmp/kubeconfig-kots-test-${{ github.run_id }}"
611+
if [ ! -f "$KUBECONFIG_FILE" ]; then
612+
echo "$KUBECONFIG" > "$KUBECONFIG_FILE"
613+
fi
614+
615+
echo "Installing Python dependencies for tests..."
616+
pip install mlflow pandas scikit-learn requests urllib3
617+
618+
echo "Running MLflow application tests against ${{ steps.port-forward.outputs.hostname }}"
619+
echo "This may take some time as it will retry connections for up to 2 minutes"
620+
KUBECONFIG="$KUBECONFIG_FILE" python tests/mlflow_test.py ${{ steps.port-forward.outputs.hostname }} \
621+
--protocol http \
622+
--connection-timeout 180 \
623+
--debug
624+
timeout-minutes: 5
625+
env:
626+
KUBECONFIG: ${{ steps.create-cluster.outputs.cluster-kubeconfig }}
627+
545628
- name: Install troubleshoot
546629
run: curl -L https://github.com/replicatedhq/troubleshoot/releases/latest/download/support-bundle_linux_amd64.tar.gz | tar xzvf -
547630
if: failure()

0 commit comments

Comments
 (0)