You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
10. Now start tilt by running the following command in the directory where you cloned Cluster API repo in step 1:
67
+
> NOTE: You can also use your existing kind cluster by using the environment variable `CAPI_KIND_CLUSTER_NAME`.
68
+
10. Export `CLUSTER_TOPOLOGY=true` to enable support for managed topologies and ClusterClass.
69
+
11. Now start tilt by running the following command in the directory where you cloned Cluster API repo in step 1:
69
70
70
71
```bash
71
72
tilt up
@@ -79,8 +80,11 @@ This section explains how to attach debugger to the CAPRKE2 process running in a
79
80
connecting a debugger to this process, you would be able to step through the code through your IDE. This guide
80
81
covers two popular IDEs - IntelliJ GoLand and VS Code.
81
82
82
-
On the Tilt web UI and confirm the port on which `caprke2_controller` is exposed. By default, it should be
83
-
localhost:30001.
83
+
On the Tilt web UI and confirm the port on which `caprke2_controller` is exposed. By default, it should be localhost:30002.
84
+
85
+
If you want to debug CAPRKE2 bootstrap controller, find where `capbpr_controller` is exposed. By default, it should be localhost:30001.
86
+
87
+
To learn about debugging Core CAPI Controller, refer to [the official doc](https://cluster-api.sigs.k8s.io/developer/core/tilt).
84
88
85
89
### GoLand
86
90
@@ -89,6 +93,10 @@ localhost:30001.
89
93
Remote'.
90
94
3. Enter the 'Host' and 'Port' values based on where `caprke2_controller` is exposed.
91
95
96
+
You can setup a similar debugger for the Bootstrap controller.
97
+
98
+
To debug Bootstrap and Control Plane simultaneously, you can add a new configuration as before but select 'Compound' and then select the Go Remote setups for both controllers.
99
+
92
100
### VS Code
93
101
94
102
1. If you don't already have a `launch.json` setup, go to 'Run and Debug' in the Activity Bar and click on 'create a
@@ -111,11 +119,11 @@ localhost:30001.
111
119
]
112
120
}
113
121
```
114
-
122
+
---
115
123
Insert a breakpoint, e.g., in the [`updateStatus`](https://github.com/rancher/cluster-api-provider-rke2/blob/5163e6233301262c5bcfebab58189aa278b1f51e/controlplane/internal/controllers/rke2controlplane_controller.go#L298) method which responsible for updating the status of the `RKE2ControlPlane`
116
124
resource and run the configuration. To check if you can step into the code, create a workload cluster by using the
117
125
example provided in the [documentation](../03_examples/03_docker.md). If things were configured correctly, code
118
-
execution would halt at the breakpoint and you should be able to step through it.
126
+
execution would halt at the breakpoint, and you should be able to step through it.
119
127
120
128
## Troubleshooting
121
129
@@ -125,4 +133,33 @@ run `tilt logs` in a separate terminal without stopping the `tilt up` command th
125
133
### Common Issues
126
134
127
135
1. Make sure you run the `kind` and `tilt` commands mentioned above from correct directory.
128
-
2. A `go mod vendor` might be required in your clone of CAPI repo. `tilt logs` should make this obvious.
136
+
2. A `go mod vendor` might be required in your clone of CAPI repo. `tilt logs` should make this obvious.
137
+
138
+
# Unit Testing
139
+
Unit tests use envtest, and to ensure you can run them locally, you need to install the envtest binary.
140
+
141
+
```shell
142
+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
143
+
KUBEBUILDER_ASSETS=$(setup-envtest use -p path <k8s-version>)
144
+
```
145
+
146
+
Set the envvar `KUBEBUILDER_ASSETS` and its value in your code editor's test configuration.
147
+
148
+
# E2E Testing
149
+
To run or debug a test from your code editor, you would need to setup the configuration with some environment variables and arguments.
150
+
To run an e2e test, we use `make e2e-test` in the CI, we will replicate the same settings in our code editor configuration.
151
+
152
+
## Goland
153
+
Create a Run/Debug configuration with the following settings:
0 commit comments