Skip to content

Commit b8e226f

Browse files
committed
feat: improve e2e testing tooling and documentation
Major improvements to the end-to-end testing infrastructure: Testing Infrastructure: - Add automatic payment method ID fetching from RedisCloud API - Create templated test examples with dynamic payment method injection - Add cluster/test/setup.sh script for comprehensive test environment setup - Add datasource.yaml for dynamic value injection in tests - Support environment variable configuration via .envrc Documentation Updates: - Restructure TESTING.md with clear quick-start instructions - Add comprehensive payment method configuration section - Document environment variable setup with .envrc.example - Update CI-TESTING.md to reflect current CI/CD workflows - Clean up references to removed scripts in all docs Cleanup: - Remove obsolete scripts (quick-start.sh, setup-podman.sh, test-provider.sh) - Consolidate functionality into Makefile targets - Add proper .gitignore entries for test artifacts - Remove untracked files (provider-aws/, kubeconfig, etc.) Developer Experience: - Add devenv.nix configuration for development environment - Add rediscloud-payment-methods and rediscloud-first-payment-method-id make targets - Improve error handling and user feedback in setup scripts - Simplify credential management with environment variables This refactoring makes the e2e testing process more robust and user-friendly, particularly for testing Pro subscription features that require payment methods.
1 parent 6128cb7 commit b8e226f

File tree

20 files changed

+568
-568
lines changed

20 files changed

+568
-568
lines changed

.claude/settings.local.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

.envrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
source_env_if_exists .envrc.local
2+
13
export DIRENV_WARN_TIMEOUT=20s
24

35
if has devenv; then
@@ -7,16 +9,14 @@ fi
79

810
# RedisCloud API Credentials
911
# Get these from: RedisCloud Console → Account Settings → API Keys
10-
export REDISCLOUD_API_KEY="your-api-key-here"
11-
export REDISCLOUD_SECRET_KEY="your-secret-key-here"
12+
#export REDISCLOUD_API_KEY="YOUR_API_KEY_HERE"
13+
#export REDISCLOUD_SECRET_KEY="YOUR_SECRET_KEY_HERE"
1214
export REDISCLOUD_URL="https://api.redislabs.com/v1"
1315

1416
# Kubernetes/Crossplane Configuration
1517
export CROSSPLANE_NAMESPACE="crossplane-system"
1618
export PROVIDER_NAMESPACE="crossplane-system"
1719

1820
# Development Settings
19-
export DOCKER_HOST="unix:///run/user/$(id -u)/podman/podman.sock"
2021
export KIND_CLUSTER_NAME="rediscloud-test"
21-
export KIND_EXPERIMENTAL_PROVIDER=podman │ │
2222
export KUBECONFIG_PATH="${PWD}/.kube/config"

.envrc.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# RedisCloud API Credentials
2+
# Get these from: RedisCloud Console → Account Settings → API Keys
3+
export REDISCLOUD_API_KEY="YOUR_API_KEY_HERE"
4+
export REDISCLOUD_SECRET_KEY="YOUR_SECRET_KEY_HERE"
5+
export REDISCLOUD_URL="https://api.redislabs.com/v1"
6+
7+
# Optional: Set a specific payment method ID (otherwise will fetch the first one)
8+
# export REDISCLOUD_PAYMENT_METHOD_ID="12345"
9+
10+
# Kubernetes/Crossplane Configuration
11+
export CROSSPLANE_NAMESPACE="crossplane-system"
12+
export PROVIDER_NAMESPACE="crossplane-system"
13+
14+
# Development Settings
15+
export KIND_CLUSTER_NAME="rediscloud-test"
16+
export KUBECONFIG_PATH="${PWD}/.kube/config"
17+
18+
# For 1Password users, you can override in .envrc.local:
19+
# export REDISCLOUD_API_KEY="op://Private/Redis Cloud/api-tokens/api-account-key"
20+
# export REDISCLOUD_SECRET_KEY="op://Private/Redis Cloud/api-tokens/api-user-key"

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,62 @@ jobs:
290290
run: |
291291
./scripts/check-examples.py package/crds examples
292292
293+
e2e-tests:
294+
runs-on: ubuntu-24.04
295+
needs: detect-noop
296+
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
297+
298+
steps:
299+
- name: Setup QEMU
300+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3
301+
with:
302+
platforms: all
303+
304+
- name: Setup Docker Buildx
305+
uses: docker/setup-buildx-action@v3
306+
with:
307+
version: ${{ env.DOCKER_BUILDX_VERSION }}
308+
install: true
309+
310+
- name: Checkout
311+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
312+
with:
313+
submodules: true
314+
315+
- name: Setup Go
316+
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
317+
with:
318+
go-version: ${{ env.GO_VERSION }}
319+
320+
- name: Find the Go Build Cache
321+
id: go
322+
run: echo "cache=$(make go.cachedir)" >> $GITHUB_OUTPUT
323+
324+
- name: Cache the Go Build Cache
325+
uses: actions/cache@v4
326+
with:
327+
path: ${{ steps.go.outputs.cache }}
328+
key: ${{ runner.os }}-build-e2e-tests-${{ hashFiles('**/go.sum') }}
329+
restore-keys: ${{ runner.os }}-build-e2e-tests-
330+
331+
- name: Cache Go Dependencies
332+
uses: actions/cache@v4
333+
with:
334+
path: .work/pkg
335+
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
336+
restore-keys: ${{ runner.os }}-pkg-
337+
338+
- name: Vendor Dependencies
339+
run: make vendor vendor.check
340+
341+
- name: Build Helm Chart
342+
run: make -j2 build.all
343+
env:
344+
BUILD_ARGS: "--load"
345+
346+
- name: Run E2E Tests
347+
run: make e2e USE_HELM3=true
348+
293349
publish-artifacts:
294350
runs-on: ubuntu-24.04
295351
needs:
@@ -300,6 +356,7 @@ jobs:
300356
- unit-tests
301357
- local-deploy
302358
- check-examples
359+
- e2e-tests
303360
if: needs.detect-noop.outputs.noop != 'true'
304361

305362
steps:

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ cover.out
99
# ignore IDE folders
1010
.vscode/
1111
.idea/
12+
.claude/
13+
14+
# Secrets
15+
.envrc.local
1216

1317
# Devenv
1418
.devenv*
@@ -22,3 +26,6 @@ devenv.local.nix
2226

2327
# Testing
2428
.kube/
29+
kubeconfig
30+
cluster/test/processed-examples/
31+
cluster/test/datasource.yaml

CONTRIBUTING.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,46 @@ See the [README.md](README.md#developing) for development setup instructions.
2727
Before submitting a pull request:
2828

2929
1. Run the full test suite: `make test`
30-
2. Test your changes locally: `./scripts/test-provider.sh`
31-
3. Ensure all CRDs generate properly: `make generate`
30+
2. Test your changes locally: `make local-deploy`
31+
3. Run end-to-end tests: `make e2e`
32+
4. Ensure all CRDs generate properly: `make generate`
33+
5. Run all pre-submit checks: `make reviewable`
34+
35+
### Testing with RedisCloud Pro Subscriptions
36+
37+
For testing Pro subscription features that require payment methods:
38+
39+
```bash
40+
# Set RedisCloud API credentials
41+
export REDISCLOUD_API_KEY="your-api-key"
42+
export REDISCLOUD_SECRET_KEY="your-secret-key"
43+
export REDISCLOUD_URL="https://api.redislabs.com/v1"
44+
45+
# List available payment methods
46+
make rediscloud-payment-methods
47+
48+
# Get first payment method ID
49+
make rediscloud-first-payment-method-id
50+
51+
# Run e2e tests with automatic payment method fetching
52+
make e2e
53+
54+
# Or with 1Password integration
55+
op run -- make e2e
56+
```
57+
58+
### Useful Make Targets
59+
60+
```bash
61+
make help # Show all available targets
62+
make test # Run unit tests
63+
make e2e # Run end-to-end tests
64+
make local-deploy # Deploy provider to local Kind cluster
65+
make run # Run provider locally (out of cluster)
66+
make reviewable # Run all checks before submitting PR
67+
make rediscloud-payment-methods # List available payment methods from RedisCloud
68+
make rediscloud-first-payment-method-id # Get first payment method ID
69+
```
3270

3371
## Submitting Changes
3472

Makefile

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,13 @@ run: go.build
175175
# ====================================================================================
176176
# End to End Testing
177177
CROSSPLANE_VERSION = 1.16.0
178-
CROSSPLANE_NAMESPACE = upbound-system
178+
CROSSPLANE_NAMESPACE ?= crossplane-system
179179
-include build/makelib/local.xpkg.mk
180180
-include build/makelib/controlplane.mk
181181

182182
# This target requires the following environment variables to be set:
183183
# - UPTEST_EXAMPLE_LIST, a comma-separated list of examples to test
184+
# Default: examples/rediscloud/subscription.yaml
184185
# To ensure the proper functioning of the end-to-end test resource pre-deletion hook, it is crucial to arrange your resources appropriately.
185186
# You can check the basic implementation here: https://github.com/crossplane/uptest/blob/main/internal/templates/03-delete.yaml.tmpl.
186187
# - UPTEST_CLOUD_CREDENTIALS (optional), multiple sets of AWS IAM User credentials specified as key=value pairs.
@@ -193,15 +194,31 @@ CROSSPLANE_NAMESPACE = upbound-system
193194
# aws_secret_access_key = REDACTED'
194195
# The associated `ProviderConfig`s will be named as `default` and `peer`.
195196
# - UPTEST_DATASOURCE_PATH (optional), please see https://github.com/crossplane/uptest#injecting-dynamic-values-and-datasource
197+
# - REDISCLOUD_PAYMENT_METHOD_ID (optional), the payment method ID to use for subscription examples
198+
# - REDISCLOUD_API_KEY, REDISCLOUD_SECRET_KEY, REDISCLOUD_URL - RedisCloud API credentials to fetch payment method ID
199+
UPTEST_EXAMPLE_LIST ?= examples/rediscloud/subscription.yaml
196200
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
197201
@$(INFO) running automated tests
198-
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) $(UPTEST) e2e "${UPTEST_EXAMPLE_LIST}" --data-source="${UPTEST_DATASOURCE_PATH}" --setup-script=cluster/test/setup.sh --default-conditions="Test" || $(FAIL)
202+
@# Create datasource.yaml file before running uptest (will be updated by setup script)
203+
@mkdir -p cluster/test
204+
@echo "# Placeholder datasource file - will be populated by setup script" > cluster/test/datasource.yaml
205+
@echo "payment_method_id: \"\"" >> cluster/test/datasource.yaml
206+
@echo "api_key: \"\"" >> cluster/test/datasource.yaml
207+
@echo "secret_key: \"\"" >> cluster/test/datasource.yaml
208+
@echo "url: \"\"" >> cluster/test/datasource.yaml
209+
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) \
210+
REDISCLOUD_API_KEY=$${REDISCLOUD_API_KEY:-} \
211+
REDISCLOUD_SECRET_KEY=$${REDISCLOUD_SECRET_KEY:-} \
212+
REDISCLOUD_URL=$${REDISCLOUD_URL:-} \
213+
REDISCLOUD_PAYMENT_METHOD_ID=$${REDISCLOUD_PAYMENT_METHOD_ID:-} \
214+
UPTEST_DATASOURCE_PATH="cluster/test/datasource.yaml" \
215+
$(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --data-source="cluster/test/datasource.yaml" --setup-script=cluster/test/setup.sh --default-conditions="Test" || $(FAIL)
199216
@$(OK) running automated tests
200217

201218
local-deploy: build controlplane.up local.xpkg.deploy.provider.$(PROJECT_NAME)
202219
@$(INFO) running locally built provider
203220
@$(KUBECTL) wait provider.pkg $(PROJECT_NAME) --for condition=Healthy --timeout 5m
204-
@$(KUBECTL) -n upbound-system wait --for=condition=Available deployment --all --timeout=5m
221+
@$(KUBECTL) -n $(CROSSPLANE_NAMESPACE) wait --for=condition=Available deployment --all --timeout=5m
205222
@$(OK) running locally built provider
206223

207224
e2e: local-deploy uptest
@@ -261,6 +278,40 @@ help-special: crossplane.help
261278

262279
.PHONY: crossplane.help help-special
263280

281+
# ====================================================================================
282+
# RedisCloud API Testing
283+
284+
# Fetch payment methods from RedisCloud API
285+
.PHONY: rediscloud-payment-methods
286+
rediscloud-payment-methods:
287+
@$(INFO) Fetching RedisCloud payment methods
288+
@curl -s -X GET "$${REDISCLOUD_URL}/payment-methods" \
289+
-H "x-api-key: $${REDISCLOUD_API_KEY}" \
290+
-H "x-api-secret-key: $${REDISCLOUD_SECRET_KEY}" | jq '.' || $(FAIL)
291+
@$(OK) Fetched RedisCloud payment methods
292+
293+
# Get the first payment method ID from RedisCloud API
294+
.PHONY: rediscloud-first-payment-method-id
295+
rediscloud-first-payment-method-id:
296+
@curl -s -X GET "$${REDISCLOUD_URL}/payment-methods" \
297+
-H "x-api-key: $${REDISCLOUD_API_KEY}" \
298+
-H "x-api-secret-key: $${REDISCLOUD_SECRET_KEY}" | jq -r '.paymentMethods[0].id // empty'
299+
300+
# Run e2e tests with processed examples
301+
.PHONY: e2e-with-processed-examples
302+
e2e-with-processed-examples:
303+
@$(INFO) Running e2e tests with processed examples
304+
@# The setup.sh script will handle fetching payment method ID and processing templates
305+
@# Use processed examples if they exist, otherwise fall back to original examples
306+
@if [ -d "cluster/test/processed-examples" ] && [ "$$(ls -A cluster/test/processed-examples/*.yaml 2>/dev/null | wc -l)" -gt 0 ]; then \
307+
EXAMPLE_LIST=$$(ls cluster/test/processed-examples/*.yaml | tr '\n' ',' | sed 's/,$$//'); \
308+
echo "Using processed examples: $${EXAMPLE_LIST}"; \
309+
$(MAKE) uptest UPTEST_EXAMPLE_LIST="$${EXAMPLE_LIST}"; \
310+
else \
311+
echo "Using default examples"; \
312+
$(MAKE) uptest; \
313+
fi
314+
264315
# TODO(negz): Update CI to use these targets.
265316
vendor: modules.download
266317
vendor.check: modules.check

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,37 @@ make build
120120

121121
### Testing
122122

123-
Run the test harness (uses podman by default):
123+
Run unit tests:
124124

125125
```bash
126-
./scripts/test-provider.sh
126+
make test
127+
```
128+
129+
Run end-to-end tests:
130+
131+
```bash
132+
# Run with default examples (subscription + database)
133+
make e2e
134+
135+
# Run with custom examples
136+
UPTEST_EXAMPLE_LIST="examples/rediscloud/acl-user.yaml" make e2e
137+
```
138+
139+
#### E2E Testing with RedisCloud Pro Subscriptions
140+
141+
Pro subscriptions require a valid payment method ID. The test infrastructure automatically handles this:
142+
143+
```bash
144+
# Set RedisCloud API credentials
145+
export REDISCLOUD_API_KEY="your-api-key"
146+
export REDISCLOUD_SECRET_KEY="your-secret-key"
147+
export REDISCLOUD_URL="https://api.redislabs.com/v1"
148+
149+
# Run e2e tests (automatically fetches payment method ID)
150+
make e2e
151+
152+
# Or with 1Password integration
153+
op run -- make e2e
127154
```
128155

129156
For detailed testing instructions, see [TESTING.md](TESTING.md).

0 commit comments

Comments
 (0)