Skip to content

PB-298: Fix race condition when exporting/saving kml#649

Merged
ltshb merged 5 commits intodevelopfrom
bug-drawing-e2e-ci
Feb 21, 2024
Merged

PB-298: Fix race condition when exporting/saving kml#649
ltshb merged 5 commits intodevelopfrom
bug-drawing-e2e-ci

Conversation

@ltshb
Copy link
Contributor

@ltshb ltshb commented Feb 21, 2024

To export a kml, openlayer requires the icon size in order to compute the
scale. If the icon has not yet been loaded when generating the style then
the icon scale would be computed with a default size of 64px.

The last commit tried to solve this issue in cypress test, but unfortunately
waiting on the icon to be loaded did not always solved the race condition.

I could not find a better way to ensure this as settings the size when
generating the icon style.

This solve temporarly the issue, but in the future we should get the size
from the backend with the others icon metadata.

The icon size test did failed time to time. This was due to a race condition.

The icon scale in KML is set by openlayer and uses a scale factor based on the
icon size. Now if the icon has not yet be loaded during the KML write, openlayer
takes a default size of 64 pixel which defer from our icon size of 48 pixel.
Due to this the icon scale of a large icon was 2 instead of 1.5.

We solve this race condition by waiting on all icons being loaded before doing
the icon size changes.

NOTE this is not an issue in real life as the save drawing is always delayed
at least 2 seconds which let plenty of time to load the icons. In cypress this
delay was reduced to speed up testing.

Also did small test improvements:

  • Remove the useless wait on icon, changing icon size don't trigger any new
    icon request anymore as all icon are loading from the backend using the same
    size.

  • Remove a wrong closing action, at this time of the test the icon size selector
    is already closed.

Test link

On the CI this E2E test is sometimes failing in the icon size check in KML
payload. Although this commit should not fix this issue, it removes some
bad practice of `force: true` flag and make sure that element are visible before
clicking which is a good practice (avoiding clicking on element not yet fully
rendered and avoiding race condition).
Remove the useless wait on icon, changing icon size don't trigger any new
icon request anymore as all icon are loading from the backend using the same
size.

Remove a wrong closing action, at this time of the test the icon size selector
is already closed.
@github-actions github-actions bot added the bug label Feb 21, 2024
@cypress
Copy link

cypress bot commented Feb 21, 2024

Passing run #654 ↗︎

0 176 21 0 Flakiness 0

Details:

Fix race condition when exporting/saving kml
Project: web-mapviewer Commit: 85dedafd3b
Status: Passed Duration: 04:42 💡
Started: Feb 21, 2024 9:32 AM Ended: Feb 21, 2024 9:36 AM

Review all test suite changes for PR #649 ↗︎

The icon size test did failed time to time. This was due to a race condition.

The icon scale in KML is set by openlayer and uses a scale factor based on the
icon size. Now if the icon has not yet be loaded during the KML write, openlayer
takes a default size of 64 pixel which defer from our icon size of 48 pixel.
Due to this the icon scale of a large icon was 2 instead of 1.5.

We solve this race condition by waiting on all icons being loaded before doing
the icon size changes.

NOTE this is not an issue in real life as the save drawing is always delayed
at least 2 seconds which let plenty of time to load the icons. In cypress this
delay was reduced to speed up testing.
@ltshb ltshb changed the title Fix flaky e2e drawing test Fix cypress e2e race condition in drawing icon size test Feb 21, 2024
@ltshb ltshb marked this pull request as ready for review February 21, 2024 07:05
To export a kml, openlayer requires the icon size in order to compute the
scale. If the icon has not yet been loaded when generating the style then
the icon scale would be computed with a default size of 64px.

The last commit tried to solve this issue in cypress test, but unfortunately
waiting on the icon to be loaded did not always solved the race condition.

I could not find a better way to ensure this as settings the size when
generating the icon style.

This solve temporarly the issue, but in the future we should get the size
from the backend with the others icon metadata.
@ltshb ltshb force-pushed the bug-drawing-e2e-ci branch from c57e920 to 85dedaf Compare February 21, 2024 09:28
@ltshb ltshb changed the title Fix cypress e2e race condition in drawing icon size test Fix race condition when exporting/saving kml Feb 21, 2024
@ltshb ltshb requested a review from pakb February 21, 2024 09:43
Copy link
Contributor

@pakb pakb left a comment

Choose a reason for hiding this comment

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

👍

@ltshb ltshb merged commit fa54657 into develop Feb 21, 2024
@ltshb ltshb deleted the bug-drawing-e2e-ci branch February 21, 2024 10:02
@cypress cypress bot mentioned this pull request Feb 21, 2024
@ltshb ltshb changed the title Fix race condition when exporting/saving kml PB-298: Fix race condition when exporting/saving kml Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants