-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic acceptence tests for kafka_cluster
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: acc_test | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v1 | ||
with: | ||
go-version: 1.16.x | ||
- name: Acceptence Tests | ||
env: # Or as an environment variable | ||
CONFLUENT_CLOUD_USERNAME: ${{ secrets.CONFLUENT_CLOUD_USERNAME }} | ||
CONFLUENT_CLOUD_PASSWORD: ${{ secrets.CONFLUENT_CLOUD_PASSWORD }} | ||
run: make testacc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package ccloud | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/hashicorp/go-uuid" | ||
r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func overrideProvider() *schema.Provider { | ||
return Provider() | ||
} | ||
func accProvider() map[string]*schema.Provider { | ||
return map[string]*schema.Provider{ | ||
"confluentcloud": overrideProvider(), | ||
} | ||
} | ||
|
||
func testAccPreCheck(t *testing.T) { | ||
if os.Getenv("CONFLUENT_CLOUD_USERNAME") == "" || os.Getenv("CONFLUENT_CLOUD_PASSWORD") == "" { | ||
t.Skip("CONFLUENT_CLOUD_ environment variables must be set") | ||
} | ||
} | ||
|
||
func TestAcc_BasicCluster(t *testing.T) { | ||
u, err := uuid.GenerateUUID() | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
r.ParallelTest(t, r.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: accProvider(), | ||
Steps: []r.TestStep{ | ||
{ | ||
Config: fmt.Sprintf(testResourceCluster_noConfig, u, u), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
//lintignore:AT004 | ||
const testResourceCluster_noConfig = ` | ||
resource "confluentcloud_environment" "test" { | ||
name = "acc_test_environment-%s" | ||
} | ||
resource "confluentcloud_kafka_cluster" "test" { | ||
name = "provider-test-%s" | ||
service_provider = "aws" | ||
region = "eu-west-1" | ||
availability = "LOW" | ||
environment_id = confluentcloud_environment.test.id | ||
deployment = { | ||
sku = "BASIC" | ||
} | ||
network_egress = 100 | ||
network_ingress = 100 | ||
storage = 5000 | ||
} | ||
` |