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

Local dev / documentation improvement #1441

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ test: generate fmt vet manifests ## Run unit tests
manager: generate fmt vet ## Build operator binary
go build -o bin/manager ./cmd/manager/main.go

run: install install-rbac ## Run the operator against the configured Kubernetes cluster in ~/.kube/config
run: install ## Run the operator against the configured Kubernetes cluster in ~/.kube/config
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make e2e - already installs rbac. So installing it here creates resource conflict error.

eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \
go run ./cmd/manager/main.go

Expand Down Expand Up @@ -116,6 +116,7 @@ manifests: controller-gen ## Generate manifests e.g. CRD, RBAC etc.
# Run e2e tests locally using go build while also setting up a proxy in the shell to allow
# the test to run as if it were inside the cluster. This enables mongodb connectivity while running locally.
e2e-telepresence: cleanup-e2e install ## Run e2e tests locally using go build while also setting up a proxy e.g. make e2e-telepresence test=replica_set cleanup=true
export MDB_LOCAL_OPERATOR=true; \
Copy link
Collaborator

Choose a reason for hiding this comment

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

exporting this means we are expecting folks to run the test locally (go test) and that the operator runs locally as well. Maybe we should make a new target for this? Or maybe a comment is enough 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think leaving a comment should be fine. Since the target uses telpresence - I belive we are fairly sure that the operator is running locally. wdyt?

telepresence connect; \
eval $$(scripts/dev/get_e2e_env_vars.py $(cleanup)); \
go test -v -timeout=30m -failfast $(options) ./test/e2e/$(test) ; \
Expand All @@ -139,7 +140,8 @@ cleanup-e2e: ## Cleans up e2e test env
kubectl delete pv --all -n $(NAMESPACE) || true

generate-env-file: ## generates a local-test.env for local testing
python scripts/dev/get_e2e_env_vars.py | cut -d' ' -f2 > .community-operator-dev/local-test.env
mkdir -p .community-operator-dev
{ python scripts/dev/get_e2e_env_vars.py | tee >(cut -d' ' -f2 > .community-operator-dev/local-test.env) ;} > .community-operator-dev/local-test.export.env

##@ Image

Expand Down
5 changes: 3 additions & 2 deletions docs/run-operator-locally.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quick start for building and running the operator locally

This document contains a quickstart guide to build and running (+debugging) the operator locally.
This document contains a quickstart guide to build and running and debugging the operator locally.
Being able to run and build the binary locally can help with faster feedback-cycles.

## Prerequisites
Expand All @@ -12,6 +12,7 @@ Being able to run and build the binary locally can help with faster feedback-cyc
- `KUBECONFIG` environment variable pointing at a file
- **Note**: either of these are necessary to be able to run the operator locally
- Have a folder `.community-operator-dev`
- *Optional - if you want to export the environment variables, you can run the following command*: `source .community-operator-dev/local-test.export.env`
irajdeep marked this conversation as resolved.
Show resolved Hide resolved
## Goals
- Run the operator locally as a binary (optionally in debug mode) in command line or in an IDE
- Run e2e tests locally
Expand All @@ -20,7 +21,7 @@ Being able to run and build the binary locally can help with faster feedback-cyc
1. Use the dedicated make target which exports the needed environment variables and builds & runs the operator binary

```sh
make run
make run
```

2. For debugging one can use the following make target, which uses [dlv](https://github.com/go-delve/delve):
Expand Down
Loading