Skip to content

chore: improve diag-plugins and add system tests#3682

Merged
rina23q merged 1 commit intothin-edge:mainfrom
rina23q:improve/3646/improve-diag-plugins
Jun 18, 2025
Merged

chore: improve diag-plugins and add system tests#3682
rina23q merged 1 commit intothin-edge:mainfrom
rina23q:improve/3646/improve-diag-plugins

Conversation

@rina23q
Copy link
Copy Markdown
Member

@rina23q rina23q commented Jun 12, 2025

Proposed changes

According to the review 1.-4. points from #3646 (comment)

  • 01_tedge.sh collects tedge.toml and tedge config list output (->1.)
  • 01_tedge.sh collects also collectd mapper log (->2.)
  • 07_mosquitto.sh collects either journalctl output and mosquitto.log (->4.)

In addition, add system tests for all predefined diag plugins.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

#3646

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@reubenmiller reubenmiller added theme:troubleshooting Theme: Troubleshooting and remote control skip-release-notes Don't include the ticket in the auto generated release notes labels Jun 13, 2025
@rina23q rina23q had a problem deploying to Test Pull Request June 13, 2025 11:17 — with GitHub Actions Failure
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

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

Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

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

The changes look fine.

But, we'll have to extend the tedge_diag_collect test to do deeper validations beyond the presence of the output.log files for each plugin, bbut also validate what's collected by the factory plugins as well, so that changes like these can be easily validated. We probably don't need to validate each and every line of the collected logs, but some basic validation like the presence of a non-empty file with the expected starting line or something like that would suffice. For static files like tedge.toml, they can be compared for equality as well.

@rina23q
Copy link
Copy Markdown
Member Author

rina23q commented Jun 16, 2025

The changes look fine.

But, we'll have to extend the tedge_diag_collect test to do deeper validations beyond the presence of the output.log files for each plugin, bbut also validate what's collected by the factory plugins as well, so that changes like these can be easily validated. We probably don't need to validate each and every line of the collected logs, but some basic validation like the presence of a non-empty file with the expected starting line or something like that would suffice. For static files like tedge.toml, they can be compared for equality as well.

I would go to create another robot file to test the predefined plugins. I think what missing is, the test coverage of the predefined plugins. Since we ship them officially, I understand we need to test and guarantee them.

By the way, the general existence of output.log is covered by this Rust unit test. So, I wouldn't focus on in a general manner.

let log_path = command.diag_dir.join("plugin_a").join("output.log");
assert!(log_path.exists());

@rina23q rina23q force-pushed the improve/3646/improve-diag-plugins branch from 09d5ee5 to 2cd9a2d Compare June 16, 2025 16:05
@rina23q rina23q had a problem deploying to Test Pull Request June 16, 2025 16:05 — with GitHub Actions Failure
@rina23q rina23q requested a review from a team as a code owner June 16, 2025 16:07
@rina23q rina23q had a problem deploying to Test Pull Request June 16, 2025 16:07 — with GitHub Actions Failure
@rina23q rina23q had a problem deploying to Test Pull Request June 16, 2025 16:17 — with GitHub Actions Failure
@rina23q rina23q temporarily deployed to Test Pull Request June 16, 2025 16:33 — with GitHub Actions Inactive
@rina23q rina23q changed the title chore: improve diag-plugins fix: improve diag-plugins and add system tests Jun 16, 2025
@rina23q rina23q changed the title fix: improve diag-plugins and add system tests chrore: improve diag-plugins and add system tests Jun 16, 2025
@rina23q rina23q changed the title chrore: improve diag-plugins and add system tests chore: improve diag-plugins and add system tests Jun 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 16, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
649 0 3 649 100 1h49m9.871782999s

Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

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

Happy to approve with some test coverage improvements.

Custom Suite Setup
Setup
Execute Command mkdir -p /results
Start Service tedge-mapper-collectd
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.

Is there possibly a race here? Are the tests assuming the diagnostic collection happens after tedge-mapper-collectd publishes something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nope, tedge-mapper-collectd doesn't have to publish something. As long as some content is logged in journalctl, it's fine. So even this line, indicating the service is starting, is enough.

Jun 16 16:01:26 c2e84027fd54 systemd[1]: Starting tedge-mapper-collectd.service - tedge-mapper-collectd converts Thin Edge JSON measurements to Cumulocity JSON format....

Copy link
Copy Markdown
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

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

LGTM

File Size Is Not Zero ${log_name}
END

Log Should Contain tedge-agent.log Starting tedge-agent.service
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.

The earlier File Size Is Not Zero check is redundant now, as we're checking the content itself here.

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.

Though one advantage to checking the file size is zero is that it would produce a more meaningful error if the file is empty (e.g. "File is empty" rather than "File does not contain "xxxx")

Copy link
Copy Markdown
Member Author

@rina23q rina23q Jun 18, 2025

Choose a reason for hiding this comment

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

Though one advantage to checking the file size is zero is that it would produce a more meaningful error if the file is empty (e.g. "File is empty" rather than "File does not contain "xxxx")

Exactly this is the reason why I kept it. Also, it just calls test -s xxx, so it should be a light job and finish quickly.

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.

In that case I'd have done the File Size Is Not Zero from the Log Should Contain function itself. But anyway, minor thing.

Comment on lines +44 to 46
if command -V journalctl >/dev/null 2>&1; then
mosquitto_journal
mosquitto_log
else
echo "mosquitto not found" >&2
mosquitto_log
fi
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.

We'll need to change this logic to check both locations, journald logs and the default location of the mosquitto file log, as you can configure mosquitto to log to file instead of syslog (journald) even if you have journalctl installed.

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller Jun 18, 2025

Choose a reason for hiding this comment

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

So just move the "mosquitto_log" out of the journalctl if/else condition.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 5a88ac5

Copy link
Copy Markdown
Contributor

@reubenmiller reubenmiller left a comment

Choose a reason for hiding this comment

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

Approved

@rina23q rina23q force-pushed the improve/3646/improve-diag-plugins branch from 5a88ac5 to a9fcb3b Compare June 18, 2025 12:16
@rina23q rina23q had a problem deploying to Test Pull Request June 18, 2025 12:16 — with GitHub Actions Failure
* 01_tedge.sh collects tedge.toml, tedge config list output, and
tedge-mapper-collectd log
* 07_mosquitto.sh collects mosquitto.log and journal log
* Rename CONFIG_DIR to TEDGE_CONFIG_DIR in diag plugins
* Add system tests for all predefined diag plugins

Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
@rina23q rina23q force-pushed the improve/3646/improve-diag-plugins branch from a9fcb3b to a7b70ba Compare June 18, 2025 12:22
@rina23q rina23q temporarily deployed to Test Pull Request June 18, 2025 12:22 — with GitHub Actions Inactive
@rina23q rina23q enabled auto-merge June 18, 2025 12:24
@rina23q rina23q added this pull request to the merge queue Jun 18, 2025
Merged via the queue into thin-edge:main with commit 1609634 Jun 18, 2025
34 checks passed
@rina23q rina23q deleted the improve/3646/improve-diag-plugins branch August 8, 2025 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-release-notes Don't include the ticket in the auto generated release notes theme:troubleshooting Theme: Troubleshooting and remote control

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants