Skip to content

ANDROID-16807 Add waitForCondition at loggerazzi logs comparation#11

Merged
dpastor merged 4 commits into
mainfrom
wait_for_logs
Sep 17, 2025
Merged

ANDROID-16807 Add waitForCondition at loggerazzi logs comparation#11
dpastor merged 4 commits into
mainfrom
wait_for_logs

Conversation

@dpastor

@dpastor dpastor commented Sep 15, 2025

Copy link
Copy Markdown

🎟️ Jira ticket

ANDROID-16807

🥅 What's the goal?

Add some time after test ends to try to wait for logs to be the expected one, if after 5 seconds this still fails, test would be failed.

🚧 How do we do it?

  • Just add a waiting mechanism for logs comparation

📘 Documentation changes?

  • No docs to update nor create

🧪 How can I test this?

  • Run instrumentation tests inside repository

@dpastor
dpastor requested review from a team, Copilot, dnieto-r and hjorrod and removed request for a team September 15, 2025 16:30
compareFile.writeText(comparationResult.result!!)
throw AssertionError("Logs do not match:\n${comparationResult.result}")
}
recordedLogs = comparationResult.recordedLogs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Dump the latest logs obtained.

Comment on lines +75 to +78
val log = recordedLogs.joinToString("\n") { stringMapper.fromLog(it) }
val testFile = File(recordedDir, fileName)
testFile.createNewFile()
testFile.writeText(log)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Just moved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a retry mechanism with timeout to the LoggerazziRule test comparison logic. Instead of immediately failing when logs don't match the golden file, the code now waits up to 5 seconds, checking every 500ms for the logs to eventually match the expected output.

Key changes:

  • Refactored log comparison to use a polling mechanism with configurable timeout
  • Introduced a ComparationResult data class to encapsulate comparison results
  • Added constants for polling interval (500ms) and timeout (5 seconds)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated

@nimeacuerdo nimeacuerdo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add this feature to the readme :)

@dpastor

dpastor commented Sep 17, 2025

Copy link
Copy Markdown
Author

I would add this feature to the readme :)

-> d9e584e

@dnieto-r dnieto-r left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM! Just a couple of questions

Comment thread loggerazzi/src/main/java/com/telefonica/loggerazzi/LoggerazziRule.kt Outdated
@dpastor
dpastor merged commit fdc8370 into main Sep 17, 2025
1 check passed
@dpastor
dpastor deleted the wait_for_logs branch September 17, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants