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

'testing' is imported in non-test files (testhelpers.go) #1048

Closed
2 of 7 tasks
dmlambea opened this issue Aug 23, 2023 · 3 comments
Closed
2 of 7 tasks

'testing' is imported in non-test files (testhelpers.go) #1048

dmlambea opened this issue Aug 23, 2023 · 3 comments
Assignees

Comments

@dmlambea
Copy link
Contributor

Description

The file 'testhelpers.go' is adding test code to production builds. That file contains 'testing' package and adds some flags that appear in the usage of the final program. This bug is a regression of #51 but with a different set of flags.

How to reproduce

Given the following code, obtained from #51 and updated to the latest version of confluent-kafka-go:

package main

import (
	"flag"

	"github.com/confluentinc/confluent-kafka-go/v2/kafka"
)

func main() {
	flag.Parse()
	kafka.NewProducer(&kafka.ConfigMap{"bootstrap.servers": "foo"})
}

we get the following help output:

$ ./foo --help
Usage of ./main:
  -clients.docker
    	Decides whether a docker container be brought up automatically
  -clients.semaphore
    	Tells if the job is running on Semaphore

Checklist

Please provide the following information:

  • confluent-kafka-go and librdkafka version (LibraryVersion()): v2.2.0 and librdkafka-static-bundle-v2.2.0.tgz
  • Apache Kafka broker version:
  • Client configuration: ConfigMap{...}
  • Operating system: linux (glibc and musl)
  • Provide client logs (with "debug": ".." as necessary)
  • Provide broker log excerpts
  • Critical issue
@dmlambea
Copy link
Contributor Author

testhelpers.go cannot be suffixed with _test.go because CGo is not allowed in test code. But the only usage of CGo in that file seems to be for the line 159:

return 0, newError(C.RD_KAFKA_RESP_ERR__UNKNOWN_TOPIC)

That line could be replaced by another one not requiring CGo while expressing the same, like:

return 0, NewError(ErrUnknownTopic, "", false)

With this simple change, testhelpers.go contents could be added to testhelpers_test.go.

@milindl
Copy link
Contributor

milindl commented Aug 24, 2023

Thanks for bringing this issue up! I'll take a look at the fix in some time.

@milindl
Copy link
Contributor

milindl commented Oct 10, 2023

Fixed after #1077

@milindl milindl closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants