Skip to content

test: Files Historic Plugin Unit Tests Pt. 3 #1019

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

Merged

Conversation

ata-nas
Copy link
Contributor

@ata-nas ata-nas commented Apr 15, 2025

Reviewer Notes

  • part 3 of unit tests for the files historic plugin
  • some changes to the compress method for the ZSTD compression type for consistency with the wrapped stream method
  • additional tests for the change in the compress method

Related Issue(s)

Closes #1009

@ata-nas ata-nas added the pull request label to get past the "label required" check when no label is needed or appropriate. label Apr 15, 2025
@ata-nas ata-nas added this to the 0.9.0 milestone Apr 15, 2025
@ata-nas ata-nas self-assigned this Apr 15, 2025
@ata-nas ata-nas linked an issue Apr 15, 2025 that may be closed by this pull request
@ata-nas ata-nas changed the base branch from main to 505-plugins-services April 15, 2025 08:52
Comment on lines +93 to +109
// Seems that if we use Zstd.compress(data, DEFAULT_ZSTD_COMPRESSION_LEVEL);
// directly it will not produce the same result as wrapping
// a stream with the same compression level. For consistency,
// we need to use the same approach as the one used in the
// wrapStream method. This method is a convenience for
// compressing data in memory.
try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final OutputStream wrappedBaos = wrapStream(baos)) {
wrappedBaos.write(data);
wrappedBaos.close();
// close before return so that we are absolutely sure that
// all data is written including possible footer and others
yield baos.toByteArray();
} catch (final IOException e) {
throw new UncheckedIOException(e);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have introduced this change for consistency reasons. It seems that using the static method produces slightly different output than a wrapped stream would, even if using the same compression level. Is it ok to do this? Is there a better way?
cc: @jasperpotts @jsync-swirlds

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: after a discussion, let's revert this. The difference in bytes is probably because the static method call has more context than the streaming approach and this means that it can do a better job at compressing. This will produce different bytes at the end of the day. As far as the consistency concern, we should probably not take it into account as the library should be non deterministic, based on multiple factors. The proper way to assert would be to always uncompress the data and then juxtapose that against the expected.

@@ -133,7 +139,7 @@ public BlockAccessor blockAccessor(long blockNumber) {
*
* @return the minimum block number, or -1 if no block files are found
*/
public long minStoredBlockNumber() {
long minStoredBlockNumber() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor bug on line 163 (GH did not allow me to include int in the preview as I have not made changes there)

...
L:163    return Long.parseLong(fileName.substring(0, fileName.indexOf('.')));
...

(in the max method is the same). We are neglecting the "s" appended at the back of the filename (e.g. "10s.zip") which produces a number format exception.

  • Solution 1: handle with fileName.indexOf('s')
  • Solution 2: change the BlockPath resolution logic to exclude the "s"

Any opinions/preferences?

cc: @jsync-swirlds @jasperpotts @AlfredoG87 @Nana-EC @georgi-l95

Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove the s. I'd also remove the extra 0 characters and just have a single digit filename (regardless of grouping). We really shouldn't make reading these files manually "easy"; we don't want operators meddling in the filesystem, so why make it easier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: after a discussion, let's proceed with solution 1 for now, revisiting this later if we need to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#1027 is created for a future revisit if we decide.

ata-nas added 12 commits April 15, 2025 11:38
…the compress convenience method for the zstd compression type for consistency + tests

Signed-off-by: Atanas Atanasov <[email protected]>
Signed-off-by: Atanas Atanasov <[email protected]>
Signed-off-by: Atanas Atanasov <[email protected]>
…the end of zip file names

Signed-off-by: Atanas Atanasov <[email protected]>
@jasperpotts jasperpotts force-pushed the 1009-files-historic-plugin-unit-tests-pt-3 branch from eaa5b75 to dd6c2be Compare April 15, 2025 18:42
@jasperpotts jasperpotts marked this pull request as ready for review April 15, 2025 18:43
@jasperpotts jasperpotts requested review from a team as code owners April 15, 2025 18:43
@jasperpotts jasperpotts requested a review from AlfredoG87 April 15, 2025 18:43
@jasperpotts jasperpotts merged commit dafa9ad into 505-plugins-services Apr 15, 2025
7 of 10 checks passed
@jasperpotts jasperpotts deleted the 1009-files-historic-plugin-unit-tests-pt-3 branch April 15, 2025 18:43
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ava/org/hiero/block/node/base/CompressionType.java 85.71% 1 Missing ⚠️
...ck/node/blocks/files/historic/ZipBlockArchive.java 83.33% 0 Missing and 1 partial ⚠️
@@                    Coverage Diff                     @@
##             505-plugins-services    #1019      +/-   ##
==========================================================
+ Coverage                   77.30%   79.56%   +2.26%     
- Complexity                    737      748      +11     
==========================================================
  Files                          99       98       -1     
  Lines                        3256     3245      -11     
  Branches                      316      312       -4     
==========================================================
+ Hits                         2517     2582      +65     
+ Misses                        638      550      -88     
- Partials                      101      113      +12     
Files with missing lines Coverage Δ Complexity Δ
...ro/block/node/blocks/files/historic/BlockPath.java 100.00% <ø> (+45.00%) 9.00 <0.00> (+6.00)
...ava/org/hiero/block/node/base/CompressionType.java 96.55% <85.71%> (-3.45%) 11.00 <0.00> (ø)
...ck/node/blocks/files/historic/ZipBlockArchive.java 26.95% <83.33%> (+26.95%) 3.00 <0.00> (+3.00)

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jsync-swirlds jsync-swirlds restored the 1009-files-historic-plugin-unit-tests-pt-3 branch April 16, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull request label to get past the "label required" check when no label is needed or appropriate.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Files Historic Plugin Unit Tests Pt. 3
3 participants