From 591d336013a5589221e0aadcf43132f906e2b4da Mon Sep 17 00:00:00 2001 From: donovanbai-dd Date: Fri, 9 Dec 2022 14:52:38 -0800 Subject: [PATCH] fix and parallelize acceptance tests --- GNUmakefile | 5 ++--- kafka/data_source_kafka_topic_test.go | 1 + kafka/lazy_init_test.go | 3 ++- kafka/provider_test.go | 3 +-- kafka/resource_kafka_acl_test.go | 2 ++ kafka/resource_kafka_quota_test.go | 4 +++- kafka/resource_kafka_topic_test.go | 13 ++++--------- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 65e50de1..7d44c9f3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,3 @@ -TEST?=./... GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor) default: build @@ -6,7 +5,7 @@ build: go build . test: - go test $(TEST) -v $(TESTARGS) + go test ./kafka -v $(TESTARGS) testacc: GODEBUG=x509ignoreCN=0 \ @@ -18,6 +17,6 @@ testacc: KAFKA_SKIP_VERIFY=false \ KAFKA_ENABLE_TLS=true \ TF_LOG=DEBUG \ - TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 9m -count=1 + TF_ACC=1 go test ./kafka -v $(TESTARGS) -timeout 9m -count=1 .PHONY: build test testacc diff --git a/kafka/data_source_kafka_topic_test.go b/kafka/data_source_kafka_topic_test.go index ef34c85b..640fe22a 100755 --- a/kafka/data_source_kafka_topic_test.go +++ b/kafka/data_source_kafka_topic_test.go @@ -10,6 +10,7 @@ import ( ) func TestAcc_TopicData(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) diff --git a/kafka/lazy_init_test.go b/kafka/lazy_init_test.go index 50aed2f8..ec9a7ded 100644 --- a/kafka/lazy_init_test.go +++ b/kafka/lazy_init_test.go @@ -8,8 +8,9 @@ import ( r "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -//lintignore:AT001 +// lintignore:AT001 func TestAcc_LazyInit(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) diff --git a/kafka/provider_test.go b/kafka/provider_test.go index a9cbd790..7075f316 100644 --- a/kafka/provider_test.go +++ b/kafka/provider_test.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -var testProvider *schema.Provider +var testProvider, _ = overrideProvider() var testBootstrapServers []string = bootstrapServersFromEnv() func TestProvider(t *testing.T) { @@ -57,7 +57,6 @@ func overrideProvider() (*schema.Provider, error) { return nil, fmt.Errorf("Could not configure provider") } - testProvider = provider return provider, nil } diff --git a/kafka/resource_kafka_acl_test.go b/kafka/resource_kafka_acl_test.go index 0771c053..4ea0b69f 100644 --- a/kafka/resource_kafka_acl_test.go +++ b/kafka/resource_kafka_acl_test.go @@ -13,6 +13,7 @@ import ( ) func TestAcc_ACLCreateAndUpdate(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -65,6 +66,7 @@ func TestAcc_ACLCreateAndUpdate(t *testing.T) { } func TestAcc_ACLDeletedOutsideOfTerraform(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) diff --git a/kafka/resource_kafka_quota_test.go b/kafka/resource_kafka_quota_test.go index a2b74a99..47871ac7 100644 --- a/kafka/resource_kafka_quota_test.go +++ b/kafka/resource_kafka_quota_test.go @@ -10,6 +10,7 @@ import ( ) func TestAcc_BasicQuota(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -31,6 +32,7 @@ func TestAcc_BasicQuota(t *testing.T) { } func TestAcc_QuotaConfigUpdate(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -171,7 +173,7 @@ func testAccCheckQuotaDestroy(s *terraform.State) error { return nil } -//lintignore:AT004 +// lintignore:AT004 func cfgs(t *testing.T, bs string, extraCfg string) string { return fmt.Sprintf(` provider "kafka" { diff --git a/kafka/resource_kafka_topic_test.go b/kafka/resource_kafka_topic_test.go index 5dfb8b09..6b9f0ade 100644 --- a/kafka/resource_kafka_topic_test.go +++ b/kafka/resource_kafka_topic_test.go @@ -15,6 +15,7 @@ import ( ) func TestAcc_BasicTopic(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -35,6 +36,7 @@ func TestAcc_BasicTopic(t *testing.T) { } func TestAcc_TopicConfigUpdate(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -87,6 +89,7 @@ func testAccCheckTopicDestroy(s *terraform.State) error { } func TestAcc_TopicUpdatePartitions(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -112,6 +115,7 @@ func TestAcc_TopicUpdatePartitions(t *testing.T) { } func TestAcc_TopicAlterReplicationFactor(t *testing.T) { + t.Parallel() u, err := uuid.GenerateUUID() if err != nil { t.Fatal(err) @@ -238,15 +242,6 @@ func testResourceTopic_initialCheck(s *terraform.State) error { func testResourceTopic_produceMessages(messages []*sarama.ProducerMessage) r.TestCheckFunc { return func(s *terraform.State) error { c := testProvider.Meta().(*LazyClient) - if c == nil { - return fmt.Errorf("unable to get lazy client") - } - if c.inner == nil { - err := c.init() - if err != nil { - return fmt.Errorf("unable to get original kafka client") - } - } config := c.inner.config kafkaConfig, err := config.newKafkaConfig()