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

Metricbeat: Integration tests for haproxy 1.7 and 1.8 #6793

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

jsoriano
Copy link
Member

@jsoriano jsoriano commented Apr 6, 2018

Test haproxy with versions 1.7 and 1.8 apart of 1.5.

It also adds a method to base compose mixin for tests to obtain hosts for tests using docker inspect.

@jsoriano jsoriano requested a review from ruflin April 6, 2018 15:04
@jsoriano jsoriano force-pushed the haproxy-versions-test branch 2 times, most recently from 7154f33 to 871ba0f Compare April 6, 2018 15:14
@@ -6,7 +6,7 @@
HAPROXY_FIELDS = metricbeat.COMMON_FIELDS + ["haproxy"]


class Test(metricbeat.BaseTest):
class HaproxyTest(metricbeat.BaseTest):
Copy link
Member

Choose a reason for hiding this comment

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

The reason we aways call it test is that it makes it very easy to run tests manually: nosetest test_haproxy.py:Test.test_*. What about not postfixing this by Test but just call it Haproxy for example and then have

16Test
17Test
18Test

like you have at the bottom.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, indeed haproxy is already in the name of the file, I'll change it when I revisit this :)

"period": "5s"
}])
self._test_stat()


class Haproxy_1_6_Test(HaproxyTest):
Copy link
Member

Choose a reason for hiding this comment

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

Not for now, but what if we could autogenerate this part? Meaning we would separate the test code from the versions against we want to test. This is getting interesting :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

There are ways to generate classes, I could give a try, but I'd wait to see more cases, for example in apache we had to override some parts of the test because each version provides different metrics, it was not only changing the scenario.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on waiting for some more cases to see how we can generalise it.

@@ -32,7 +32,7 @@ def test_info_socket(self):
self.render_config_template(modules=[{
"name": "haproxy",
"metricsets": ["info"],
"hosts": ["tcp://%s:%d" % (os.getenv('HAPROXY_HOST', 'localhost'), 14567)],
"hosts": ["tcp://%s:%d" % (self.compose_hosts()[0], 14567)],
Copy link
Member

Choose a reason for hiding this comment

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

What happens if more then 1 service is running? I think we are fine in this case as there will be only 1 haproxy instance but there are tests which require more then 1 service to be running.

Copy link
Member Author

@jsoriano jsoriano Apr 7, 2018

Choose a reason for hiding this comment

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

This method could return a hash with the service name as key, I'll refactor this. It could also return the hash with a list as values, in case some service has multiple replicas, e.g:

{
  "proxy": ["172.0.18.1"],
  "server": ["172.0.18.2", "172.0.18.3"],
}

I don't know if we have any case with multiple replicas.

Copy link
Member Author

Choose a reason for hiding this comment

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

Although if we have different service names for different versions this is not going to work as I'd want, I have to think more about this...

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Going to merge this. Change LGTM. Left some comments / ideas for the future of multi version testing.

@@ -43,7 +43,7 @@ The default metricsets are `info`and `stat`.
[float]
=== Compatibility

The HAProxy metricsets were tested with HAProxy 1.6 and are expected to work with all 1.6 versions.
The HAProxy metricsets are tested with HAProxy versions from 1.6, 1.7 to 1.8.
Copy link
Member

Choose a reason for hiding this comment

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

Should we find a way to define the supported versions in fields.yml so we can generate this?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could have a central place where to define the versions matrix for the tests and use it also to generate doc, yes, this will require further thinking.

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would be enough if we start with an array `version: ["1.7", "2.1", "5.2-alpha"] or if this will not be enough, as we should also have the supported OS in there and for some versions only a subset of metricset works? Perhaps we should also allow to overwrite these values per metricset?

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.

2 participants