-
Notifications
You must be signed in to change notification settings - Fork 4
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
Issue #170 Enhance ConnectorStore loading system #176
Issue #170 Enhance ConnectorStore loading system #176
Conversation
* Internalized external files. * Updated Windows and OsCommand extensions in order to correctly fetch embedded files.
* Updated http extension to manage header and body using embedded files.
* Formatted code. * Updated unit tests in the agent to use real extensions.
* Updated extension unit tests.
fearture/issue-170-enhance-metricshub-connectorstore-loading-system
* Fixed JUnit tests on oscommand extension
* Fixed formatting and removed useless imports
* Decreased coverage on metricshub-agent due to code removal
fearture/issue-170-enhance-metricshub-connectorstore-loading-system
* Added unit tests for EmbeddedFile methods. * Update README.md * Enhanced log message in EmbeddedFileHelper
* Managed connector store extension providers
@@ -150,7 +150,7 @@ | |||
<limit> | |||
<counter>COMPLEXITY</counter> | |||
<value>COVEREDRATIO</value> | |||
<minimum>0.51</minimum> | |||
<minimum>0.50</minimum> |
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.
Why we decreased the test coverage percentage here ?
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.
Even with new tests the coverage decreased, I will look into it.
*/ | ||
public static String getExtension(String filename) { | ||
// Find the last index of '.' in the filename | ||
int lastIndex = filename.lastIndexOf('.'); |
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.
could be final
*/ | ||
public static String getBaseName(String filename) { | ||
// Find the last index of '.' in the filename | ||
int lastIndex = filename.lastIndexOf('.'); |
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.
could be final
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 looks beautiful! Well done! I only have a question about the id
of embedded files, and whether we can ditch it. Thank you! 😊
try { | ||
return File.createTempFile("SEN_Embedded_", extension); | ||
return File.createTempFile("SEN_Embedded_" + baseName, extension); |
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.
we don't need SEN_Embedded_
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.
Yes, maybe we need metricshub_embedded_
as prefix.
The reason we have this prefix is to easily identify the files in case of an issue. The user or support can then efficiently clean everything in the user's directory, and possibly even on a production machine where files could fill up the filesystem, which could become critical.
void testDescription() { | ||
assertEquals( | ||
"EmbeddedFile 1: script.bat", | ||
EmbeddedFile.builder().content("value".getBytes()).filename("script.bat").id(1).build().description() |
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.
Is the id
really required? Wouldn't the name be sufficient? (I'm asking because I'm may be misunderstanding something)
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 name alone is insufficient since different files with the same name can exist in various subdirectories and be referenced in the connector. Therefore, a unique ID is necessary. Additionally, the global index of the embedded files should be represented using integer values instead of strings.
void testGetContentAsString() { | ||
final EmbeddedFile embeddedFile = EmbeddedFile | ||
.builder() | ||
.content("value".getBytes()) |
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.
You will need to specify the Charset in getBytes()
to make sure the tests run properly without relying with the JRE and system configuration.
assertEquals(uriStrExpected, result.toString()); | ||
final String actualAwkScriptNormalized = result.getContentAsString().replaceAll("\r\n", "").replaceAll("\n", ""); | ||
final String expected = | ||
""" |
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.
Urgl...
*/ | ||
private String reference; | ||
private Integer id; |
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.
What's the requirement for this id
? Can we avoid it?
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 is the unique id of the embedded file, this will handle the case where different embedded files have the same name, and enhance slightly the memory of the global embedded file Map<Integer, EmbeddedFile>.
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 is generated by the connector parser 😉.
* Increased coverage on OsCommand and Http extension * Fixed Timeout deserialization on the configuration objects.
* Cleaned-up Constants.java in the engine. * Replaced temp file prefix `SEN_Embedded_` with `metricshub_embedded_`.
* Added note to `README.md`.
Overview