-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |