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

refactor grafanaNet route cfg + unit testing for setting up route + configurable retry backoff intervals + more #465

Merged
merged 10 commits into from
Jun 15, 2021

Conversation

Dieterbe
Copy link
Contributor

@Dieterbe Dieterbe commented Jun 11, 2021

@fkaleo i got a bit of a surprise for you..

I thought it was a good idea to refactor that ugly-and-getting-longer constructor function for GrafanaNet routes to use a cfg struct. added some options, so far so good.
thought it may also make sense to add some testing to make sure that 1) given an init command or 2) given a toml config, the proper grafananet route is created. but both of those affect the table directly, so you have to inspect the table (or use a mock that makes it a bit easier). for use case 1 it was fairly straightforward, but 2 landed me in a bit of a mess (circular dependency) . I'll have a fresh look at it on monday. i still like the idea of unit testing, but need to figure out if it can be done realistically

well at least even without the tests, this PR does clean stuff up, both in code and docs.

@fkaleo
Copy link

fkaleo commented Jun 14, 2021

What I have seen so far (I have reviewed commits till 751b484) looks good to me.

The table package should not reach out into configuration packages such
as cfg and imperatives
Instead the table is something that should be setup _from_ imperatives
(this was already the case) and _from_ the config
So, we move out the config bits from table and make it work with the
generic interface.
Just as we already tested table setup from imperatives, this will let us
test the same through cfg as well. (see next commit)

While we're at it:
* move imperative's table Interface and MockTable to the table package,
  so it can be used in various places
* cleaner "TableConfig" type
* move validation of badMetrics settings and its creation
  to table config and construction (that was the only case from
  the moved config stuff that accessed the table directly and couldn't
  be interface-ized)

One interesting thing is that the cfg imports imperatives. Why? simply
because your toml configuration may contain imperative commands that
need to be executed
@Dieterbe Dieterbe changed the title Grafana net cfg refactor grafanaNet route cfg + unit testing for setting up route + configurable retry backoff intervals + more Jun 14, 2021
@Dieterbe Dieterbe marked this pull request as ready for review June 14, 2021 18:36
@fkaleo fkaleo self-requested a review June 15, 2021 06:26
Copy link

@fkaleo fkaleo left a comment

Choose a reason for hiding this comment

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

ALRIGHT:

  1. thank god for tests
  2. everything seems to check out

@Dieterbe Dieterbe merged commit 1ecb512 into master Jun 15, 2021
@Dieterbe Dieterbe deleted the grafana-net-cfg branch June 15, 2021 07:37
@Dieterbe
Copy link
Contributor Author

for anyone lurking...
re

for use case 1 it was fairly straightforward, but 2 landed me in a bit of a mess (circular dependency) . I'll have a fresh look at it on monday. i still like the idea of unit testing, but need to figure out if it can be done realistically

i figured it out how to do it. pretty happy now to have unit testing both from the toml config, as well as imperatives side

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 this pull request may close these issues.

None yet

2 participants