Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests on Grafana v11 #1415

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
17 changes: 8 additions & 9 deletions .github/workflows/acc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,32 @@ jobs:
fail-fast: false # Let all versions run, even if one fails
matrix:
# OSS tests, run on all versions
version: ['10.3.1', '10.2.3', '9.5.15', '8.5.27']
version: ['11.0.0', '10.4.3', '9.5.18']
type: ['oss']
subset: ['basic', 'other', 'long']
include:
# Examples, run only on latest version
- version: '10.3.1'
- version: '11.0.0'
type: 'oss'
subset: examples
# TLS proxy tests, run only on latest version
- version: '10.3.1'
- version: '11.0.0'
type: 'tls'
subset: 'basic'
# Sub-path tests. Runs tests on localhost:3000/grafana/
- version: '10.3.1'
- version: '11.0.0'
type: 'subpath'
subset: 'basic'
- version: '10.3.1'
- version: '11.0.0'
type: 'subpath'
subset: 'other'
# Enterprise tests
- version: '10.3.1'
- version: '11.0.0'
type: 'enterprise'
subset: 'all'
- version: '9.5.15'
- version: '10.4.3'
type: 'enterprise'
subset: 'all'
- version: '8.5.27'
- version: '9.5.18'
type: 'enterprise'
subset: 'all'
name: ${{ matrix.version }} - ${{ matrix.type }} - ${{ matrix.subset }}
Expand Down
2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GRAFANA_VERSION ?= 10.3.1
GRAFANA_VERSION ?= 11.0.0
DOCKER_COMPOSE_ARGS ?= --force-recreate --detach --remove-orphans --wait

testacc:
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/message_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ page_title: "grafana_message_template Resource - terraform-provider-grafana"
subcategory: "Alerting"
description: |-
Manages Grafana Alerting message templates.
Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates
Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates
This resource requires Grafana 9.1.0 or later.
---

# grafana_message_template (Resource)

Manages Grafana Alerting message templates.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/)
* [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates)

This resource requires Grafana 9.1.0 or later.
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/mute_timing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ page_title: "grafana_mute_timing Resource - terraform-provider-grafana"
subcategory: "Alerting"
description: |-
Manages Grafana Alerting mute timings.
Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings
Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/HTTP API https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings
This resource requires Grafana 9.1.0 or later.
---

# grafana_mute_timing (Resource)

Manages Grafana Alerting mute timings.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/)
* [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings)

This resource requires Grafana 9.1.0 or later.
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/notification_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ subcategory: "Alerting"
description: |-
Sets the global notification policy for Grafana.
!> This resource manages the entire notification policy tree, and will overwrite any existing policies.
Official documentation https://grafana.com/docs/grafana/latest/alerting/manage-notifications/HTTP API https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/
Official documentation https://grafana.com/docs/grafana/latest/alerting/configure-notifications/HTTP API https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/
This resource requires Grafana 9.1.0 or later.
---

Expand All @@ -15,7 +15,7 @@ Sets the global notification policy for Grafana.

!> This resource manages the entire notification policy tree, and will overwrite any existing policies.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/)
* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/)

This resource requires Grafana 9.1.0 or later.
Expand Down
8 changes: 4 additions & 4 deletions internal/resources/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ func TestAccExamples(t *testing.T) {
{
category: "Alerting",
testCheck: func(t *testing.T, filename string) {
testutils.CheckOSSTestsEnabled(t, ">=10.3.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config.
testutils.CheckOSSTestsEnabled(t, ">=11.0.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config.
},
},
{
category: "Grafana OSS",
testCheck: func(t *testing.T, filename string) {
if strings.Contains(filename, "sso_settings") {
t.Skip() // TODO: Run on v10.4.0 once it's released
t.Skip() // TODO: Fix the tests to run on local instances
} else {
testutils.CheckOSSTestsEnabled(t, ">=10.3.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config.
testutils.CheckOSSTestsEnabled(t, ">=11.0.0") // Only run on latest OSS version. The examples should be updated to reflect their latest working config.
}
},
},
{
category: "Grafana Enterprise",
testCheck: func(t *testing.T, filename string) {
testutils.CheckEnterpriseTestsEnabled(t, ">=10.3.0") // Only run on latest version
testutils.CheckEnterpriseTestsEnabled(t, ">=11.0.0") // Only run on latest version
},
},

Expand Down
17 changes: 15 additions & 2 deletions internal/resources/grafana/common_check_exists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package grafana_test

import (
"fmt"
"os"
"strconv"
"strings"

"github.com/go-openapi/runtime"
goapi "github.com/grafana/grafana-openapi-client-go/client"
"github.com/grafana/grafana-openapi-client-go/client/annotations"
"github.com/grafana/grafana-openapi-client-go/client/provisioning"
"github.com/grafana/grafana-openapi-client-go/models"
"github.com/grafana/terraform-provider-grafana/v2/internal/common"
Expand All @@ -24,6 +26,9 @@ var (
func(client *goapi.GrafanaHTTPAPI, id string) (*models.ContactPoints, error) {
params := provisioning.NewGetContactpointsParams().WithName(&id)
resp, err := client.Provisioning.GetContactpoints(params)
if castErr, ok := err.(*runtime.APIError); strings.HasPrefix(os.Getenv("GRAFANA_VERSION"), "10.4") && ok && castErr.Code == 500 {
return nil, &runtime.APIError{Code: 404} // There's a bug in 10.4 where the API returns a 500 if no contact points are found
}
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -72,8 +77,16 @@ var (
annotationsCheckExists = newCheckExistsHelper(
func(a *models.Annotation) string { return strconv.FormatInt(a.ID, 10) },
func(client *goapi.GrafanaHTTPAPI, id string) (*models.Annotation, error) {
resp, err := client.Annotations.GetAnnotationByID(id)
return payloadOrError(resp, err)
resp, err := client.Annotations.GetAnnotations(annotations.NewGetAnnotationsParams())
if err != nil {
return nil, err
}
for _, a := range resp.Payload {
if strconv.FormatInt(a.ID, 10) == id {
return a, nil
}
}
return nil, &runtime.APIError{Code: 404, Response: "annotation not found"}
},
)
dashboardCheckExists = newCheckExistsHelper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func resourceMessageTemplate() *common.Resource {
Description: `
Manages Grafana Alerting message templates.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/template-notifications/create-notification-templates/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/create-notification-templates/)
* [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#templates)

This resource requires Grafana 9.1.0 or later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func resourceMuteTiming() *common.Resource {
Description: `
Manages Grafana Alerting mute timings.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/mute-timings/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/mute-timings/)
* [HTTP API](https://grafana.com/docs/grafana/next/developers/http_api/alerting_provisioning/#mute-timings)

This resource requires Grafana 9.1.0 or later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Sets the global notification policy for Grafana.

!> This resource manages the entire notification policy tree, and will overwrite any existing policies.

* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/)
* [Official documentation](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/)
* [HTTP API](https://grafana.com/docs/grafana/latest/developers/http_api/alerting_provisioning/)

This resource requires Grafana 9.1.0 or later.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ func TestAccAlertRule_zeroSeconds(t *testing.T) {
}

func TestAccAlertRule_NotificationSettings(t *testing.T) {
testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released
testutils.CheckOSSTestsEnabled(t, ">=10.4.0")

var group models.AlertRuleGroup
var name = acctest.RandString(10)
Expand Down
4 changes: 2 additions & 2 deletions internal/resources/grafana/resource_sso_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestSSOSettings_basic_oauth2(t *testing.T) {
testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released
testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Fix the tests to run on local instances

providers := []string{"gitlab", "google", "generic_oauth", "azuread", "okta"}

Expand Down Expand Up @@ -102,7 +102,7 @@ func TestSSOSettings_basic_saml(t *testing.T) {
}

func TestSSOSettings_customFields(t *testing.T) {
testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Run on v10.4.0 once it's released
testutils.CheckCloudInstanceTestsEnabled(t) // TODO: Fix the tests to run on local instances

api := grafanaTestClient()

Expand Down
Loading