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

test: Fix bug in TestAddTestPlugin test helper #19313

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

fairclothjm
Copy link
Contributor

@fairclothjm fairclothjm commented Feb 23, 2023

This PR fixes a bug in TestAddTestPlugin that appears to only manifest on Linux systems. This bug resulted in the test failing on Mac systems but passing on Linux systems because we failed to properly get the plugin version.

Additionally, we update the test to use the plugin version when performing the Read on the plugin catalog since this should now be properly set.

We write the plugin binary file in TestAddTestPlugin and then call file.Close() in a defer statement. However, we need to read the file's SHA256 sum immediately after writing the file so we call file.Sync(). On Linux this was not working as expected because we seem to be reading the sha sum and running the plugin too fast. This caused the call to get the plugin version to fail and to be incorrectly written to storage as un-versioned.

@fairclothjm
Copy link
Contributor Author

I think its ok to leave the defer out.Close() call even though it will error since we are ignoring it?

@maxcoulombe
Copy link
Contributor

maxcoulombe commented Feb 23, 2023

This caused the call to get the plugin version to fail and to be incorrectly written to storage as un-versioned.

Is this intended? Should the plugin addition/registration operation fail entirely if we expect a version but fail to retrieve it? Maybe that's lenient for backward compatibility or something but I'm wondering.

Copy link
Contributor

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

And yes, exactly, I think we can leave in defer out.Close() since we ignore the error (and it's good to keep it in just in case we hit one of the t.Fatal lines).

@swenson
Copy link
Contributor

swenson commented Feb 23, 2023

This caused the call to get the plugin version to fail and to be incorrectly written to storage as un-versioned.

Is this intended? Should the plugin addition/registration operation fail entirely if we expect a version but fail to retrieve it? Maybe that's lenient for backward compatibility or something but I'm wondering.

This is intended. We don't know if the version is meant to be versioned until we run it and try to query the gRPC endpoint for getting the version. If it fails, we assume the plugin is unversioned.

We could possibly tighten the error handling so that we only register it if we get the right gRPC error, and fail to register the plugin on other errors.

@fairclothjm
Copy link
Contributor Author

@maxcoulombe

Is this intended? Should the plugin addition/registration operation fail entirely if we expect a version but fail to retrieve it? Maybe that's lenient for backward compatibility or something but I'm wondering.

Yes, I believe it is for backwards compat but also plugins can self-report their version. We make a best effort to get the plugin version on registration but we don't fail the request if we can't.

@fairclothjm
Copy link
Contributor Author

backporting to 1.12.x and 1.13.x because this problem exists since plugin versioning was introduced.

@fairclothjm fairclothjm deleted the fix-external-plugin-test branch February 23, 2023 17:15
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.

3 participants