@@ -84,26 +84,105 @@ task DRY_RUN=true
8484task bake TARGET=pgvector DRY_RUN=true
8585```
8686
87- ## Testing locally
87+ ## Local testing guide
8888
89- Local testing can be performed by using a local Docker container registry and a Kind cluster with CNPG installed.
90- The Taskfile includes utilities to set up and tear down such an environment.
89+ Testing your extensions locally ensures high-quality PRs and faster iteration
90+ cycles. This environment uses a local Docker container registry and a Kind
91+ cluster with CloudNativePG pre-installed.
9192
92- ### Create a local test environment
93+ > [ !IMPORTANT]
94+ > ** Pre-submission requirement:** You must successfully run local tests before
95+ > submitting a Pull Request for any extension.
9396
94- The ` e2e:setup-env ` task takes care of setting up a Kind cluster with a local Docker container registry connected to the same
95- Docker network and installs CloudNativePG by default.
97+ ### Initialize the environment
98+
99+ The ` e2e:setup-env ` utility automates the heavy lifting. It creates a Kind
100+ cluster, attaches a local Docker registry (available at ` localhost:5000 ` ), and
101+ installs the CloudNativePG operator.
96102
97103``` bash
98104task e2e:setup-env
99105```
100106
101- The container registry will be exposed locally at ` localhost:5000 ` .
107+ ### Get access to the cluster
108+
109+ Even though the cluster is running, your local ` kubectl ` doesn't know how to
110+ talk to it yet. You need to "export" the credentials (the Kubeconfig).
111+
112+ If you want to run ` kubectl get pods ` from your own laptop's terminal, use the
113+ standard export:
114+
115+ ``` bash
116+ task e2e:export-kubeconfig KUBECONFIG_PATH=./kubeconfig
117+ export KUBECONFIG=$PWD /kubeconfig
118+ ```
119+
120+ If you are running a test script that is also running inside a Docker container
121+ on the same network, like in the case of Kind, it needs the "internal" address
122+ to find the API server:
123+
124+ ``` bash
125+ task e2e:export-kubeconfig KUBECONFIG_PATH=./kubeconfig INTERNAL=true
126+ ```
127+
128+ ### Build and push the extension (` bake ` )
129+
130+ Before the cluster can use your extension, you must build the image and push it
131+ to the local registry (see [ "Push images for a specific project" above] ( #6-push-images-for-a-specific-project ) ):
132+
133+ ``` bash
134+ task bake TARGET=" <extension>" PUSH=true
135+ ```
136+
137+ This command tags the image for ` localhost:5000 ` and pushes it automatically.
138+
139+ > [ !TIP]
140+ > You can change the default registry through the ` registry ` environment variable
141+ > (defined in the ` docker/bake.hcl ` file).
142+
143+ ### Prepare testing values
144+
145+ We use [ Chainsaw] ( https://github.com/kyverno/chainsaw ) for declarative
146+ end-to-end testing. Before running tests, you must generate specific
147+ configuration values for your extension image.
148+
149+ Run the following command to export these values into your extension's
150+ directory:
151+
152+ ``` bash
153+ task e2e:generate-values TARGET=" <extension>" EXTENSION_IMAGE=" <my-local-image>"
154+ ```
155+
156+ For example, to generate the values for the local test of the local image, you could run something similar to the following:
157+
158+ ``` bash
159+ # The actual name of the image might be different on your system
160+ task e2e:generate-values TARGET=pgvector EXTENSION_IMAGE=" localhost:5000/pgvector-testing:0.8.1-18-trixie"
161+ ```
162+
163+ ### Execute End-to-End tests
164+
165+ The testing framework requires an internal Kubeconfig to communicate correctly
166+ within the Docker network.
167+
168+ First, export the internal configuration as shown above:
169+
170+ ``` bash
171+ task e2e:export-kubeconfig KUBECONFIG_PATH=./kubeconfig INTERNAL=true
172+ ```
173+
174+ Then, run the ` e2e:test ` task. This executes both the generic tests (located in
175+ the global ` /test ` folder) and any extension-specific tests (located in the
176+ target's ` /test ` folder):
177+
178+ ``` bash
179+ task e2e:test TARGET=" <extension>" KUBECONFIG_PATH=" ./kubeconfig"
180+ ```
102181
103- The Kubeconfig to connect to the Kind cluster can be retrieved with:
182+ You can test the ` pgvector ` extension with:
104183
105184``` bash
106- task e2e:export-kubeconfig KUBECONFIG_PATH=< path-to-export- kubeconfig>
185+ task e2e:test TARGET= " pgvector " KUBECONFIG_PATH=" ./ kubeconfig"
107186```
108187
109188### Tear down the local test environment
0 commit comments