Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .buildkite/scripts/update-kibana-client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -euo pipefail

source /etc/profile.d/go.sh

echo "--- Regenerating the Kibana client"
make -C generated/kbapi all

echo "--- Building the provider"
make build

echo "--- Starting Stack containers"
make docker-fleet
docker ps
sleep 30

echo "--- Collecting docker info"
docker ps
docker logs terraform-elasticstack-kb 2>&1 > kibana.log
docker logs terraform-elasticstack-es 2>&1 > es.log
docker logs terraform-elasticstack-fleet 2>&1 > fleet.log

buildkite-agent artifact upload kibana.log
buildkite-agent artifact upload es.log
buildkite-agent artifact upload fleet.log

echo "--- Running acceptance tests"
ELASTICSEARCH_ENDPOINTS=http://localhost:9200 KIBANA_ENDPOINT=http://localhost:5601 ELASTICSEARCH_USERNAME=elastic ELASTICSEARCH_PASSWORD=password make testacc
8 changes: 2 additions & 6 deletions .buildkite/update-kibana-client.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
agents:
provider: "gcp"
machineType: "n1-standard-4"
image: family/managed-intake-service-ubuntu-2204
image: family/terraform-provider-elasticstack-ubuntu-2204
steps:
- label: Regenerate Kibana client and build provider
command:
- "make -C generated/kbapi all"
- "make build"
- "make test"
- "make docker-fleet"
- "make testacc"
- ".buildkite/scripts/update-kibana-client.sh"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ build: lint build-ci ## build the terraform provider

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

.PHONY: test
test: ## Run unit tests
Expand Down
7 changes: 6 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ require (
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bitfield/gotestdox v0.2.2 // indirect
github.com/blacktop/go-dwarf v1.0.10 // indirect
github.com/blacktop/go-macho v1.1.238 // indirect
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb // indirect
Expand Down Expand Up @@ -145,6 +146,7 @@ require (
github.com/digitorus/timestamp v0.0.0-20231217203849-220c5c2851b7 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/docker/cli v28.1.1+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v28.1.1+incompatible // indirect
Expand All @@ -159,7 +161,7 @@ require (
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
Expand Down Expand Up @@ -202,6 +204,7 @@ require (
github.com/google/rpmpack v0.7.0 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/safetext v0.0.0-20240722112252-5a72de7e7962 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/wire v0.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
Expand Down Expand Up @@ -398,6 +401,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/gotestsum v1.13.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
sigs.k8s.io/kind v0.27.0 // indirect
Expand All @@ -412,4 +416,5 @@ tool (
github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
go.uber.org/mock/mockgen
gotest.tools/gotestsum
)
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
github.com/blacktop/go-dwarf v1.0.10 h1:i9zYgcIROETsNZ6V+zZn3uDH21FCG5BLLZ837GitxS0=
github.com/blacktop/go-dwarf v1.0.10/go.mod h1:4W2FKgSFYcZLDwnR7k+apv5i3nrau4NGl9N6VQ9DSTo=
github.com/blacktop/go-macho v1.1.238 h1:OFfT6NB/SWxkoky7L/ytuY8QekgFpa9pmz/GHUQLsmM=
Expand Down Expand Up @@ -329,6 +331,8 @@ github.com/distribution/distribution/v3 v3.0.0 h1:q4R8wemdRQDClzoNNStftB2ZAfqOiN
github.com/distribution/distribution/v3 v3.0.0/go.mod h1:tRNuFoZsUdyRVegq8xGNeds4KLjwLCRin/tTo6i1DhU=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
github.com/docker/cli v28.1.1+incompatible h1:eyUemzeI45DY7eDPuwUcmDyDj1pM98oD5MdSpiItp8k=
github.com/docker/cli v28.1.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
Expand Down Expand Up @@ -377,6 +381,8 @@ github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/X
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fatih/set v0.2.1 h1:nn2CaJyknWE/6txyUDGwysr3G5QC6xWB/PtVjPBbeaA=
github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
Expand Down Expand Up @@ -1369,8 +1375,11 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo=
gotest.tools/gotestsum v1.13.0/go.mod h1:7f0NS5hFb0dWr4NtcsAsF0y1kzjEFfAil0HiBQJE03Q=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
Expand Down
20 changes: 11 additions & 9 deletions internal/kibana/synthetics/private_location/acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/elastic/terraform-provider-elasticstack/internal/acctest"
"github.com/elastic/terraform-provider-elasticstack/internal/versionutils"
"github.com/hashicorp/go-version"
sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

Expand All @@ -29,14 +30,15 @@ var (

func TestSyntheticPrivateLocationResource(t *testing.T) {
resourceId := "elasticstack_kibana_synthetics_private_location.test"
randomSuffix := sdkacctest.RandStringFromCharSet(4, sdkacctest.CharSetAlphaNum)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure I follow why we need the random suffix for this resource but not for others. Should we add a comment to explain if there is something special about them?

resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t) },
ProtoV6ProviderFactories: acctest.Providers,
Steps: []resource.TestStep{
// Create and Read testing
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
Config: testConfig("testacc", "test_policy") + `
Config: testConfig("testacc", "test_policy", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
Expand All @@ -63,7 +65,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
ResourceName: resourceId,
ImportState: true,
ImportStateVerify: true,
Config: testConfig("testacc", "test_policy") + `
Config: testConfig("testacc", "test_policy", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy.policy_id
Expand All @@ -78,7 +80,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
// Update and Read testing
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
Config: testConfig("default", "test_policy_default") + `
Config: testConfig("default", "test_policy_default", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label-2"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
Expand All @@ -103,7 +105,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
// Update and Read testing
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
Config: testConfig("default", "test_policy_default") + `
Config: testConfig("default", "test_policy_default", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label-2"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
Expand All @@ -119,7 +121,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
// Update and Read testing
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
Config: testConfig("default", "test_policy_default") + `
Config: testConfig("default", "test_policy_default", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label-2"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
Expand All @@ -139,7 +141,7 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
// Update and Read testing
{
SkipFunc: versionutils.CheckIfVersionIsUnsupported(minKibanaPrivateLocationAPIVersion),
Config: testConfig("default", "test_policy_default") + `
Config: testConfig("default", "test_policy_default", randomSuffix) + `
resource "elasticstack_kibana_synthetics_private_location" "test" {
label = "pl-test-label-2"
agent_policy_id = elasticstack_fleet_agent_policy.test_policy_default.policy_id
Expand All @@ -162,15 +164,15 @@ resource "elasticstack_kibana_synthetics_private_location" "test" {
})
}

func testConfig(namespace, agentPolicy string) string {
func testConfig(namespace, agentPolicy, randomSuffix string) string {
return providerConfig + fmt.Sprintf(`
resource "elasticstack_fleet_agent_policy" "%s" {
name = "Private Location Agent Policy - %s"
name = "Private Location Agent Policy - %s - %s"
namespace = "%s"
description = "TestPrivateLocationResource Agent Policy"
monitor_logs = true
monitor_metrics = true
skip_destroy = false
}
`, agentPolicy, agentPolicy, namespace)
`, agentPolicy, agentPolicy, randomSuffix, namespace)
}