Skip to content
Merged
132 changes: 88 additions & 44 deletions .github/workflows/terraform_provider.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,29 @@ on:
- develop
env:
TERRAFORM_VERSION: "1.2.6"
REDISCLOUD_ACCESS_KEY: ${{ secrets.REDISCLOUD_ACCESS_KEY_STAGING }}
REDISCLOUD_SECRET_KEY: ${{ secrets.REDISCLOUD_SECRET_KEY_STAGING }}
REDISCLOUD_URL: ${{ secrets.REDISCLOUD_URL_STAGING }}
AWS_TEST_CLOUD_ACCOUNT_NAME: "${{ secrets.AWS_TEST_CLOUD_ACCOUNT_NAME_STAGING }}"
AWS_PEERING_REGION: ${{ secrets.AWS_PEERING_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_VPC_CIDR: ${{ secrets.AWS_VPC_CIDR }}
AWS_VPC_ID: ${{ secrets.AWS_VPC_ID }}
AWS_TEST_TGW_ID: ${{ secrets.AWS_TEST_TGW_ID_STAGING }}
TF_ACC: true
TF_LOG: info
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUD_ACCOUNT_KEY }}
AWS_ACCESS_SECRET_KEY: ${{ secrets.CLOUD_ACCOUNT_SECRET }}
AWS_CONSOLE_USERNAME: ${{ secrets.CLOUD_ACCOUNT_USERNAME }}
AWS_CONSOLE_PASSWORD: ${{ secrets.CLOUD_ACCOUNT_PASS }}
AWS_SIGNIN_URL: ${{ secrets.CLOUD_ACCOUNT_URL }}
GCP_VPC_PROJECT: ${{ secrets.GCP_VPC_PROJECT }}
GCP_VPC_ID: ${{ secrets.GCP_VPC_ID }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: <span class="math-inline">\{\{ github\.workflow \}\}\-</span>{{ github.ref }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -86,57 +106,82 @@ jobs:
mkdir terraform-providers-schema
terraform providers schema -json > terraform-providers-schema/schema.json

go_test:
name: go test
go_test_databases:
name: go test Databases
needs: [go_build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloud(Essentials|Pro|ActiveActive)Database_.*"'

go_test_subscriptions:
name: go test Subscriptions
needs: [go_test_databases]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
filters: |
code-changes:
- 'go.mod'
- 'go.sum'
- 'provider/**'
- '*.go'
- '.github/workflows/**'
- run: make testacc
if: steps.filter.outputs.code-changes == 'true'
env:
REDISCLOUD_ACCESS_KEY: ${{ secrets.REDISCLOUD_ACCESS_KEY_STAGING }}
REDISCLOUD_SECRET_KEY: ${{ secrets.REDISCLOUD_SECRET_KEY_STAGING }}
REDISCLOUD_URL: ${{ secrets.REDISCLOUD_URL_STAGING }}
AWS_TEST_CLOUD_ACCOUNT_NAME: "${{ secrets.AWS_TEST_CLOUD_ACCOUNT_NAME_STAGING }}"
AWS_PEERING_REGION: ${{ secrets.AWS_PEERING_REGION }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_VPC_CIDR: ${{ secrets.AWS_VPC_CIDR }}
AWS_VPC_ID: ${{ secrets.AWS_VPC_ID }}
AWS_TEST_TGW_ID: ${{ secrets.AWS_TEST_TGW_ID_STAGING }}
TF_ACC: true
TF_LOG: debug
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUD_ACCOUNT_KEY }}
AWS_ACCESS_SECRET_KEY: ${{ secrets.CLOUD_ACCOUNT_SECRET }}
AWS_CONSOLE_USERNAME: ${{ secrets.CLOUD_ACCOUNT_USERNAME }}
AWS_CONSOLE_PASSWORD: ${{ secrets.CLOUD_ACCOUNT_PASS }}
AWS_SIGNIN_URL: ${{ secrets.CLOUD_ACCOUNT_URL }}
GCP_VPC_PROJECT: ${{ secrets.GCP_VPC_PROJECT }}
GCP_VPC_ID: ${{ secrets.GCP_VPC_ID }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
- name: Generate code coverage report
if: steps.filter.outputs.code-changes == 'true' && (success() || failure())
run: make generate_coverage
- name: Upload code coverage report
if: steps.filter.outputs.code-changes == 'true' && (success() || failure())
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloud(Essentials|Pro|ActiveActive)Subscription_.*"'

go_test_subscriptions_tls:
name: go test Subscriptions TLS
needs: [go_test_subscriptions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
name: coverage.html
path: bin/coverage.html
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloudSubscriptionTls_.*"'

go_test_essentials_plan:
name: go test Essentials Plan
needs: [go_test_subscriptions_tls]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloudEssentialsPlan_.*"'

go_test_persistence_modules_regions_acl:
name: go test Other
needs: [go_test_essentials_plan]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloud(DataPersistence|DatabaseModules|Regions|Acl).*"'

go_test_cloud_account:
name: go test Cloud Account
needs: [go_test_persistence_modules_regions_acl]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-test.short -run="TestAcc(DataSource|Resource)RedisCloud(CloudAccount).*"'

go_test_transit_payment:
name: go test Transit Gateway & Payment
needs: [go_test_cloud_account]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
- run: EXECUTE_TESTS=true make testacc TESTARGS='-run="TestAcc(DataSource|Resource)RedisCloud(TransitGatewayAttachment|PaymentMethod).*"'

tfproviderlint:
name: tfproviderlint
Expand All @@ -148,4 +193,3 @@ jobs:
with:
go-version-file: go.mod
- run: make tfproviderlint

42 changes: 42 additions & 0 deletions provider/datasource_rediscloud_acl_rule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package provider

import (
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
"testing"
)

func TestAccDataSourceRedisCloudAclRule_ForDefaultRule(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

// This rule already exists
const testName = "Read-Write"
const testRule = "+@all -@dangerous ~*"
getRuleTerraform := fmt.Sprintf(getDefaultDatasourceAclRuleDataSource, testName)

const AclRuleTest = "data.rediscloud_acl_rule.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
CheckDestroy: nil, // test doesn't create a resource, so don't need to check anything
Steps: []resource.TestStep{
{
Config: getRuleTerraform,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestMatchResourceAttr(
AclRuleTest, "id", regexp.MustCompile("^\\d*$")),
resource.TestCheckResourceAttr(AclRuleTest, "name", testName),
resource.TestCheckResourceAttr(AclRuleTest, "rule", testRule),
),
},
},
})
}

const getDefaultDatasourceAclRuleDataSource = `
data "rediscloud_acl_rule" "test" {
name = "%s"
}
`
3 changes: 3 additions & 0 deletions provider/datasource_rediscloud_cloud_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
)

func TestAccDataSourceRedisCloudCloudAccount_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

name := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")

const testCloudAccount = "data.rediscloud_cloud_account.test"
Expand Down
3 changes: 3 additions & 0 deletions provider/datasource_rediscloud_data_persistence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func TestAccDataSourceRedisCloudDataPersistence_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

const dataPersistenceFoo = "data.rediscloud_data_persistence.foo"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down
3 changes: 3 additions & 0 deletions provider/datasource_rediscloud_database_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func TestAccDataSourceRedisCloudDatabaseModules_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand Down
10 changes: 10 additions & 0 deletions provider/datasource_rediscloud_essentials_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

func TestAccDataSourceRedisCloudEssentialsPlan_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

const basicPlan = "data.rediscloud_essentials_plan.basic"

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -48,6 +50,8 @@ func TestAccDataSourceRedisCloudEssentialsPlan_basic(t *testing.T) {

func TestAccDataSourceRedisCloudEssentialsPlan_azure(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

const azurePlan = "data.rediscloud_essentials_plan.azure"

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -88,6 +92,8 @@ func TestAccDataSourceRedisCloudEssentialsPlan_azure(t *testing.T) {

func TestAccDataSourceRedisCloudEssentialsPlan_subscriptionId(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

const examplePlan = "data.rediscloud_essentials_plan.example"

resource.ParallelTest(t, resource.TestCase{
Expand Down Expand Up @@ -130,6 +136,8 @@ func TestAccDataSourceRedisCloudEssentialsPlan_subscriptionId(t *testing.T) {

func TestAccDataSourceRedisCloudEssentialsPlan_ambiguous(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand All @@ -145,6 +153,8 @@ func TestAccDataSourceRedisCloudEssentialsPlan_ambiguous(t *testing.T) {

func TestAccDataSourceRedisCloudEssentialsPlan_impossible(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand Down
2 changes: 2 additions & 0 deletions provider/datasource_rediscloud_payment_method_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

func TestAccDataSourceRedisCloudPaymentMethod_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand Down
3 changes: 3 additions & 0 deletions provider/datasource_rediscloud_pro_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
)

func TestAccDataSourceRedisCloudProDatabase_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

name := acctest.RandomWithPrefix(testResourcePrefix)
password := acctest.RandString(20)
testCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")
Expand Down
6 changes: 6 additions & 0 deletions provider/datasource_rediscloud_pro_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
)

func TestAccDataSourceRedisCloudProSubscription_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

name := acctest.RandomWithPrefix("tf-test")

const resourceName = "rediscloud_subscription.example"
Expand Down Expand Up @@ -57,6 +60,9 @@ func TestAccDataSourceRedisCloudProSubscription_basic(t *testing.T) {
}

func TestAccDataSourceRedisCloudProSubscription_ignoresAA(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

name := acctest.RandomWithPrefix(testResourcePrefix)
password := acctest.RandString(20)

Expand Down
9 changes: 9 additions & 0 deletions provider/datasource_rediscloud_regions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
)

func TestAccDataSourceRedisCloudRegions_all(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand Down Expand Up @@ -40,6 +43,9 @@ func TestAccDataSourceRedisCloudRegions_all(t *testing.T) {
}

func TestAccDataSourceRedisCloudRegions_AWS(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand All @@ -64,6 +70,9 @@ func TestAccDataSourceRedisCloudRegions_AWS(t *testing.T) {
}

func TestAccDataSourceRedisCloudRegions_GCP(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: providerFactories,
Expand Down
3 changes: 3 additions & 0 deletions provider/datasource_rediscloud_subscription_peerings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
)

func TestAccDataSourceRedisCloudSubscriptionPeerings_basic(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

name := acctest.RandomWithPrefix(testResourcePrefix)

testCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")
Expand Down
4 changes: 3 additions & 1 deletion provider/rediscloud_acl_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"testing"
)

func TestAccCreateReadUpdateImportDeleteAclRole_Pro(t *testing.T) {
func TestAccResourceRedisCloudAclRole_CRUDI(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

prefix := acctest.RandomWithPrefix(testResourcePrefix)
exampleCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")
Expand Down
2 changes: 2 additions & 0 deletions provider/rediscloud_acl_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (

func TestAccResourceRedisCloudAclUser_CRUDI(t *testing.T) {

testAccRequiresEnvVar(t, "EXECUTE_TESTS")

prefix := acctest.RandomWithPrefix(testResourcePrefix)
exampleCloudAccountName := os.Getenv("AWS_TEST_CLOUD_ACCOUNT_NAME")
exampleSubscriptionName := prefix + "-subscription"
Expand Down
Loading
Loading