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

Truncate excessively large log output in large collections #265

Merged
merged 1 commit into from Sep 30, 2022

Conversation

mdedetrich
Copy link
Collaborator

About this change - What it does

Overrides the default scalatest prettifier to one that truncates in the case of having excessively large collections

Why this way

Currently we have the issue where if one of the S3 tests fails then it creates an excessively large test output (example https://github.com/aiven/guardian-for-apache-kafka/runs/7500976439?check_suite_focus=true) due to the fact that we create very large collections (i.e. many megs in size). Overridding the prettifier with Prettifier.truncateAt allows to limit the size of the collection.

Note that scalatest will still print the initial seed that caused a failure so its still possible to recreate the test scenario without having to see the generated dataset.

@mdedetrich mdedetrich force-pushed the truncate-large-collection-logs branch 2 times, most recently from 02697bb to 6a37c9e Compare August 3, 2022 22:16
@coveralls
Copy link

coveralls commented Aug 3, 2022

Pull Request Test Coverage Report for Build 3156846522

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage remained the same at 75.844%

Files with Coverage Reduction New Missed Lines %
core-s3/src/main/scala/io/aiven/guardian/kafka/s3/Config.scala 1 82.98%
Totals Coverage Status
Change from base Build 3138762884: 0.0%
Covered Lines: 292
Relevant Lines: 385

💛 - Coveralls

@mdedetrich mdedetrich marked this pull request as draft August 4, 2022 11:00
@mdedetrich mdedetrich added the upstream Issues that require changes/co-operation with upstream libraries/projects label Aug 4, 2022
@mdedetrich
Copy link
Collaborator Author

While using Prettifier.truncateAt is the correct change for the problem, unfortunately the current implementation of Prettifier.truncateAt doesn't work if the generated collections are inside a case class. PR has been submitted upstream at scalatest/scalatest#2155 to solve the issue.

@mdedetrich mdedetrich force-pushed the truncate-large-collection-logs branch from 6a37c9e to 90a84f3 Compare August 8, 2022 14:07
@mdedetrich mdedetrich force-pushed the truncate-large-collection-logs branch from 90a84f3 to a3ec07a Compare August 19, 2022 21:47
@mdedetrich mdedetrich marked this pull request as ready for review September 30, 2022 06:52
@mdedetrich
Copy link
Collaborator Author

mdedetrich commented Sep 30, 2022

PR is now ready to review since new scalatest has been released fixing the problem mentioned at #265 (comment) (see scalatest/scalatest#2155 (comment)).

You can see a result of the truncation here when I deliberately make a test fail.

TestFailedException was thrown during property evaluation.
  Message: The future returned an exception of type: io.aiven.guardian.kafka.s3.S3Spec$DownloadNotReady, with message: Download not ready, current state is .
  Location: (RealS3BackupClientSpec.scala:142)
  Occurred when passed generated values (
    arg0 = KafkaDataInChunksWithTimePeriod(List(List(ReducedConsumerRecord(lQj-.3y_-q.6-_4.7G.0-.x_-.j.--.0O_-9-_.3S-171_-8-_Fs.5_.7_-_.e.r..3-ub_9.-24.j__-4__.m.O1.48.._._-.n--.U.74_M6.m7-8_7-L_f.2p-k.Z._Z_T_.-_._F-.._2_5.22_p,0,0,Some(bA==),bkNRbHJYTnZQanZtY1JWd1dDZkJpRnNjamt3THJQSERzTWNJb1JFV3lGaGlTcnduWGdJWExPbQ==,1,CreateTime), ReducedConsumerRecord(lQj-.3y_-q.6-_4.7G.0-.x_-.j.--.0O_-9-_.3S-171_-8-_Fs.5_.7_-_.e.r..3-ub_9.-24.j__-4__.m.O1.48.._._-.n--.U.74_M6.m7-8_7-L_f.2p-k.Z._Z_T_.-_._F-.._2_5.22_p,0,1,Some(bA==),emtDbGlsenlheFBRc2duSHZLWGJLU1R2VFJabUVDVURCbw==,3,CreateTime), ReducedConsumerRecord(lQj-.3y_-q.6-_4.7G.0-.x_-.j.--.0O_-9-_.3S-171_-8-_Fs.5_.7_-_.e.r..3-ub_9.-24.j__-4_<...>ducedConsumerRecord(Mx5.K-7--F.4a_-.-8-D.-K.-2_.t-..3.pR6-.._d--G-..0.1A-1f_-x.L8-....-2pN3._A2_._V.,0,7046,Some(Rw==),b3JUQllKa1BXdVdHdUNaR1pnVVFxcXhxQld5RGhlUlVNSFZmdVVEaQ==,34263,CreateTime), ReducedConsumerRecord(Mx5.K-7--F.4a_-.-8-D.-K.-2_.t-..3.pR6-.._d--G-..0.1A-1f_-x.L8-....-2pN3._A2_._V.,0,7047,Some(Rw==),ek9jbGxBTk1vc3JlcU94cFVIc2NOTGRQZWxFWVlJTENkRVJqeVZGbXpkWnl2WGFITVZGTkRLUlVpUm5lZU5oUmRXV2N3dFVFcGxrQnRwdA==,34266,CreateTime), ReducedConsumerRecord(Mx5.K-7--F.4a_-.-8-D.-K.-2_.t-..3.pR6-.._d--G-..0.1A-1f_-x.L8-....-2pN3._A2_._V.,0,7048,Some(Rw==),dw==,34267,CreateTime))),34268 milliseconds),
    arg1 = S3(guardian-gepzrk2-glrmd2tnumltte-hxnagmzxjger9yd4,None,RestartSettings(minBackoff=5 milliseconds,maxBackoff=10 seconds,randomFactor=0.2,maxRestarts=2147483647,maxRestartsWithin=5 milliseconds)),
    arg2 = "" // 2 shrinks
  )
Init Seed: 1907363718961213527

@mdedetrich mdedetrich merged commit 33bb4af into main Sep 30, 2022
@mdedetrich mdedetrich deleted the truncate-large-collection-logs branch September 30, 2022 07:37
@mdedetrich mdedetrich mentioned this pull request Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Issues that require changes/co-operation with upstream libraries/projects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants