-
Notifications
You must be signed in to change notification settings - Fork 112
Run integration tests with Go #2118
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
Conversation
de0dea5
to
9be2c94
Compare
3905562
to
b7a8d80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing.
Going to go over it more tomorrow, left a few comments regarding the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this.
- Regarding the kafka case I'm wondering how it'll scale once we expand the tests to have more cases in the matrix (client version, go version etc') - we don't want to create the kafka broker for each case - so I think we need to have a way to register a "setup" function to our tests - this can be relevant also to the database/sql one and more future libraries.
- Also relating to the first point - I think we can make use of https://github.com/testcontainers/testcontainers-go instead of directly using the docker api, I think that lib can provide some nice abstractions for us.
I'm not seeing an issue running a broker per test given they will be run in parallel. But more importantly, I do not see it being relevant to this PR. We can address that issue when we address running multiple of these tests in a matrix test. This is something out-of-scope for this PR and is already being tracked as a follow up task in the description. I'll be sure to include this feedback in the issue I create for that task when this PR merges. |
I've tried switching to this but am not able to get this working. It looks to be due to my lack of knowledge about how to get the testcontainers to configure the network appropriately. Given we have a working solution for the single kafka test case, and given the abstractions are not going to make a significant reduction of code here (my non-working prototype had 10s of less lines) , I'm going to keep the use of the Docker API the way it is. It is something we can address in the future if we find a need or have the motivation to. |
Based on experience I had so far (amount of issues, stability of API), I would rather look into https://github.com/ory/dockertest. We use it in https://github.com/signalfx/splunk-otel-go. But using Docker API seems also fine and I do not think it should block this PR. |
85d508f
to
6d3435b
Compare
Update the e2e Kafka testing application to run Kafka directly in a Docker container using the Go Docker client.
Support integration testing in a docker container
6d3435b
to
c651643
Compare
Replace Integration Tests with Go
testing
implementationThis replaces the existing integration test run on a
kind
server with ones run directly from Go on the host machine.Resolves #93
Add
instrumentation_integration_test.go
This is the integration testing file. It runs integration tests for all existing coverage:
Each test is run as a sub-test of the main
TestIntegration
. This allows users to run all test:Or just a single test for a packge. For example:
The test is skipped if being run in short mode (i.e.
go test -short
), or if the user does not have permissions to set memory limits on the host (the same as our eBPF verifier tests).The test can be run from within a virtualized environment if permissions are not available by default with something like the following:
Note, the
Makefile
has been updated (see below).Processing reuse where possible
Instead of writing every part of the end-to-end tests in Go, existing functionality is reused where possible. This means that the test results are still evaluated with BATS.
This is an area of improvement to address after this PR (see below).
Event flow via signal
The end-to-end tests no longer rely on sleeps/timing to manage event flow. The integration tests signal the spawned process using Linux process signaling. Once signaled, the application knows it is being monitored and starts it processing.
Kafka Go testing
The Kafka testing is unique. It needs to run a Kafka server to communicate with. This consolidates that process into the end-to-end testing application.
The Docker Go client is used to managed and run a Kafka container.
Removed BATS verification of
traces.json
This was talked about at the last SIG meeting and is accomplished in these changes. The BATS verification against a static JSON output is unstable. Instead of updating all
traces.json
to the lastest version of Go used in this change (and other spans added to the Kafka testing), the verification oftraces.json
is removed.Makefile
All
fixture
targets are removed from theMakefile
.The docker development target (
make docker-dev
) is updated. It now runs with the correct permissions and mounts to run integration tests.The docker test target (
make docker-test
) is updated. It now runs with the correct permissions and mounts to run the full test suite, including integration tests.Kind Integration tests
The kind integration testing is removed along will all of the related artifacts.
Follow-up items