Skip to content

Commit 563d2eb

Browse files
authored
Merge branch 'main' into copilot/add-default-data-view-resource
2 parents 8e5e1d9 + ccaf99c commit 563d2eb

File tree

6 files changed

+75
-34
lines changed

6 files changed

+75
-34
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
source /etc/profile.d/go.sh
6+
7+
echo "--- Regenerating the Kibana client"
8+
make -C generated/kbapi all
9+
10+
echo "--- Building the provider"
11+
make build
12+
13+
echo "--- Starting Stack containers"
14+
make docker-fleet
15+
docker ps
16+
sleep 30
17+
18+
echo "--- Collecting docker info"
19+
docker ps
20+
docker logs terraform-elasticstack-kb 2>&1 > kibana.log
21+
docker logs terraform-elasticstack-es 2>&1 > es.log
22+
docker logs terraform-elasticstack-fleet 2>&1 > fleet.log
23+
24+
buildkite-agent artifact upload kibana.log
25+
buildkite-agent artifact upload es.log
26+
buildkite-agent artifact upload fleet.log
27+
28+
echo "--- Running acceptance tests"
29+
ELASTICSEARCH_ENDPOINTS=http://localhost:9200 KIBANA_ENDPOINT=http://localhost:5601 ELASTICSEARCH_USERNAME=elastic ELASTICSEARCH_PASSWORD=password make testacc
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
agents:
22
provider: "gcp"
33
machineType: "n1-standard-4"
4-
image: family/managed-intake-service-ubuntu-2204
4+
image: family/terraform-provider-elasticstack-ubuntu-2204
55
steps:
66
- label: Regenerate Kibana client and build provider
77
command:
8-
- "make -C generated/kbapi all"
9-
- "make build"
10-
- "make test"
11-
- "make docker-fleet"
12-
- "make testacc"
8+
- ".buildkite/scripts/update-kibana-client.sh"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ build: lint build-ci ## build the terraform provider
5454

5555
.PHONY: testacc
5656
testacc: ## Run acceptance tests
57-
TF_ACC=1 go test -v ./... -count $(ACCTEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)
57+
TF_ACC=1 go tool gotestsum --format testname --rerun-fails=3 --packages="-v ./..." -- -count $(ACCTEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)
5858

5959
.PHONY: test
6060
test: ## Run unit tests

go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ require (
106106
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
107107
github.com/bahlo/generic-list-go v0.2.0 // indirect
108108
github.com/bgentry/speakeasy v0.1.0 // indirect
109+
github.com/bitfield/gotestdox v0.2.2 // indirect
109110
github.com/blacktop/go-dwarf v1.0.10 // indirect
110111
github.com/blacktop/go-macho v1.1.238 // indirect
111112
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect
@@ -145,6 +146,7 @@ require (
145146
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
146147
github.com/dimchansky/utfbom v1.1.1 // indirect
147148
github.com/distribution/reference v0.6.0 // indirect
149+
github.com/dnephin/pflag v1.0.7 // indirect
148150
github.com/docker/cli v28.1.1+incompatible // indirect
149151
github.com/docker/distribution v2.8.3+incompatible // indirect
150152
github.com/docker/docker v28.1.1+incompatible // indirect
@@ -159,7 +161,7 @@ require (
159161
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
160162
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
161163
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
162-
github.com/fatih/color v1.17.0 // indirect
164+
github.com/fatih/color v1.18.0 // indirect
163165
github.com/felixge/httpsnoop v1.0.4 // indirect
164166
github.com/fsnotify/fsnotify v1.9.0 // indirect
165167
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
@@ -202,6 +204,7 @@ require (
202204
github.com/google/rpmpack v0.7.0 // indirect
203205
github.com/google/s2a-go v0.1.9 // indirect
204206
github.com/google/safetext v0.0.0-20240722112252-5a72de7e7962 // indirect
207+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
205208
github.com/google/wire v0.6.0 // indirect
206209
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
207210
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
@@ -398,6 +401,7 @@ require (
398401
gopkg.in/warnings.v0 v0.1.2 // indirect
399402
gopkg.in/yaml.v2 v2.4.0 // indirect
400403
gopkg.in/yaml.v3 v3.0.1 // indirect
404+
gotest.tools/gotestsum v1.13.0 // indirect
401405
k8s.io/klog/v2 v2.130.1 // indirect
402406
lukechampine.com/blake3 v1.2.1 // indirect
403407
sigs.k8s.io/kind v0.27.0 // indirect
@@ -412,4 +416,5 @@ tool (
412416
github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
413417
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
414418
go.uber.org/mock/mockgen
419+
gotest.tools/gotestsum
415420
)

go.sum

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
217217
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
218218
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
219219
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
220+
github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
221+
github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
220222
github.com/blacktop/go-dwarf v1.0.10 h1:i9zYgcIROETsNZ6V+zZn3uDH21FCG5BLLZ837GitxS0=
221223
github.com/blacktop/go-dwarf v1.0.10/go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo=
222224
github.com/blacktop/go-macho v1.1.238 h1:OFfT6NB/SWxkoky7L/ytuY8QekgFpa9pmz/GHUQLsmM=
@@ -329,6 +331,8 @@ github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN
329331
github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU=
330332
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
331333
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
334+
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
335+
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
332336
github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k=
333337
github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
334338
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
@@ -377,6 +381,8 @@ github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/X
377381
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
378382
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
379383
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
384+
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
385+
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
380386
github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA=
381387
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
382388
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
@@ -1369,8 +1375,11 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
13691375
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
13701376
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
13711377
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
1378+
gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo=
1379+
gotest.tools/gotestsum v1.13.0/go.mod h1:7f0NS5hFb0dWr4NtcsAsF0y1kzjEFfAil0HiBQJE03Q=
13721380
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
13731381
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
1382+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
13741383
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
13751384
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
13761385
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=

internal/kibana/synthetics/private_location/acc_test.go

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/elastic/terraform-provider-elasticstack/internal/acctest"
1111
"github.com/elastic/terraform-provider-elasticstack/internal/versionutils"
1212
"github.com/hashicorp/go-version"
13+
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1314
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
1415
)
1516

@@ -29,26 +30,27 @@ var (
2930

3031
func TestSyntheticPrivateLocationResource(t *testing.T) {
3132
resourceId := "elasticstack_kibana_synthetics_private_location.test"
33+
randomSuffix := sdkacctest.RandStringFromCharSet(4, sdkacctest.CharSetAlphaNum)
3234
resource.Test(t, resource.TestCase{
3335
PreCheck: func() { acctest.PreCheck(t) },
3436
ProtoV6ProviderFactories: acctest.Providers,
3537
Steps: []resource.TestStep{
3638
// Create and Read testing
3739
{
3840
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
39-
Config: testConfig("testacc", "test_policy") + `
41+
Config: testConfig("testacc", "test_policy", randomSuffix) + fmt.Sprintf(`
4042
resource "elasticstack_kibana_synthetics_private_location" "test" {
41-
label = "pl-test-label"
43+
label = "pl-test-label-%s"
4244
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
4345
tags = ["a", "b"]
4446
geo = {
4547
lat = 42.42
4648
lon = -42.42
4749
}
4850
}
49-
`,
51+
`, randomSuffix),
5052
Check: resource.ComposeAggregateTestCheckFunc(
51-
resource.TestCheckResourceAttr(resourceId, "label", "pl-test-label"),
53+
resource.TestCheckResourceAttr(resourceId, "label", fmt.Sprintf("pl-test-label-%s", randomSuffix)),
5254
resource.TestCheckResourceAttrSet(resourceId, "agent_policy_id"),
5355
resource.TestCheckResourceAttr(resourceId, "tags.#", "2"),
5456
resource.TestCheckResourceAttr(resourceId, "tags.0", "a"),
@@ -63,34 +65,34 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
6365
ResourceName: resourceId,
6466
ImportState: true,
6567
ImportStateVerify: true,
66-
Config: testConfig("testacc", "test_policy") + `
68+
Config: testConfig("testacc", "test_policy", randomSuffix) + fmt.Sprintf(`
6769
resource "elasticstack_kibana_synthetics_private_location" "test" {
68-
label = "pl-test-label"
70+
label = "pl-test-label-%s"
6971
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
7072
tags = ["a", "b"]
7173
geo = {
7274
lat = 42.42
7375
lon = -42.42
7476
}
7577
}
76-
`,
78+
`, randomSuffix),
7779
},
7880
// Update and Read testing
7981
{
8082
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
81-
Config: testConfig("default", "test_policy_default") + `
83+
Config: testConfig("default", "test_policy_default", randomSuffix) + fmt.Sprintf(`
8284
resource "elasticstack_kibana_synthetics_private_location" "test" {
83-
label = "pl-test-label-2"
85+
label = "pl-test-label-2-%s"
8486
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
8587
tags = ["c", "d", "e"]
8688
geo = {
8789
lat = -33.21
8890
lon = -33.21
8991
}
9092
}
91-
`,
93+
`, randomSuffix),
9294
Check: resource.ComposeAggregateTestCheckFunc(
93-
resource.TestCheckResourceAttr(resourceId, "label", "pl-test-label-2"),
95+
resource.TestCheckResourceAttr(resourceId, "label", fmt.Sprintf("pl-test-label-2-%s", randomSuffix)),
9496
resource.TestCheckResourceAttrSet(resourceId, "agent_policy_id"),
9597
resource.TestCheckResourceAttr(resourceId, "tags.#", "3"),
9698
resource.TestCheckResourceAttr(resourceId, "tags.0", "c"),
@@ -103,14 +105,14 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
103105
// Update and Read testing
104106
{
105107
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
106-
Config: testConfig("default", "test_policy_default") + `
108+
Config: testConfig("default", "test_policy_default", randomSuffix) + fmt.Sprintf(`
107109
resource "elasticstack_kibana_synthetics_private_location" "test" {
108-
label = "pl-test-label-2"
110+
label = "pl-test-label-2-%s"
109111
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
110112
}
111-
`,
113+
`, randomSuffix),
112114
Check: resource.ComposeAggregateTestCheckFunc(
113-
resource.TestCheckResourceAttr(resourceId, "label", "pl-test-label-2"),
115+
resource.TestCheckResourceAttr(resourceId, "label", fmt.Sprintf("pl-test-label-2-%s", randomSuffix)),
114116
resource.TestCheckResourceAttrSet(resourceId, "agent_policy_id"),
115117
resource.TestCheckNoResourceAttr(resourceId, "tags"),
116118
resource.TestCheckNoResourceAttr(resourceId, "geo"),
@@ -119,15 +121,15 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
119121
// Update and Read testing
120122
{
121123
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
122-
Config: testConfig("default", "test_policy_default") + `
124+
Config: testConfig("default", "test_policy_default", randomSuffix) + fmt.Sprintf(`
123125
resource "elasticstack_kibana_synthetics_private_location" "test" {
124-
label = "pl-test-label-2"
126+
label = "pl-test-label-2-%s"
125127
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
126128
tags = ["c", "d", "e"]
127129
}
128-
`,
130+
`, randomSuffix),
129131
Check: resource.ComposeAggregateTestCheckFunc(
130-
resource.TestCheckResourceAttr(resourceId, "label", "pl-test-label-2"),
132+
resource.TestCheckResourceAttr(resourceId, "label", fmt.Sprintf("pl-test-label-2-%s", randomSuffix)),
131133
resource.TestCheckResourceAttrSet(resourceId, "agent_policy_id"),
132134
resource.TestCheckResourceAttr(resourceId, "tags.#", "3"),
133135
resource.TestCheckResourceAttr(resourceId, "tags.0", "c"),
@@ -139,18 +141,18 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
139141
// Update and Read testing
140142
{
141143
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
142-
Config: testConfig("default", "test_policy_default") + `
144+
Config: testConfig("default", "test_policy_default", randomSuffix) + fmt.Sprintf(`
143145
resource "elasticstack_kibana_synthetics_private_location" "test" {
144-
label = "pl-test-label-2"
146+
label = "pl-test-label-2-%s"
145147
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
146148
geo = {
147149
lat = -33.21
148150
lon = -33.21
149151
}
150152
}
151-
`,
153+
`, randomSuffix),
152154
Check: resource.ComposeAggregateTestCheckFunc(
153-
resource.TestCheckResourceAttr(resourceId, "label", "pl-test-label-2"),
155+
resource.TestCheckResourceAttr(resourceId, "label", fmt.Sprintf("pl-test-label-2-%s", randomSuffix)),
154156
resource.TestCheckResourceAttrSet(resourceId, "agent_policy_id"),
155157
resource.TestCheckNoResourceAttr(resourceId, "tags"),
156158
resource.TestCheckResourceAttr(resourceId, "geo.lat", "-33.21"),
@@ -162,15 +164,15 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
162164
})
163165
}
164166

165-
func testConfig(namespace, agentPolicy string) string {
167+
func testConfig(namespace, agentPolicy, randomSuffix string) string {
166168
return providerConfig + fmt.Sprintf(`
167169
resource "elasticstack_fleet_agent_policy" "%s" {
168-
name = "Private Location Agent Policy - %s"
170+
name = "Private Location Agent Policy - %s - %s"
169171
namespace = "%s"
170172
description = "TestPrivateLocationResource Agent Policy"
171173
monitor_logs = true
172174
monitor_metrics = true
173175
skip_destroy = false
174176
}
175-
`, agentPolicy, agentPolicy, namespace)
177+
`, agentPolicy, agentPolicy, randomSuffix, namespace)
176178
}

0 commit comments

Comments
 (0)