-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add helper to get hosts on metricbeat integration tests #11925
Add helper to get hosts on metricbeat integration tests #11925
Conversation
Add a helper to automatically obtain the host of a service in metricbeat integration tests so tests don't depend on environment variables or current running docker services. This is needed to allow in the future to run multiple versions of the same service, is also helpful when running tests locally. Environment variables with the format SERVICE_HOST, being SERVICE the uppercased name of the compose service can be used to override the automatic value. `NO_COMPOSE` environment variable can be used now to avoid stopping the running containers too. Add ports to all services in docker compose files, required for the helper. Part of elastic#7957 for python-based integration tests.
88cda5b
to
ede58db
Compare
jenkins, test this again please |
f4e0192
to
386432a
Compare
4929f5c
to
37dc4eb
Compare
dfcd3e2
to
0071b37
Compare
0071b37
to
3c411cf
Compare
3c411cf
to
cbed1fd
Compare
8825fa9
to
fcc2b56
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.
I like this change, it should make tests easier!
I wonder if we can detect ports as exposed in the Dockerfile
, without explicitly exposing them in docker-compose.yml
, or maybe that's too hidden
ENV KAFKA_LOGS_DIR="/kafka-logs" | ||
ENV _JAVA_OPTIONS "-Djava.net.preferIPv4Stack=true" | ||
ENV TERM=linux | ||
|
||
RUN apt-get update && apt-get install -y curl openjdk-8-jre-headless netcat dnsutils | ||
RUN apk add -u bash |
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.
changes to this file and run.sh
probably belong to a different PR?
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.
Changes here could probably be reverted, yes, I think they only reduced the size of the image.
Changes in run.sh are needed, kafka announces the addresses clients should use, current container only works if tests can connect to "kafka:9092". After this change services can be listening on random addresses and ports, so we need some plumbing to let kafka know what address it should announce.
But said that, not all changes are needed now, I got all changes done in #7957, that are intended also to be able to have multiple versions of the same service running at the same time, this is not needed till I merge the Go-part of this PR.
I will reduce the changes in these files to the ones really needed by now.
@@ -50,5 +50,4 @@ def test_jmx(self, mbean): | |||
assert evt["jolokia"]["test"]["gc"]["collection_count"] >= 0 | |||
|
|||
def get_hosts(self): | |||
return [os.getenv('JOLOKIA_HOST', 'localhost') + ':' + | |||
os.getenv('JOLOKIA_PORT', '8778')] | |||
return [self.compose_host()] |
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 see this pattern a lot, you could also replace get_hosts()
call with self.compose_host()
and remove get_hosts
all together??
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.
Good suggestion, thanks! It should be possible, I will do it and override only when needed.
I tried, but I didn't manage to do it, it seems that docker compose only expose ports defined in the docker-compose.yml file. If there is a way to make it expose the ports defined in the Dockerfile we could consider doing it, yes. |
b525479
to
a32c640
Compare
I have seen Kafka tests to fail a couple of times in travis, I am taking a look to this. |
Ok, it fails because it is not ready yet to have multiple docker compose files in the same run, I will try to refactor Kafka docker files to don't need to bring here more changes from #7957 I don't know though why it doesn't fail on Jenkins. |
Issues fixed by reverting more uneeded changes for kafka, this would be ready for another review. |
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.
Great improvement!
Add a helper to automatically obtain the host of a service in metricbeat
system tests so tests don't depend on environment variables or
current running docker services. This is needed to allow in the future
to run multiple versions of the same service, is also helpful when
running tests locally.
Environment variables with the format
SERVICE_HOST
, being SERVICEthe uppercased name of the compose service can be used to override the
automatic value. By now
OVERRIDE_HOST
needs to be set to for thesevariables to work in the python-based tests.
NO_COMPOSE
environment variable can be used now to avoid stoppingthe running containers too.
Add ports to all services in docker compose files, required for the
helper.
Part of #7957 for python-based integration tests.