-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
feat: Add RedisTimeSeries plugin #11054
feat: Add RedisTimeSeries plugin #11054
Conversation
@srebhan
Done.
Done
Done
I'm not familiar of RedisTimeSeries mock for Go.
Done, also removed the uneeded retry, FT.ADD can create a series if doesn't exist already. |
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.
Thanks for the nice update @gkorland! I do have only some style suggestions, but the PR looks good overall. There are two more things I want to ask you:
- Please sync the README example with the
sampleConfig
to show all options to the user. - Can you please add a test for the serialization? You can fake a client by introducing an interface with a
Do()
function and then compare the serialized format to the expected one. This would give us at least some testing in short-mode.
Co-authored-by: Sven Rebhan <[email protected]>
Co-authored-by: Sven Rebhan <[email protected]>
Co-authored-by: Sven Rebhan <[email protected]>
Co-authored-by: Sven Rebhan <[email protected]>
Co-authored-by: Sven Rebhan <[email protected]>
Co-authored-by: Sven Rebhan <[email protected]>
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 only leaves us with synchronizing the sampleConfig
to the README example...
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.
@gkorland we are almost there. I would comment the optional options (as this is what we do everywhere else). Furthermore, there is a closing quote missing in your TOML section...
Co-authored-by: Sven Rebhan <[email protected]>
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.
Looks good to me. Thanks for keep rocking on this PR @gkorland!
@gkorland it seems like there are some merge conflicts. Can you please rebase this PR on the latest master and resolve the conflicts!? |
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.
Just one small question and we will be good to go! Thank you for your work on this :)
Can you also run go mod tidy
and check back in as that should make the tests pass?
Pushed! |
@chayim can you look at the failing test? |
@srebhan I've fixed the merge conflicts, and our code, it passes all of CI, except for the Windows issue in statsd. But, given that this is a timeout.. perhaps it's a red herring? Can you please advise? |
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.
Can you please fix the error text? Other than this, the PR looks good.
@@ -0,0 +1,26 @@ | |||
package redistimeseries |
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.
As there is zero testing in this PR that would get routinely run, I'd like to see an integration test.
There is an example in the redis input using testcontainers that you can copy and paste from.
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.
@powersj Maybe I misunderstand the testing (and likely)! But doesn't the TestConnectAndWrite in this file, with the MockMetrics cover this use case? I'd like to make sure I'm not missing something - and I'm pretty sure I am.
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.
The point is that you have only a single test and this test isn't run by default (see if testing.Short() { ...Skip...}
) as it requires a local instance of redis
running. @powersj added some infrastructure to enable integration tests using testcontainers
(aka docker images) to verify functionality of plugins.
So the request is to make use of this infrastructure (see the plugin linked above) to at least enable integration tests for your plugin...
Co-authored-by: Sven Rebhan <[email protected]>
func TestConnectAndWrite(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip("Skipping integration test in short mode") | ||
} | ||
|
||
address := testutil.GetLocalHost() + ":6379" | ||
redis := &RedisTimeSeries{ | ||
Address: address, | ||
} | ||
|
||
// Verify that we can connect to the RedisTimeSeries server | ||
err := redis.Connect() | ||
require.NoError(t, err) | ||
|
||
// Verify that we can successfully write data to the RedisTimeSeries server | ||
err = redis.Write(testutil.MockMetrics()) | ||
require.NoError(t, err) | ||
} |
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.
To allow integration tests you want something like this
func TestConnectAndWrite(t *testing.T) { | |
if testing.Short() { | |
t.Skip("Skipping integration test in short mode") | |
} | |
address := testutil.GetLocalHost() + ":6379" | |
redis := &RedisTimeSeries{ | |
Address: address, | |
} | |
// Verify that we can connect to the RedisTimeSeries server | |
err := redis.Connect() | |
require.NoError(t, err) | |
// Verify that we can successfully write data to the RedisTimeSeries server | |
err = redis.Write(testutil.MockMetrics()) | |
require.NoError(t, err) | |
} | |
func TestConnectAndWriteIntegration(t *testing.T) { | |
if testing.Short() { | |
t.Skip("Skipping integration test in short mode") | |
} | |
servicePort := "6379" | |
container := testutil.Container{ | |
Image: "redis:alpine", | |
ExposedPorts: []string{servicePort}, | |
WaitingFor: wait.ForListeningPort(nat.Port(servicePort)), | |
} | |
require.NoError(t, container.Start(), "failed to start container") | |
defer func() { | |
require.NoError(t, container.Terminate(), "terminating container failed") | |
}() | |
redis := &RedisTimeSeries{ | |
Address: fmt.Sprintf("%s:%s", container.Address, container.Ports[servicePort]), | |
} | |
// Verify that we can connect to the RedisTimeSeries server | |
require.NoError(t, redis.Connect()) | |
// Verify that we can successfully write data to the RedisTimeSeries server | |
require.NoError(t, redis.Write(testutil.MockMetrics())) | |
} |
Hi @chayim - @srebhan and I talked and he will write the integration test once this is merged. It is something he wanted to learn anyway. Can you resolve the test issues and we can land this? Looks like a complaint:
You should be able to reproduce locally with Thanks! |
Yes... especially since that was already there, and I just needed to push. Pushing @powersj |
Download PR build artifacts for linux_amd64.tar.gz, darwin_amd64.tar.gz, and windows_amd64.zip. 🥳 This pull request decreases the Telegraf binary size by -2.02 % for linux amd64 (new size: 143.3 MB, nightly size 146.2 MB) 📦 Click here to get additional PR build artifactsArtifact URLs |
Required for all PRs: