Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf75712

Browse files
authored
chore: add integration test for provider (#233)
This PR adds integration tests for the provider against an arbitrary version of Coder.Example usage:```CODER_VERSION="v2.10.0-devel-3a9a7d199-amd64" go test -v ./integrationTesting methodology:```- Create an ephemeral Coder instance running in a container- Perform initial setup- Import a predefined template that creates a single file- Create a workspace that populates the file with the actual output- Compare the actual versus expected output
1 parent4f417ad commitdf75712

File tree

6 files changed

+506
-39
lines changed

6 files changed

+506
-39
lines changed

‎Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,19 @@ fmt:
66
gen:
77
go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest
88

9+
build: terraform-provider-coder
10+
11+
# Builds the provider. Note that as coder/coder is based on
12+
# alpine, we need to disable cgo.
13+
terraform-provider-coder: provider/*.go main.go
14+
CGO_ENABLED=0 go build.
15+
16+
# Run integration tests
17+
.PHONY: test-integration
18+
test-integration: terraform-provider-coder
19+
gotest -v ./integration
20+
921
# Run acceptance tests
1022
.PHONY: testacc
1123
testacc:
12-
TF_ACC=1 gotest ./... -v$(TESTARGS) -timeout 120m
24+
TF_ACC=1 gotest ./... -v$(TESTARGS) -timeout 120m

‎README.md

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ to setup your local Terraform to use your local version rather than the registry
2020

2121
1. Create a file named`.terraformrc` in your`$HOME` directory
2222
2. Add the following content:
23+
2324
```hcl
2425
provider_installation {
2526
# Override the coder/coder provider to use your local version
@@ -33,18 +34,46 @@ to setup your local Terraform to use your local version rather than the registry
3334
direct {}
3435
}
3536
```
37+
3638
3. (optional, but recommended) Validate your configuration:
37-
1. Create a new`main.tf` file and include:
38-
```hcl
39-
terraform {
40-
required_providers {
41-
coder = {
42-
source = "coder/coder"
43-
}
44-
}
45-
}
46-
```
39+
1. Create a new`main.tf` file and include:
40+
```hcl
41+
terraform {
42+
required_providers {
43+
coder = {
44+
source = "coder/coder"
45+
}
46+
}
47+
}
48+
```
4749
2. Run`terraform init` and observe a warning like`Warning: Provider development overrides are in effect`
4850
4. Run`go build -o terraform-provider-coder` to build the provider binary, which Terraform will try locate and execute
4951
5. All local Terraform runs will now use your local provider!
50-
6. _**NOTE**: we vendor in this provider into `github.com/coder/coder`, so if you're testing with a local clone then you should also run `go mod edit -replace github.com/coder/terraform-provider-coder=/path/to/terraform-provider-coder` in your clone._
52+
6._**NOTE**: we vendor in this provider into`github.com/coder/coder`, so if you're testing with a local clone then you should also run`go mod edit -replace github.com/coder/terraform-provider-coder=/path/to/terraform-provider-coder` in your clone._
53+
54+
####Terraform Acceptance Tests
55+
56+
To run Terraform acceptance tests, run`make testacc`. This will test the provider against the locally installed version of Terraform.
57+
58+
>**Note:** our[CI workflow](./github/workflows/test.yml) runs a test matrix against multiple Terraform versions.
59+
60+
####Integration Tests
61+
62+
The tests under the`./integration` directory perform the following steps:
63+
64+
- Build the local version of the provider,
65+
- Run an in-memory Coder instance with a specified version,
66+
- Validate the behaviour of the local provider against that specific version of Coder.
67+
68+
To run these integration tests locally:
69+
70+
1. Pull the version of the Coder image you wish to test:
71+
72+
```console
73+
docker pull ghcr.io/coder/coder:main-x.y.z-devel-abcd1234
74+
```
75+
76+
1. Run`CODER_VERSION=main-x.y.z-devel-abcd1234 make test-integration`.
77+
78+
>**Note:** you can specify`CODER_IMAGE` if the Coder image you wish to test is hosted somewhere other than`ghcr.io/coder/coder`.
79+
>For example,`CODER_IMAGE=example.com/repo/coder CODER_VERSION=foobar make test-integration`.

‎go.mod

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go 1.22
55
toolchaingo1.22.3
66

77
require (
8+
github.com/docker/dockerv26.1.3+incompatible
89
github.com/google/uuidv1.6.0
910
github.com/hashicorp/go-ctyv1.4.1-0.20200414143053-d3edf31b6320
1011
github.com/hashicorp/terraform-plugin-sdk/v2v2.20.0
@@ -18,10 +19,18 @@ require (
1819
github.com/Microsoft/go-winiov0.5.2// indirect
1920
github.com/agext/levenshteinv1.2.3// indirect
2021
github.com/apparentlymart/go-textseg/v13v13.0.0// indirect
22+
github.com/containerd/logv0.1.0// indirect
2123
github.com/davecgh/go-spewv1.1.1// indirect
24+
github.com/distribution/referencev0.6.0// indirect
25+
github.com/docker/go-connectionsv0.5.0// indirect
26+
github.com/docker/go-unitsv0.5.0// indirect
2227
github.com/fatih/colorv1.13.0// indirect
23-
github.com/golang/protobufv1.5.3// indirect
24-
github.com/google/go-cmpv0.5.9// indirect
28+
github.com/felixge/httpsnoopv1.0.4// indirect
29+
github.com/go-logr/logrv1.4.1// indirect
30+
github.com/go-logr/stdrv1.2.2// indirect
31+
github.com/gogo/protobufv1.3.2// indirect
32+
github.com/golang/protobufv1.5.4// indirect
33+
github.com/google/go-cmpv0.6.0// indirect
2534
github.com/hashicorp/errwrapv1.1.0// indirect
2635
github.com/hashicorp/go-checkpointv0.5.0// indirect
2736
github.com/hashicorp/go-cleanhttpv0.5.2// indirect
@@ -47,20 +56,34 @@ require (
4756
github.com/mitchellh/go-testing-interfacev1.14.1// indirect
4857
github.com/mitchellh/go-wordwrapv1.0.1// indirect
4958
github.com/mitchellh/reflectwalkv1.0.2// indirect
59+
github.com/moby/docker-image-specv1.3.1// indirect
60+
github.com/moby/termv0.5.0// indirect
61+
github.com/morikuni/aecv1.0.0// indirect
5062
github.com/oklog/runv1.0.0// indirect
63+
github.com/opencontainers/go-digestv1.0.0// indirect
64+
github.com/opencontainers/image-specv1.1.0// indirect
65+
github.com/pkg/errorsv0.9.1// indirect
5166
github.com/pmezard/go-difflibv1.0.0// indirect
5267
github.com/rogpeppe/go-internalv1.8.0// indirect
5368
github.com/vmihailenco/msgpackv4.0.4+incompatible// indirect
5469
github.com/vmihailenco/msgpack/v4v4.3.12// indirect
5570
github.com/vmihailenco/tagparserv0.1.1// indirect
5671
github.com/zclconf/go-ctyv1.10.0// indirect
57-
golang.org/x/cryptov0.21.0// indirect
58-
golang.org/x/netv0.23.0// indirect
59-
golang.org/x/sysv0.18.0// indirect
60-
golang.org/x/textv0.14.0// indirect
61-
google.golang.org/appenginev1.6.7// indirect
72+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttpv0.52.0// indirect
73+
go.opentelemetry.io/otelv1.27.0// indirect
74+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttpv1.27.0// indirect
75+
go.opentelemetry.io/otel/metricv1.27.0// indirect
76+
go.opentelemetry.io/otel/sdkv1.27.0// indirect
77+
go.opentelemetry.io/otel/tracev1.27.0// indirect
78+
golang.org/x/cryptov0.23.0// indirect
79+
golang.org/x/netv0.25.0// indirect
80+
golang.org/x/sysv0.20.0// indirect
81+
golang.org/x/textv0.15.0// indirect
82+
golang.org/x/timev0.5.0// indirect
83+
google.golang.org/appenginev1.6.8// indirect
6284
google.golang.org/genprotov0.0.0-20230410155749-daa745c078e1// indirect
63-
google.golang.org/grpcv1.56.3// indirect
64-
google.golang.org/protobufv1.33.0// indirect
85+
google.golang.org/grpcv1.64.0// indirect
86+
google.golang.org/protobufv1.34.1// indirect
6587
gopkg.in/yaml.v3v3.0.1// indirect
88+
gotest.tools/v3v3.5.1// indirect
6689
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp