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: use testcontainers-go instead of containertest #16264

Merged
merged 11 commits into from
Nov 15, 2022

Conversation

mdelapenya
Copy link
Contributor

@mdelapenya mdelapenya commented Nov 11, 2022

Description:

This PR is replacing the internal package for managing containers lifecycle in tests with testcontainers-go. Following the same procedure as in #16209, where we updated the Redis receiver tests, we are updating:

  • zookeeper receiver
  • memcached receiver
  • docker stats receiver
  • aerospike receiver
  • kafka metrics receiver
  • docker observer extension

Link to tracking Issue: #9939

Testing:

I ran each module tests with:

cd $the_module
go test -timeout 600s -v -tags integration

Documentation: No docs were updated

Follow-ups
After merging this PR, I think the containertest package can be removed/deprecated.

@@ -67,7 +67,5 @@ require (

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/containertest => ../../internal/containertest
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to remove this line in #16209

@mdelapenya
Copy link
Contributor Author

It seems the same error than yesterday happened at the windows pipeline. Is there anything I can do to troubleshoot it?

@djaglowski
Copy link
Member

It seems the same error than yesterday happened at the windows pipeline. Is there anything I can do to troubleshoot it?

I opened #16267 to track the issue. I don't recall seeing this one in particular before, but we do deal with flaky tests much more frequently than we would like.

Ideally we would resolve every issue but these are often difficult to reproduce/debug. We try to at least document any failures in a corresponding issue and note reoccurrences as well. If nothing else, this provides more information about what may be happening. If a failure occurs frequently we will disable the test until it is resolved. We could certainly use more help with these flaky tests. Any help or ideas for managing are welcome.

@djaglowski djaglowski added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Nov 11, 2022
Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks again @mdelapenya.

@mdelapenya
Copy link
Contributor Author

The error seems a real one in dockerstatsreceiver.TestRemovedContainerRemovesRecordsIntegration.

Currently looking at it 👀

@github-actions github-actions bot requested a review from djaglowski November 11, 2022 16:44
@mdelapenya
Copy link
Contributor Author

mdelapenya commented Nov 11, 2022

@djaglowski I did my best trying to understand the test suite 🤞 Result is f01b5bd

I noticed the test failed because the assertions were expecting an isolated Docker execution, and it could be the case that other containers are running.

I'd recommend checking the current assertions regarding Docker events/stats, as they could be influenced by the existence of, i.e., the Ryuk container or other pending-to-be-pruned containers. Please take a look at f01b5bd#diff-ca81407f807d8cfe041b4a8ad51b991f51e0fcc20bfd8ff6bad32b9b9ac9e0ddR224 and f01b5bd#diff-ca81407f807d8cfe041b4a8ad51b991f51e0fcc20bfd8ff6bad32b9b9ac9e0ddR247, where I'm checking the initial count of running containers, and expecting just one more in the assertion.

Same issue in f01b5bd#diff-ca81407f807d8cfe041b4a8ad51b991f51e0fcc20bfd8ff6bad32b9b9ac9e0ddR255, where I created a stub Container from the container ID.

Hopefully I guessed correctly 😅

Copy link
Contributor

@antonblock antonblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aerospike changes look good and pass integration tests

@mdelapenya
Copy link
Contributor Author

Mongodb receiver tests failing:

--- FAIL: TestMongodbIntegration (0.00s)
    --- FAIL: TestMongodbIntegration/Running_mongodb_4.0 (16.87s)
    --- PASS: TestMongodbIntegration/Running_mongodb_4.2 (79.81s)
    --- PASS: TestMongodbIntegration/Running_mongodb_4.4_as_LPU (81.02s)
    --- PASS: TestMongodbIntegration/Running_mongodb_5.0 (76.70s)
FAIL
coverage: 73.3% of statements
FAIL	github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver	156.561s
?   	github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver/internal/metadata	[no test files]
FAIL
make[1]: *** [../../Makefile.Common:68: do-integration-tests-with-cover] Error 1
make: *** [Makefile:188: receiver/mongodbreceiver] Error 2

We could probably be facing "integrated tests", or tests that could eventually depend on each other's state. Will take a look at it once I have time.

The container requests where using same fixed, exposed port, instead of
using the random one. In this commit we are calculating the exposed port
in the getContainer method, returning the endpoint for the container
in order to be used by each test
@mdelapenya
Copy link
Contributor Author

I noticed the mongoDB test examples were using a fixed port to be exposed, and that port was the same for mongo 4.0 and 4.2.

I updated the function to return the mongo container to retrieve both the container and its endpoint, calculating the dynamic, random port internally.

Hope this fixes the build 🤞

@mdelapenya
Copy link
Contributor Author

The build failed because of the fpm install: https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/3454696043/jobs/5766407878

Run gem install --no-document fpm -v 1.11.0
  gem install --no-document fpm -v 1.11.0
  shell: /usr/bin/bash -e {0}
  env:
    TEST_RESULTS: testbed/tests/results/junit/results.xml
    SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    too many connection resets (https://rubygems.org/quick/Marshal.[4](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/3454696043/jobs/5766407878#step:4:4).[8](https://github.com/open-telemetry/opentelemetry-collector-contrib/actions/runs/3454696043/jobs/5766407878#step:4:9)/fpm-1.11.0.gemspec.rz)
Error: Process completed with exit code 1.

Probably a retry on the step could help here: https://github.com/orgs/community/discussions/27121#discussioncomment-3254700

@djaglowski
Copy link
Member

djaglowski commented Nov 14, 2022

@mdelapenya, really appreciate your efforts on this.

Given that the mongo changes go beyond what is necessary for the others, would you be willing to open a separate PR for that component?

@mdelapenya
Copy link
Contributor Author

Given that the mongo changes go beyond what is necessary for the others, would you be willing to open a separate PR for that component?

Sure, I can revert the commit for MongoDB and send it in a separate PR. I'm worried if, without the commit, the PR does not get merged because the mongo tests could eventually fail for the inconsistency of the used ports. If you agree with that, then't it's fine for me too :)

* main:
  [chore] dependabot updates Tue Nov 15 00:17:56 UTC 2022 (open-telemetry#16300)
  [receiver/rabbitmq] Fix flaky integration test (open-telemetry#16240)
  [Docker Stats Receiver] Add @jamesmoessis as code owner (open-telemetry#16253)
  [receiver/mongodbatlas] Alerts poll mode check hostname and port (open-telemetry#16286)
  [chore] update jaeger dep (open-telemetry#16287)
  [pkg/stanza] Fix issue where specifying a non-existent storage extension caused panic during shutdown. (open-telemetry#16213)
  [pkg/ottl] Rename ottllogs to ottllog (open-telemetry#16242)
  Register featuregate, otherwise does not work (open-telemetry#16269)
  [receiver/elasticsearch]: add fielddata memory size metrics on index level (open-telemetry#14922)
  [chore] remove what looks to be debugging code from instanaexporter (open-telemetry#16258)
@djaglowski djaglowski merged commit ce37a30 into open-telemetry:main Nov 15, 2022
@mdelapenya mdelapenya deleted the receivers-testcontainers-go branch November 15, 2022 16:23
JaredTan95 pushed a commit to openinsight-proj/opentelemetry-collector-contrib that referenced this pull request Nov 21, 2022
…#16264)

* chore: use testcontainers-go in zookeper receiver

* chore: use testcontainers-go in memcached receiver

* chore: use testcontainers-go in docker stats receiver

* chore: use testcontainers-go in aerospike receiver

* chore: use testcontainers-go in kafka metrics receiver

* chore: use testcontainers-go in docker observer extension
shalper2 pushed a commit to shalper2/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2022
…#16264)

* chore: use testcontainers-go in zookeper receiver

* chore: use testcontainers-go in memcached receiver

* chore: use testcontainers-go in docker stats receiver

* chore: use testcontainers-go in aerospike receiver

* chore: use testcontainers-go in kafka metrics receiver

* chore: use testcontainers-go in docker observer extension
@plantfansam plantfansam mentioned this pull request Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants