Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Check cluster is running for non-standalone Make targets #437

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bentito
Copy link
Contributor

@bentito bentito commented Oct 18, 2024

We have several non-standlone Make targets

  • test-e2e
  • kind-load
  • install
  • only-deploy-manifest

The above targets rely on Kind to be running.

Unfortunately, currently, errors returned from the Go code are pretty cryptic. Better would be an explicit catch and error when a Kind cluster is not found when these targets are run.

Currently we have:

catalogd checking_kind_running $ make test-e2e
/Users/btofel/go/bin/ginkgo-v2.20.2  -trace -vv  test/e2e
Running Suite: E2E Suite - /Users/btofel/workspace/catalogd/test/e2e
====================================================================
Random Seed: 1729265504

Will run 1 of 1 specs
------------------------------
[BeforeSuite]
/Users/btofel/workspace/catalogd/test/e2e/e2e_suite_test.go:33
  > Enter [BeforeSuite] TOP-LEVEL - /Users/btofel/workspace/catalogd/test/e2e/e2e_suite_test.go:33 @ 10/18/24 11:31:49.369

Ginkgo ran 1 suite in 4.681573708s

Test Suite Failed
make: *** [test-e2e] Error 1

wha?

but it would be better to have:

$ make test-e2e
if ! kubectl config current-context >/dev/null 2>&1; then \
		echo "Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first."; \
		exit 1; \
	fi
Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first.
make: *** [check-cluster] Error 1

@bentito bentito requested a review from a team as a code owner October 18, 2024 14:39
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.11%. Comparing base (d320249) to head (69053f6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #437      +/-   ##
==========================================
- Coverage   38.36%   38.11%   -0.25%     
==========================================
  Files          15       15              
  Lines         941     1191     +250     
==========================================
+ Hits          361      454      +93     
- Misses        530      687     +157     
  Partials       50       50              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated
@@ -102,7 +102,7 @@ FOCUS := $(if $(TEST),-v -focus "$(TEST)")
ifeq ($(origin E2E_FLAGS), undefined)
E2E_FLAGS :=
endif
test-e2e: $(GINKGO) ## Run the e2e tests
test-e2e: check-kind-cluster $(GINKGO) ## Run the e2e tests
Copy link
Member

Choose a reason for hiding this comment

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

This check might be a bit too presumptuous. For example, someone running test-e2e might want to run the tests after running kind create cluster --name=foobar and tilt up.

It may even be that someone wants to run the e2es against a non-kind cluster that already has OLM deployed.

Copy link
Contributor Author

@bentito bentito Oct 18, 2024

Choose a reason for hiding this comment

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

Changed to make it more generic like this:

.PHONY: check-cluster
check-cluster:
	if ! kubectl config current-context >/dev/null 2>&1; then \
		echo "Error: Could not get current Kubernetes context. Use 'run' or 'e2e' targets first."; \
		exit 1; \
	fi

wdyt?

Makefile Outdated Show resolved Hide resolved
bentito and others added 3 commits October 18, 2024 10:57
Co-authored-by: Jordan Keister <[email protected]>
Co-authored-by: Jordan Keister <[email protected]>
@grokspawn grokspawn changed the title 🐛 Check Kind running for non-standalong Make targets 🐛 Check Kind running for non-standalone Make targets Oct 18, 2024
@bentito bentito changed the title 🐛 Check Kind running for non-standalone Make targets 🐛 Check cluster is running for non-standalone Make targets Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants