Skip to content

Commit

Permalink
improve test_002 (#14079)
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo authored Jul 25, 2024
1 parent ee241aa commit 582182f
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions tests/api2/test_002_system_license.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
import os
import sys
import time
sys.path.append(os.getcwd())

import pytest

from auto_config import ha, ha_license
from middlewared.test.integration.utils import call

from middlewared.test.integration.utils import client

# Only read the test on HA
if ha:
def test_apply_and_verify_license():
with client() as c:
if ha_license:
_license_string = ha_license
else:
with open(os.environ.get('license_file', '/root/license.txt')) as f:
_license_string = f.read()
@pytest.mark.skipif(not ha, reason='Test only valid for HA')
def test_apply_and_verify_license():
if ha_license:
_license_string = ha_license
else:
with open(os.environ.get('license_file', '/root/license.txt')) as f:
_license_string = f.read()

# apply license
c.call('system.license_update', _license_string)
# apply license
call('system.license_update', _license_string)

# verify license is applied
assert c.call('failover.licensed') is True
# verify license is applied
assert call('failover.licensed') is True

retries = 30
sleep_time = 1
for i in range(retries):
if c.call('failover.call_remote', 'failover.licensed') is False:
# we call a hook that runs in a background task
# so give it a bit to propagate to other controller
# furthermore, our VMs are...well...inconsistent to say the least
# so sometimes this is almost instant while others I've 10+ secs
time.sleep(sleep_time)
else:
break
else:
assert False, f'Timed out after {sleep_time * retries}s waiting on license to sync to standby'
retries = 30
sleep_time = 1
for i in range(retries):
if call('failover.call_remote', 'failover.licensed') is False:
# we call a hook that runs in a background task
# so give it a bit to propagate to other controller
time.sleep(sleep_time)
else:
break
else:
assert False, f'Timed out after {sleep_time * retries}s waiting on license to sync to standby'

0 comments on commit 582182f

Please sign in to comment.