Skip to content

Commit

Permalink
test_upgrade: modify test_upgrade_package to run for more sources (#883)
Browse files Browse the repository at this point in the history
This allows us to use it when validating packages from -proposed (and
PPAs etc.).
  • Loading branch information
OddBloke authored Apr 26, 2021
1 parent 02db2c3 commit 5c740dc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions tests/integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
get_validated_source,
session_start_time,
)
from tests.integration_tests.instances import CloudInitSource


log = logging.getLogger('integration_testing')

UNSUPPORTED_INSTALL_METHOD_MSG = (
"Install method '{}' not supported for this test"
)
USER_DATA = """\
#cloud-config
hostname: SRU-worked
Expand Down Expand Up @@ -57,12 +59,10 @@ def _restart(instance):


@pytest.mark.sru_2020_11
def test_upgrade(session_cloud: IntegrationCloud):
def test_clean_boot_of_upgraded_package(session_cloud: IntegrationCloud):
source = get_validated_source(session_cloud)
if not source.installs_new_version():
pytest.skip("Install method '{}' not supported for this test".format(
source
))
pytest.skip(UNSUPPORTED_INSTALL_METHOD_MSG.format(source))
return # type checking doesn't understand that skip raises

launch_kwargs = {
Expand Down Expand Up @@ -104,18 +104,21 @@ def test_upgrade(session_cloud: IntegrationCloud):

@pytest.mark.ci
@pytest.mark.ubuntu
def test_upgrade_package(session_cloud: IntegrationCloud):
if get_validated_source(session_cloud) != CloudInitSource.DEB_PACKAGE:
not_run_message = 'Test only supports upgrading to build deb'
def test_subsequent_boot_of_upgraded_package(session_cloud: IntegrationCloud):
source = get_validated_source(session_cloud)
if not source.installs_new_version():
if os.environ.get('TRAVIS'):
# If this isn't running on CI, we should know
pytest.fail(not_run_message)
pytest.fail(UNSUPPORTED_INSTALL_METHOD_MSG.format(source))
else:
pytest.skip(not_run_message)
pytest.skip(UNSUPPORTED_INSTALL_METHOD_MSG.format(source))
return # type checking doesn't understand that skip raises

launch_kwargs = {'image_id': session_cloud.released_image_id}

with session_cloud.launch(launch_kwargs=launch_kwargs) as instance:
instance.install_deb()
instance.install_new_cloud_init(
source, take_snapshot=False, clean=False
)
instance.restart()
assert instance.execute('cloud-init status --wait --long').ok

0 comments on commit 5c740dc

Please sign in to comment.