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

NAS-130242 / 24.10 / improve test_002 #14079

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Loading