Skip to content

Commit 3cf1ce4

Browse files
authored
Clarify how acceptance tests should be run (elastic#1324)
1 parent 7385e93 commit 3cf1ce4

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

.github/copilot-instructions.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
You will be tasked to fix an issue from an open-source repository. This is a Go based repository hosting a Terrform provider for the elastic stack (elasticsearch and kibana) APIs. This repo currently supports both [plugin framework](https://developer.hashicorp.com/terraform/plugin/framework/getting-started/code-walkthrough) and [sdkv2](https://developer.hashicorp.com/terraform/plugin/sdkv2) resources. Unless you're told otherwise, all new resources _must_ use the plugin framework.
22

3-
4-
5-
63
Take your time and think through every step - remember to check your solution rigorously and watch out for boundary cases, especially with the changes you made. Your solution must be perfect. If not, continue working on it. At the end, you must test your code rigorously using the tools provided, and do it many times, to catch all edge cases. If it is not robust, iterate more and make it perfect. Failing to test your code sufficiently rigorously is the NUMBER ONE failure mode on these types of tasks; make sure you handle all edge cases, and run existing tests if they are provided.
74

8-
95
Please see [README.md](../README.md) and the [CONTRIBUTING.md](../CONTRIBUTING.md) docs before getting started.
106

11-
127
# Workflow
138

149
## High-Level Problem Solving Strategy
@@ -57,27 +52,27 @@ Carefully read the issue and think hard about a plan to solve it before coding.
5752
- After each change, verify correctness by running relevant tests.
5853
- If tests fail, analyze failures and revise your patch.
5954
- Write additional tests if needed to capture important behaviors or edge cases.
60-
- Ensure all tests pass before finalizing.
55+
- NEVER accept acceptance tests that have been skipped due to environment issues; always ensure the environment is correctly set up and all tests run successfully.
6156

6257
### 6.1 Acceptance Testing Requirements
63-
When running acceptance tests (`make testacc`), ensure the following:
64-
58+
When running acceptance tests, ensure the following:
6559

6660
- **Environment Variables** - The following environment variables are required for acceptance tests:
6761
- `ELASTICSEARCH_ENDPOINTS` (default: http://localhost:9200)
6862
- `ELASTICSEARCH_USERNAME` (default: elastic)
6963
- `ELASTICSEARCH_PASSWORD` (default: password)
7064
- `KIBANA_ENDPOINT` (default: http://localhost:5601)
7165
- `TF_ACC` (must be set to "1" to enable acceptance tests)
72-
- **Ensure a valid environment if using `go test`** - Check if the required environment variables are set, if not use the defaults specified above.
73-
- **Always finish with `make testacc`** - This will run all tests. Make sure all tests pass before considering a task complete.
74-
- **Pre-set Environment Variables** - Default environment variables are configured in the Makefile. If these defaults are suitable for your testing environment, `make testacc` will work directly without additional setup
75-
- **Docker Environment** - For isolated testing with guaranteed environment setup, use `make docker-testacc` which starts Elasticsearch and Kibana containers automatically
66+
- **Run targeted tests using `go test`** - Ensure the required environment variables are explicitly defined when running targeted tests. Example:
67+
```bash
68+
ELASTICSEARCH_ENDPOINTS=http://localhost:9200 ELASTICSEARCH_USERNAME=elastic ELASTICSEARCH_PASSWORD=password KIBANA_ENDPOINT=http://localhost:5601 TF_ACC=1 go test -v -run TestAccResourceName ./path/to/testfile.go
69+
```
7670

7771
## 7. Final Verification
7872
- Confirm the root cause is fixed.
7973
- Review your solution for logic correctness and robustness.
8074
- Iterate until you are extremely confident the fix is complete and all tests pass.
75+
- Run the acceptance tests for any changed resources. Ensure acceptance tests pass without any environment-related skips. Use `make testacc` to verify this, explicitly defining the required environment variables.
8176
- Run `make lint` to ensure any linting errors have not surfaced with your changes. This task may automatically correct any linting errors, and regenerate documentation. Include any changes in your commit.
8277

8378
## 8. Final Reflection and Additional Testing

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
terraform_wrapper: false
4646

4747
- name: Lint
48-
run: make lint
48+
run: make check-lint
4949

5050
test:
5151
name: Matrix Acceptance Test

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ build-ci: ## build the terraform provider
5252
.PHONY: build
5353
build: lint build-ci ## build the terraform provider
5454

55-
5655
.PHONY: testacc
5756
testacc: ## Run acceptance tests
5857
TF_ACC=1 go test -v ./... -count $(ACCTEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)
@@ -254,7 +253,10 @@ golangci-lint:
254253

255254

256255
.PHONY: lint
257-
lint: setup golangci-lint check-fmt check-docs ## Run lints to check the spelling and common go patterns
256+
lint: setup golangci-lint fmt docs-generate ## Run lints to check the spelling and common go patterns
257+
258+
.PHONY: check-lint
259+
check-lint: setup golangci-lint check-fmt check-docs
258260

259261
.PHONY: fmt
260262
fmt: ## Format code

0 commit comments

Comments
 (0)