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

chore(test): tag all unittests as !integration #3047

Merged
merged 4 commits into from
Jan 6, 2025
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
4 changes: 4 additions & 0 deletions .github/workflows/fvt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
nohup sudo tcpdump -i lo -w "fvt-kafka-${{ inputs.kafka-version }}.pcap" portrange 29091-29095 >/dev/null 2>&1 &
echo $! >tcpdump.pid
make test_functional
echo "## Code Coverage" >>$GITHUB_STEP_SUMMARY
echo "|Filename|Function|Coverage|" >>$GITHUB_STEP_SUMMARY
echo "|--------|--------|--------|" >>$GITHUB_STEP_SUMMARY
go tool cover -func=profile.out | sed -E -e 's/[[:space:]]+/|/g' -e 's/$/|/g' -e 's/^/|/g' >>$GITHUB_STEP_SUMMARY
- name: Stop tcpdump
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FILES := $(shell find . -name '*.go' -type f -not -name '*.pb.go' -not -name
TESTS := $(shell find . -name '*.go' -type f -not -name '*.pb.go' -not -name '*_generated.go' -name '*_test.go')

$(GOBIN)/tparse:
GOBIN=$(GOBIN) go install github.com/mfridman/tparse@v0.11.1
GOBIN=$(GOBIN) go install github.com/mfridman/tparse@v0.16.0
get:
$(GO) get ./...
$(GO) mod verify
Expand Down
2 changes: 2 additions & 0 deletions acl_create_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions acl_create_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions acl_delete_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions acl_delete_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions acl_describe_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions acl_describe_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions acl_types_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions add_offsets_to_txn_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions add_offsets_to_txn_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions add_partitions_to_txn_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions add_partitions_to_txn_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions admin_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions alter_client_quotas_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_client_quotas_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_configs_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_configs_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions alter_partition_reassignments_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_partition_reassignments_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_user_scram_credentials_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions alter_user_scram_credentials_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions api_versions_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
2 changes: 2 additions & 0 deletions api_versions_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
72 changes: 2 additions & 70 deletions async_producer_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand All @@ -17,55 +19,6 @@ import (
"github.com/stretchr/testify/require"
)

const TestMessage = "ABC THE MESSAGE"

func closeProducerWithTimeout(t *testing.T, p AsyncProducer, timeout time.Duration) {
var wg sync.WaitGroup
p.AsyncClose()

closer := make(chan struct{})
timer := time.AfterFunc(timeout, func() {
t.Error("timeout")
close(closer)
})
defer timer.Stop()

wg.Add(2)
go func() {
defer wg.Done()
for {
select {
case <-closer:
return
case _, ok := <-p.Successes():
if !ok {
return
}
t.Error("Unexpected message on Successes()")
}
}
}()
go func() {
defer wg.Done()
for {
select {
case <-closer:
return
case msg, ok := <-p.Errors():
if !ok {
return
}
t.Error(msg.Err)
}
}
}()
wg.Wait()
}

func closeProducer(t *testing.T, p AsyncProducer) {
closeProducerWithTimeout(t, p, 5*time.Minute)
}

func expectResultsWithTimeout(t *testing.T, p AsyncProducer, successCount, errorCount int, timeout time.Duration) {
t.Helper()
expect := successCount + errorCount
Expand Down Expand Up @@ -1612,27 +1565,6 @@ func TestBrokerProducerShutdown(t *testing.T) {
mockBroker.Close()
}

type appendInterceptor struct {
i int
}

func (b *appendInterceptor) OnSend(msg *ProducerMessage) {
if b.i < 0 {
panic("hey, the interceptor has failed")
}
v, _ := msg.Value.Encode()
msg.Value = StringEncoder(string(v) + strconv.Itoa(b.i))
b.i++
}

func (b *appendInterceptor) OnConsume(msg *ConsumerMessage) {
if b.i < 0 {
panic("hey, the interceptor has failed")
}
msg.Value = []byte(string(msg.Value) + strconv.Itoa(b.i))
b.i++
}

func testProducerInterceptor(
t *testing.T,
interceptors []ProducerInterceptor,
Expand Down
5 changes: 5 additions & 0 deletions balance_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,7 @@ func (p *partitionMovements) getTheActualPartitionToBeMoved(partition topicParti
return reversePairPartition
}

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func (p *partitionMovements) isLinked(src, dst string, pairs []consumerPair, currentPath []string) ([]string, bool) {
if src == dst {
return currentPath, false
Expand Down Expand Up @@ -1023,6 +1024,7 @@ func (p *partitionMovements) isLinked(src, dst string, pairs []consumerPair, cur
return currentPath, false
}

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func (p *partitionMovements) in(cycle []string, cycles [][]string) bool {
superCycle := make([]string, len(cycle)-1)
for i := 0; i < len(cycle)-1; i++ {
Expand All @@ -1037,6 +1039,7 @@ func (p *partitionMovements) in(cycle []string, cycles [][]string) bool {
return false
}

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func (p *partitionMovements) hasCycles(pairs []consumerPair) bool {
cycles := make([][]string, 0)
for _, pair := range pairs {
Expand Down Expand Up @@ -1068,6 +1071,7 @@ func (p *partitionMovements) hasCycles(pairs []consumerPair) bool {
return false
}

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func (p *partitionMovements) isSticky() bool {
for topic, movements := range p.PartitionMovementsByTopic {
movementPairs := make([]consumerPair, len(movements))
Expand All @@ -1085,6 +1089,7 @@ func (p *partitionMovements) isSticky() bool {
return true
}

//nolint:unused // this is used but only in unittests as a helper (which are excluded by the integration build tag)
func indexOfSubList(source []string, target []string) int {
targetSize := len(target)
maxCandidate := len(source) - targetSize
Expand Down
2 changes: 2 additions & 0 deletions balance_strategy_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions broker_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
10 changes: 2 additions & 8 deletions client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand All @@ -12,14 +14,6 @@ import (
"github.com/rcrowley/go-metrics"
)

func safeClose(t testing.TB, c io.Closer) {
t.Helper()
err := c.Close()
if err != nil {
t.Error(err)
}
}

func TestSimpleClient(t *testing.T) {
seedBroker := NewMockBroker(t, 1)

Expand Down
2 changes: 2 additions & 0 deletions client_tls_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_group_example_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_group_members_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_group_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_metadata_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_metadata_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions consumer_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions control_record_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions create_partitions_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions create_partitions_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions create_topics_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions create_topics_response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import (
Expand Down
2 changes: 2 additions & 0 deletions delete_groups_request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !functional

package sarama

import "testing"
Expand Down
Loading
Loading