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

tests: fix/optimise download-timeout spread test #13967

Merged
merged 1 commit into from
May 20, 2024

Conversation

MiguelPires
Copy link
Contributor

The download-timeout test was taking over 10min to complete due to a couple of issues. The first one is that there was a typo in the environment variables that controlled the measurement window so the timeout was still the default of 5min (the test downloads twice). Setting it correctly cut the execution time for one of the downloads but not the other strangely. It turns out that the test was creating a override file that was sorted before the other existing override (systemd applies sorts override files). Fixing this and lowering the timeout to 15s cuts the running time from 10min to 30s. I wanted to add a log when the env var was set so we could check it in the test but this happens in an init() and I don't think the logger is set up by then.

The download-timeout test was taking over 10min to complete due to a couple of
issues. The first one is that there was a typo in the environment variables
that controlled the measurement window so the timeout was still the default of
5min (the test downloads twice). Setting it correctly cut the execution time
for one of the downloads but not the other strangely. It turns out that
the test was creating a override file that was sorted before the other
existing override (systemd applies env vars in order).  Fixing this and
lowering the timeout to 15s cuts the running time from 10min to 30s. I wanted
to add a log when the env var was set so we could check it in the test but
this happens in an `init()` and I don't think the logger is set up by then.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

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

Looks good :-)

@MiguelPires MiguelPires requested review from andrewphelpsj and bboozzoo and removed request for andrewphelpsj May 17, 2024 09:31
Environment=SNAP_DOWNLOAD_MEAS_WINDOW=${SNAP_DOWNLOAD_MEAS_WINDOW}
EOF
cp "$OVERRIDES_FILE" "$OVERRIDES_FILE".bak
sed "s/Environment=/Environment=SNAPD_MIN_DOWNLOAD_SPEED=${SNAPD_MIN_DOWNLOAD_SPEED} SNAPD_DOWNLOAD_MEAS_WINDOW=${SNAPD_DOWNLOAD_MEAS_WINDOW} /" -i "$OVERRIDES_FILE"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm this is changing an overrides file we created during prepare if I'm not mistaken. Wouldn't it be cleaner to add a separate file like the test did before, but make sure it's named such that it gets included after local.conf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is but the file is restored to its original state so it should be ok. I considered renaming the file but my concern was that something else would change and break this silently, eg. we rename local.conf to something that gets sorted after the override like snapd.conf (or worse, znapd.conf 😛). IIRC all other tests I found changed local.conf instead of creating overrides. But I could change it to z-env-override.conf and leave a comment saying that this is necessary and why

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see there are only 7 tests that seem to touch local.conf. How about we try to fix it for good then. Say we could go with something like 00-prepare.conf in prepare.sh, then each test could use a consistent 90-${SPREAD_TASK}.conf, this way the original file created during prepare does not get modified, the cleanup is easy and if something is not cleaned up we can tell which test left a file. (also writing an invariant check would be easy now, simply check 00-prepare.conf is the only file under /etc/systemd/system/snapd.service.d/. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This sounds like a great idea. Being able to check if any configuration files were left and knowing which test to blame seems very useful. I'll open a follow-up. thanks!

Copy link
Collaborator

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

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

LGTM, let's do the renaming exercise in a followup PR

@MiguelPires MiguelPires merged commit 7612b33 into snapcore:master May 20, 2024
47 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants