Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
name: E2E Test Suite
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
matrix:
include:
- {mode: "live-cluster"}
- {mode: "offline"}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand All @@ -40,7 +45,7 @@ jobs:
sudo apt-get install -y pipx
pipx install jinjanator
pipx ensurepath
echo "$HOME/.local/bin" >> $GITHUB_PATH
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
else
echo "jinjanator already installed"
fi
Expand All @@ -55,13 +60,19 @@ jobs:
run: make build

- name: Deploy KIND
if: matrix.mode == 'live-cluster'
run: make deploy-kind-ovnk

- name: Run E2E tests
run: make run-e2e
run: |
if [ "${{ matrix.mode }}" == "live-cluster" ]; then
make run-e2e MCP_MODE="live-cluster"
else
make run-e2e MCP_MODE="offline"
fi

- name: Export kind logs
if: always()
if: always() && matrix.mode == 'live-cluster'
run: |
set -x
# Only export logs if kind CLI exists and cluster is running
Expand All @@ -73,15 +84,15 @@ jobs:
fi

- name: Upload kind logs
if: always()
if: always() && matrix.mode == 'live-cluster'
uses: actions/upload-artifact@v4
with:
name: kind-logs-e2e-${{ github.run_id }}
name: kind-logs-e2e-${{ matrix.mode }}-${{ github.run_id }}
path: /tmp/kind/logs
if-no-files-found: ignore

- name: Cleanup KIND cluster
if: always()
if: always() && matrix.mode == 'live-cluster'
run: |
set -x
kind delete cluster --name ovn || true
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ undeploy-kind-ovnk:
NVM_VERSION := 0.40.3
NODE_VERSION := 22.20.0
NPM_VERSION := 11.6.1
MCP_MODE ?= live-cluster

.PHONY: run-e2e
run-e2e:
./hack/run-e2e.sh $(NVM_VERSION) $(NODE_VERSION) $(NPM_VERSION)
./hack/run-e2e.sh $(NVM_VERSION) $(NODE_VERSION) $(NPM_VERSION) "$(MCP_MODE)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a default value for MCP_MODE here in the makefile. I think default value should be live-cluster here so that the current behavior doesn't break.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add similar conditional kind deployment for test-e2e make target, like you've done in the e2e.yml file.


.PHONY: test-e2e
test-e2e: build deploy-kind-ovnk
test-e2e: build
if [ "$(MCP_MODE)" = "live-cluster" ]; then $(MAKE) deploy-kind-ovnk || exit 1; fi; \
$(MAKE) run-e2e || EXIT_CODE=$$?; \
$(MAKE) undeploy-kind-ovnk; \
if [ "$(MCP_MODE)" = "live-cluster" ]; then $(MAKE) undeploy-kind-ovnk || exit 1; fi; \
exit $${EXIT_CODE:-0}

.PHONY: lint
Expand Down
15 changes: 14 additions & 1 deletion hack/run-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
NVM_VERSION=$1
NODE_VERSION=$2
NPM_VERSION=$3
MCP_MODE=$4

if [[ -z "${NVM_VERSION}" ]] || [[ -z "${NODE_VERSION}" ]] || [[ -z "${NPM_VERSION}" ]]; then
echo "NVM_VERSION, NODE_VERSION and NPM_VERSION are required"
exit 1
fi

if [[ "${MCP_MODE}" != "offline" && "${MCP_MODE}" != "live-cluster" && -n "${MCP_MODE}" ]]; then
echo "Invalid MCP_MODE: ${MCP_MODE}. Must be 'offline' or 'live-cluster'"
exit 1
fi

install_dependencies() {
# Install ginkgo
go install github.com/onsi/ginkgo/v2/ginkgo@latest
Expand Down Expand Up @@ -40,4 +46,11 @@ echo "Dependencies installed"

# Run e2e tests
echo "Running e2e tests"
ginkgo -vv test/e2e
if [[ "${MCP_MODE}" == "offline" ]]; then
echo "Running offline mode tests (sosreport and must-gather)"
export MCP_MODE="offline"
ginkgo -vv --focus="\[offline\]" test/e2e
else
echo "Running live-cluster mode tests (excluding offline tests)"
ginkgo -vv --skip="\[offline\]" test/e2e
fi
5 changes: 4 additions & 1 deletion pkg/sosreport/mcp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"regexp"

"github.com/ovn-kubernetes/ovn-kubernetes-mcp/pkg/sosreport/types"
)

Expand Down Expand Up @@ -122,7 +123,9 @@ func searchCommands(sosreportPath, pattern string, maxResults int) (types.Search
return types.SearchCommandsResult{}, fmt.Errorf("invalid search pattern: %w", err)
}

var result types.SearchCommandsResult
result := types.SearchCommandsResult{
Matches: []types.CommandMatch{},
}
if maxResults <= 0 {
maxResults = defaultResultLimit
}
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
const (
mcpServerPathEnvVar = "MCP_SERVER_PATH"
kubeconfigEnvVar = "KUBECONFIG"
mcpModeEnvVar = "MCP_MODE"
mcpModeOffline = "offline"
)

var (
Expand Down Expand Up @@ -90,6 +92,19 @@ func TestE2e(t *testing.T) {
var _ = BeforeSuite(func() {
mcpServerPath := os.Getenv(mcpServerPathEnvVar)
Expect(mcpServerPath).NotTo(BeEmpty())

mcpMode := os.Getenv(mcpModeEnvVar)
Expect(mcpMode).NotTo(BeEmpty())
if mcpMode == mcpModeOffline {
// Offline mode - configure MCP inspector without kubeconfig
mcpInspector = inspector.NewMCPInspector().
Command(mcpServerPath).
CommandFlags(map[string]string{
"mode": "offline",
})
return
}

kubeconfig := os.Getenv(kubeconfigEnvVar)
Expect(kubeconfig).NotTo(BeEmpty())

Expand Down
Loading
Loading