Skip to content

tests: Make Tests.Cumulocity.Software Management.Software suite faster#4237

Open
Bravo555 wants to merge 2 commits into
thin-edge:mainfrom
Bravo555:tests/make-software-suite-faster
Open

tests: Make Tests.Cumulocity.Software Management.Software suite faster#4237
Bravo555 wants to merge 2 commits into
thin-edge:mainfrom
Bravo555:tests/make-software-suite-faster

Conversation

@Bravo555

@Bravo555 Bravo555 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Proposed changes

Tests.Cumulocity.Software Management.Software suite is our slowest test suite, running at over 10 minutes on the test runner, I thought to try to speed it up a bit to get some sense what kind of changes would be necessary in other suites to speed up the entire test suite. Currently it runs in about 30 minutes, I think it would be neat if it ran closer to 5-10 minutes.

This PR speeds up software test suite by:

  • rewriting some tests that spawn new containers to not spawn + restore previous state
  • removing some Sleep keywords that were useless because keywords after retry anyway

On my pc

before: 00:03:49.143
after: 00:01:33.541
diff: 00:02:16 (-59%)

on test runner

before: 00:10:41.672
(projected) after: 00:06:18

We're running the suites in parallel, so it will have very limited impact on total runtime, but after doing it I have a better idea of what type of changes would be required to speed up other tests. Apart from repeating these changes for other suites, one other speedup would be to try to replace retry mechanisms that always wait 2s with blocking mechanisms that return as soon as assertion succeeds. In some tests there are multiple of these kinds of checks, for example in test case Operation gets updated regardless of the order of the creation time we hit a 2s retry 4 times, so 8s in a test that takes 14s (on my machine), little over 50%, is spent waiting, so I expect it to also inflate runtime of other suites a bit.

Though speeding it up does take a lot of time, so next time I'll try to task other suites to an AI model.

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


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

Bravo555 added 2 commits July 2, 2026 16:24
Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
- rewrite some tests that spawn new containers to not spawn + restore
  previous state
- removed some Sleep keywords that were useless because keywords after
  retry anyway

Signed-off-by: Marcel Guzik <marcel.guzik@cumulocity.com>
@Bravo555 Bravo555 requested a review from a team as a code owner July 2, 2026 16:41
@Bravo555 Bravo555 added theme:software Theme: Software management theme:testing Theme: Testing labels Jul 2, 2026
@Bravo555 Bravo555 temporarily deployed to Test Pull Request July 2, 2026 16:41 — with GitHub Actions Inactive
@Bravo555 Bravo555 changed the title tests: Make software suite faster tests: Make Tests.Cumulocity.Software Management.Software suite faster Jul 2, 2026
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

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.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
947 0 7 947 100 2h43m12.397813999s

@rina23q rina23q left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice experiment.

I think one problem of this test file is mixed of 3 level things:

  1. testing against c8y with legacy software management
  2. testing against c8y with advanced software management
  3. testing locally, without using c8y

I agree that the previous setup, creating a test container per each test is time consuming and too much costs.
However, I sometimes think we put too many tests in one robot file. For this case, if we split the file into three (or at least two, covering point 1&2-c8y and point 3-local) files, maybe the tests would look short and easy to read.

*** Test Cases ***
Supported software types should not be declared during startup when disabled
# This Setup could be removed and test could run on a suite device, making it faster
# if we either actively sent an empty software type fragment on startup (currently we just don't send anything)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having the c8y_SupportedSoftwareTypes fragment in ManagedObject triggers filtering out "Installed Software" list in the "Software" tab. To avoid an unexpected surprise, c8y.software_management.with_types is set to false by default.

I tested how to reset the fragment in c8y. We can send either JSON over MQTT or SmartREST.

  • tedge mqtt pub c8y/inventory/managedObjects/update/${DEVICE_SN} '{"c8y_SupportedSoftwareTypes":null}'
  • tedge mqtt pub c8y/s/us 143
    After the MQTT request is sent, if we ensure the fragment does not exist in MO, this is the clean enough state for this test.

In short, yes, we can remove this Setup by replacing it as I wrote above.

Comment on lines +309 to +312
Set Managed Object
[Arguments] ${device_sn}
Cumulocity.Set Managed Object ${device_sn}
ThinEdgeIO.Set Device Context ${device_sn}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(trivial) I think we can promote this to library level 🤔


*** Keywords ***
Custom Suite Setup
${device_sn}= Custom Setup With Software Types Enabled

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(note) This change makes most of tests run with c8y.software_management.with_types = true, which is against default. Previously, they were tested with the default (false) value. Eventually, this value doesn't affect tests unless it uses advanced software management.

Comment on lines 271 to +276

Sleep 5s reason=Given mapper a chance to react, if it does not react with 5 seconds it never will
${retained_message}= Execute Command
... tedge mqtt sub --no-topic '${topic}' --duration 1
... ignore_exit_code=${True}
... strip=${True}
... timeout=5

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 think this change is problematic as you might get the message before it has been cleared by the mapper, so the static sleep was in-place to ensure the mapper is not clearing the message. Removing the timeout means that the tedge mqtt sub might see the previously manually posted message before the tedge-mapper reacts to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:software Theme: Software management theme:testing Theme: Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants