From 52609165c798a2104fd7c7faac4e36752e18593c Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Fri, 31 May 2024 13:20:35 -0700 Subject: [PATCH 1/7] Add trichart as a display type --- .go-version | 2 +- lightstep/resource_dashboard.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.go-version b/.go-version index 3495033..69b369b 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.95.4 +1.95.5 diff --git a/lightstep/resource_dashboard.go b/lightstep/resource_dashboard.go index 7ee7bea..45bd33f 100644 --- a/lightstep/resource_dashboard.go +++ b/lightstep/resource_dashboard.go @@ -31,6 +31,7 @@ func getUnifiedQuerySchemaMap() map[string]*schema.Schema { "pie", "table", "traces_list", + "trichart", }, false), }, // See https://github.com/hashicorp/terraform-plugin-sdk/issues/155 From f45a6aad222e95d55dbdbb5b2de8f2d487f7e290 Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Fri, 31 May 2024 13:44:46 -0700 Subject: [PATCH 2/7] Add trichart test --- lightstep/resource_dashboard_test.go | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index 5d4287c..7a5283b 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -933,6 +933,53 @@ chart { `, displayType, displayTypeOptions) } +func makeTrichartDisplay() string { + return fmt.Sprintf(` +resource "lightstep_dashboard" "test_display_type_options" { +project_name = "` + testProject + `" +dashboard_name = "test trichart" + +group { +rank = 0 +title = "" +visibility_type = "implicit" + +chart { + name = "Chart #123" + type = "timeseries" + rank = 0 + x_pos = 4 + y_pos = 0 + width = 4 + height = 4 + + query { + query_name = "error_ratio" + display = "trichart" + display_type_options = { display_type = trichart } + hidden = false + query_string = "with\n errors = spans count\n | delta\n | filter service == "web" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == "web"\n | group_by [], sum;\n join errors / total, errors=0, total=0" + } + query { + query_name = "latency" + display = "trichart" + display_type_options = { display_type = trichart } + hidden = false + query_string = "spans latency | delta | filter service == "web" | group_by [], sum | point percentile(value, 99.0)" + } + query { + query_name = "rate" + display = "trichart" + display_type_options = { display_type = trichart } + hidden = false + query_string = "spans count | rate | filter service == "web" | group_by [], sum" + } + } +} +} +`) +} + func TestDisplayTypeOptionsError(t *testing.T) { var dashboard client.UnifiedDashboard @@ -1062,6 +1109,15 @@ func TestDisplayTypeOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.y_axis_max", "100"), ), }, + { + Config: makeTrichartDisplay(), + Check: resource.ComposeTestCheckFunc( + testAccCheckMetricDashboardExists(resourceName, &dashboard), + resource.TestCheckResourceAttr(resourceName, "dashboard_name", "test trichart"), + resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display", "trichart"), + resource.TestCheckResourceAttr(resourceName, "group.0.chart.0.query.0.display_type_options.0.display_type", "trichart"), + ), + }, { Config: makeDisplayTypeConfig("dependency_map", strings.TrimSpace(` display_type_options { From 647be6acc0095f254d6d2530dbd51b01faa172ad Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Fri, 31 May 2024 15:07:13 -0700 Subject: [PATCH 3/7] Add required env vars for integration tests --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 5cb22b9..f41a0ad 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,9 @@ endif LIGHTSTEP_ORG="terraform-provider" \ LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \ + TF_ACC_TERRAFORM_PATH=$(which terraform) \ + TF_ACC_PROVIDER_NAMESPACE=hashicorp \ + TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep .PHONY: test-local @@ -63,6 +66,9 @@ test-local: LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_RATE_LIMIT=100 \ LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \ + TF_ACC_TERRAFORM_PATH=$(which terraform) \ + TF_ACC_PROVIDER_NAMESPACE=hashicorp \ + TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep -test.run TestAccSAMLGroupMappings .PHONY: test-staging @@ -73,6 +79,9 @@ test-staging: LIGHTSTEP_ORG="terraform-provider" \ LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_BASE_URL="https://api-staging.lightstep.com" \ + TF_ACC_TERRAFORM_PATH=$(which terraform) \ + TF_ACC_PROVIDER_NAMESPACE=hashicorp \ + TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep .PHONY: ensure-clean-repo From 7fa31fc7ae9f3aa41452ca6ae39fb9ff3c98deae Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Mon, 3 Jun 2024 11:14:27 -0700 Subject: [PATCH 4/7] Attempt to remove new env vars --- Makefile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Makefile b/Makefile index f41a0ad..5cb22b9 100644 --- a/Makefile +++ b/Makefile @@ -52,9 +52,6 @@ endif LIGHTSTEP_ORG="terraform-provider" \ LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \ - TF_ACC_TERRAFORM_PATH=$(which terraform) \ - TF_ACC_PROVIDER_NAMESPACE=hashicorp \ - TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep .PHONY: test-local @@ -66,9 +63,6 @@ test-local: LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_RATE_LIMIT=100 \ LIGHTSTEP_API_BASE_URL="https://api.lightstep.com" \ - TF_ACC_TERRAFORM_PATH=$(which terraform) \ - TF_ACC_PROVIDER_NAMESPACE=hashicorp \ - TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep -test.run TestAccSAMLGroupMappings .PHONY: test-staging @@ -79,9 +73,6 @@ test-staging: LIGHTSTEP_ORG="terraform-provider" \ LIGHTSTEP_PROJECT="terraform-provider-test" \ LIGHTSTEP_API_BASE_URL="https://api-staging.lightstep.com" \ - TF_ACC_TERRAFORM_PATH=$(which terraform) \ - TF_ACC_PROVIDER_NAMESPACE=hashicorp \ - TF_ACC_PROVIDER_HOST=registry.opentofu.org \ go test -v ./lightstep .PHONY: ensure-clean-repo From 30777a1d5fd23510bb00f04124fa9fd8b41b3555 Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Mon, 3 Jun 2024 11:26:23 -0700 Subject: [PATCH 5/7] Proper quotes --- lightstep/resource_dashboard_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index 7a5283b..5f77c74 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -958,7 +958,7 @@ chart { display = "trichart" display_type_options = { display_type = trichart } hidden = false - query_string = "with\n errors = spans count\n | delta\n | filter service == "web" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == "web"\n | group_by [], sum;\n join errors / total, errors=0, total=0" + query_string = "with\n errors = spans count\n | delta\n | filter service == \"web\" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == \"web\"\n | group_by [], sum;\n join errors / total, errors=0, total=0" } query { query_name = "latency" From eb9b88c8f48bc35c79bc7b52494ceee473eead93 Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Mon, 3 Jun 2024 12:14:30 -0700 Subject: [PATCH 6/7] Escape more quotes --- lightstep/resource_dashboard_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index 5f77c74..a91d05d 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -965,14 +965,14 @@ chart { display = "trichart" display_type_options = { display_type = trichart } hidden = false - query_string = "spans latency | delta | filter service == "web" | group_by [], sum | point percentile(value, 99.0)" + query_string = "spans latency | delta | filter service == \"web\" | group_by [], sum | point percentile(value, 99.0)" } query { query_name = "rate" display = "trichart" display_type_options = { display_type = trichart } hidden = false - query_string = "spans count | rate | filter service == "web" | group_by [], sum" + query_string = "spans count | rate | filter service == \"web\" | group_by [], sum" } } } From 92bff60776d6a8afc18133a9b03babda5762fc5d Mon Sep 17 00:00:00 2001 From: Erik Singleton Date: Tue, 4 Jun 2024 09:23:27 -0700 Subject: [PATCH 7/7] Fix tests for real --- DEVELOPMENT.md | 8 ++++++-- lightstep/resource_dashboard_test.go | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 41560c1..6434950 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -7,6 +7,9 @@ If you're contributing changes or code to the provider, the integration tests cr To run the tests, first get an API key with a Member role for the public environment and run: ``` +export TF_ACC_PROVIDER_NAMESPACE="hashicorp" +export TF_ACC_PROVIDER_HOST="registry.opentofu.org" +export TF_ACC_TERRAFORM_PATH="$(which terraform)" LIGHTSTEP_API_KEY_PUBLIC=(your api key here) make acc-test ``` @@ -32,8 +35,9 @@ provider_installation { ## Updating docs Documentation files in `docs` are generated by combining: -* the contents of the `.md.tmpl` template files found in the `template` directory -* field-level documentation configured inline via `Description` attributes in `lightstep/*.go`. + +- the contents of the `.md.tmpl` template files found in the `template` directory +- field-level documentation configured inline via `Description` attributes in `lightstep/*.go`. Any edits to documentation files should be made in the `templates` directory or the .go files. Then you can use the following steps to generate the files in the docs directory: diff --git a/lightstep/resource_dashboard_test.go b/lightstep/resource_dashboard_test.go index a91d05d..d8ac4f7 100644 --- a/lightstep/resource_dashboard_test.go +++ b/lightstep/resource_dashboard_test.go @@ -956,21 +956,27 @@ chart { query { query_name = "error_ratio" display = "trichart" - display_type_options = { display_type = trichart } + display_type_options { + display_type = "trichart" + } hidden = false query_string = "with\n errors = spans count\n | delta\n | filter service == \"web\" && error == true\n | group_by [], sum;\n total = spans count\n | delta\n | filter service == \"web\"\n | group_by [], sum;\n join errors / total, errors=0, total=0" } query { query_name = "latency" display = "trichart" - display_type_options = { display_type = trichart } + display_type_options { + display_type = "trichart" + } hidden = false query_string = "spans latency | delta | filter service == \"web\" | group_by [], sum | point percentile(value, 99.0)" } query { query_name = "rate" display = "trichart" - display_type_options = { display_type = trichart } + display_type_options { + display_type = "trichart" + } hidden = false query_string = "spans count | rate | filter service == \"web\" | group_by [], sum" }