Skip to content

Commit

Permalink
basic: 098 - wait for provider sync completion event
Browse files Browse the repository at this point in the history
Engine periodically invokes a sync request to fetch updates from ovn
provider. In test_use_ovn_provider the sync is disabled as part of the
test but if a sync request has not completed before the disable then a
race situation is created which causes failures at various stages in the
test.
To avoid such a race, a wait on the completion of the sync action is
added after disabling it. Either the sync has completed before the wait
or the wait should catch it as 10 seconds is long enough for the whole
round trip of the sync request.

Change-Id: I68dfd4512ccd5de2c1e72b0f638a10b101b86652
Signed-off-by: Eitan Raviv <[email protected]>
  • Loading branch information
erav committed Feb 24, 2022
1 parent 91bcb0a commit 6250f3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from ovirtsdk4 import types

from ost_utils import assert_utils
from ost_utils import engine_utils
from ost_utils import network_utils
from ost_utils import test_utils
from ost_utils import versioning
Expand All @@ -24,6 +25,7 @@
VM0_NAME = 'vm0'
CLUSTER_NAME = 'test-cluster'
IFACE_NAME = 'eth2'
PROVIDER_SYNCHRONIZED_PERFORMED_EVENT_ID = 217

OVN_PROVIDER_TOKEN_URL = 'https://{hostname}:35357/v2.0/tokens/'
OVN_PROVIDER_NETWORKS_URL = 'https://{hostname}:9696/v2.0/networks/'
Expand Down Expand Up @@ -373,6 +375,7 @@ def test_use_ovn_provider(engine_api, engine_ip_url, engine_full_username, engin
_validate_db_empty(token_id, engine_ip_url)

with _disable_auto_sync(engine_api, provider_id):
engine_utils.wait_for_event_or_expire(engine, PROVIDER_SYNCHRONIZED_PERFORMED_EVENT_ID, 10)
network1_id = _add_network(
token_id,
engine_ip_url,
Expand Down
8 changes: 8 additions & 0 deletions ost_utils/engine_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def wait_for_event(engine, event_id, timeout=assert_utils.LONG_TIMEOUT):
)


def wait_for_event_or_expire(engine, event_id, timeout=assert_utils.LONG_TIMEOUT):
try:
with wait_for_event(engine, event_id, timeout):
pass
except AssertionError:
pass


def get_jobs_statuses(engine, correlation_id):
# Gets a list of jobs statuses by the specified correlation id.
jobs = engine.jobs_service().list(search=f'correlation_id={correlation_id}')
Expand Down

0 comments on commit 6250f3f

Please sign in to comment.