Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
freeznet committed Dec 18, 2024
1 parent 6763424 commit c3114d3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 26 deletions.
10 changes: 10 additions & 0 deletions pulsar/resource_pulsar_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ func TestHandleExistingCluster(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createCluster(t, cName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Clusters().Delete(cName); err != nil {
t.Fatalf("ERROR_DELETING_TEST_CLUSTER: %v", err)
}
})
},
CheckDestroy: testPulsarClusterDestroy,
ProviderFactories: testAccProviderFactories,
Expand All @@ -75,6 +80,11 @@ func TestImportExistingCluster(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createCluster(t, cName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Clusters().Delete(cName); err != nil {
t.Fatalf("ERROR_DELETING_TEST_CLUSTER: %v", err)
}
})
},
CheckDestroy: testPulsarClusterDestroy,
ProviderFactories: testAccProviderFactories,
Expand Down
5 changes: 5 additions & 0 deletions pulsar/resource_pulsar_namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ func TestImportExistingNamespace(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createNamespace(t, id)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Namespaces().DeleteNamespace(id); err != nil {
t.Fatalf("ERROR_DELETING_TEST_NS: %v", err)
}
})
},
CheckDestroy: testPulsarNamespaceDestroy,
ProviderFactories: testAccProviderFactories,
Expand Down
17 changes: 13 additions & 4 deletions pulsar/resource_pulsar_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,21 @@ func testPulsarSinkDestroy(s *terraform.State) error {

func TestImportExistingSink(t *testing.T) {
sinkName := acctest.RandString(6)
err := createSampleSink(sinkName)
if err != nil {
t.Fatal(err)
}

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
createSampleSink(sinkName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Sinks().DeleteSink(
"public",
"default",
sinkName,
); err != nil {
t.Fatalf("ERROR_DELETING_TEST_SINK: %v", err)
}
})
},
ProviderFactories: testAccProviderFactories,
CheckDestroy: testPulsarSinkDestroy,
Steps: []resource.TestStep{
Expand Down
16 changes: 12 additions & 4 deletions pulsar/resource_pulsar_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,20 @@ func getPulsarSourceByResourceID(id string) (*utils.SourceConfig, error) {

func TestImportExistingSource(t *testing.T) {
sourceName := acctest.RandString(6)
err := createSampleSource(sourceName)
if err != nil {
t.Fatal(err)
}

resource.Test(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
createSampleSource(sourceName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Sources().DeleteSource(
"public",
"default",
sourceName); err != nil {
t.Fatalf("ERROR_DELETING_TEST_SOURCE: %v", err)
}
})
},
ProviderFactories: testAccProviderFactories,
CheckDestroy: testPulsarSourceDestroy,
Steps: []resource.TestStep{
Expand Down
10 changes: 10 additions & 0 deletions pulsar/resource_pulsar_tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func TestHandleExistingTenant(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createTenant(t, tName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Tenants().Delete(tName); err != nil {
t.Fatalf("ERROR_DELETING_TEST_TENANT: %v", err)
}
})
},
ProviderFactories: testAccProviderFactories,
PreventPostDestroyRefresh: false,
Expand All @@ -77,6 +82,11 @@ func TestImportExistingTenant(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createTenant(t, tName)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Tenants().Delete(tName); err != nil {
t.Fatalf("ERROR_DELETING_TEST_TENANT: %v", err)
}
})
},
CheckDestroy: testPulsarTenantDestroy,
ProviderFactories: testAccProviderFactories,
Expand Down
29 changes: 11 additions & 18 deletions pulsar/resource_pulsar_topic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func TestImportExistingTopic(t *testing.T) {
PreCheck: func() {
testAccPreCheck(t)
createTopic(t, fullID, pnum)
t.Cleanup(func() {
if err := getClientFromMeta(testAccProvider.Meta()).Topics().Delete(fullID); err != nil {

Check failure on line 74 in pulsar/resource_pulsar_topic_test.go

View workflow job for this annotation

GitHub Actions / Run golangci-lint

not enough arguments in call to getClientFromMeta(testAccProvider.Meta()).Topics().Delete

Check failure on line 74 in pulsar/resource_pulsar_topic_test.go

View workflow job for this annotation

GitHub Actions / Run acceptance tests

not enough arguments in call to getClientFromMeta(testAccProvider.Meta()).Topics().Delete
t.Fatalf("ERROR_DELETING_TEST_TOPIC: %v", err)
}
})
},
ProviderFactories: testAccProviderFactories,
CheckDestroy: testPulsarTopicDestroy,
Expand All @@ -96,7 +101,6 @@ func TestPartionedTopicWithPermissionGrantUpdate(t *testing.T) {
func TestTopicNamespaceExternallyRemoved(t *testing.T) {

resourceName := "pulsar_topic.test"
cName := acctest.RandString(10)
tName := acctest.RandString(10)
nsName := acctest.RandString(10)
topicName := acctest.RandString(10)
Expand All @@ -108,7 +112,7 @@ func TestTopicNamespaceExternallyRemoved(t *testing.T) {
CheckDestroy: testPulsarTopicDestroy,
Steps: []resource.TestStep{
{
Config: testPulsarNamespaceWithTopic(testWebServiceURL, cName, tName, nsName, topicName),
Config: testPulsarNamespaceWithTopic(testWebServiceURL, tName, nsName, topicName),
Check: resource.ComposeTestCheckFunc(
testPulsarTopicExists(resourceName),
),
Expand All @@ -132,7 +136,7 @@ func TestTopicNamespaceExternallyRemoved(t *testing.T) {
t.Fatalf("ERROR_DELETING_TEST_NS: %v", err)
}
},
Config: testPulsarNamespaceWithTopic(testWebServiceURL, cName, tName, nsName, topicName),
Config: testPulsarNamespaceWithTopic(testWebServiceURL, tName, nsName, topicName),
PlanOnly: true,
ExpectNonEmptyPlan: true,
ExpectError: nil,
Expand Down Expand Up @@ -387,26 +391,15 @@ resource "pulsar_topic" "test" {
`, url, ttype, tname, pnum, permissionGrants)
}

func testPulsarNamespaceWithTopic(wsURL, cluster, tenant, ns, topicName string) string {
func testPulsarNamespaceWithTopic(wsURL, tenant, ns, topicName string) string {
return fmt.Sprintf(`
provider "pulsar" {
web_service_url = "%s"
}
resource "pulsar_cluster" "test_cluster" {
cluster = "%s"
cluster_data {
web_service_url = "http://localhost:8080"
broker_service_url = "http://localhost:6050"
peer_clusters = ["standalone"]
}
}
resource "pulsar_tenant" "test_tenant" {
tenant = "%s"
allowed_clusters = [pulsar_cluster.test_cluster.cluster, "standalone"]
allowed_clusters = ["standalone"]
}
resource "pulsar_namespace" "test" {
Expand All @@ -423,7 +416,7 @@ resource "pulsar_namespace" "test" {
message_ttl_seconds = "86400"
replication_clusters = ["standalone"]
is_allow_auto_update_schema = false
offload_threshold_size_in_mb = "100"
offload_threshold_size_in_mb = "100"
}
dispatch_rate {
Expand Down Expand Up @@ -487,5 +480,5 @@ resource "pulsar_topic" "test" {
pulsar_tenant.test_tenant
]
}
`, wsURL, cluster, tenant, ns, tenant, ns, topicName)
`, wsURL, tenant, ns, tenant, ns, topicName)
}

0 comments on commit c3114d3

Please sign in to comment.