diff --git a/functional_tests/features/storage_snapshots.feature b/functional_tests/features/storage_snapshots.feature index f371113e8..b56ad2bff 100644 --- a/functional_tests/features/storage_snapshots.feature +++ b/functional_tests/features/storage_snapshots.feature @@ -29,13 +29,13 @@ Scenario: Create a snapshot Then there should be 1 snapshot in the list Scenario: Configure snapshots - Given snapshots are configured with timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0, delete old software snapshots 15 - When I configure snapshots with timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1, delete old software snapshots 2 - Then snapshots should be configured with timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1, delete old software snapshots 2 + Given snapshots are configured with free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0 + When I configure snapshots with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1 + Then snapshots should be configured with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1 Scenario: Backup and restore snapshot - When I configure snapshots with timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0, delete old software snapshots 15 + When I configure snapshots with free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0 And I create a backup of the snapshot app data - And I configure snapshots with timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1, delete old software snapshots 2 + And I configure snapshots with free_space 20, timeline snapshots enabled, software snapshots enabled, hourly limit 3, daily limit 2, weekly limit 1, monthly limit 1, yearly limit 1 And I restore the snapshot app data backup - Then snapshots should be configured with timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0, delete old software snapshots 15 + Then snapshots should be configured with free_space 30, timeline snapshots disabled, software snapshots disabled, hourly limit 10, daily limit 3, weekly limit 2, monthly limit 2, yearly limit 0 diff --git a/functional_tests/step_definitions/system.py b/functional_tests/step_definitions/system.py index c3566c4b6..9f016508c 100644 --- a/functional_tests/step_definitions/system.py +++ b/functional_tests/step_definitions/system.py @@ -108,52 +108,54 @@ def verify_snapshot_count(browser, count): @given( parsers.parse( - 'snapshots are configured with timeline snapshots ' - '{timeline_enabled:w}, software snapshots {software_enabled:w}, hourly ' - 'limit {hourly:d}, daily limit {daily:d}, weekly limit {weekly:d}, ' - 'monthly limit {monthly:d}, yearly limit {yearly:d}, delete old ' - 'software snapshots {delete_old:d}')) -def snapshot_given_set_configuration(browser, timeline_enabled, + 'snapshots are configured with free_space {free_space:d}, timeline ' + 'snapshots {timeline_enabled:w}, software snapshots ' + '{software_enabled:w}, hourly limit {hourly:d}, daily limit {daily:d}' + ', weekly limit {weekly:d}, monthly limit {monthly:d}, yearly limit ' + '{yearly:d}')) +def snapshot_given_set_configuration(browser, free_space, timeline_enabled, software_enabled, hourly, daily, weekly, - monthly, yearly, delete_old): + monthly, yearly): timeline_enabled = (timeline_enabled == 'enabled') software_enabled = (software_enabled == 'enabled') - system.snapshot_set_configuration(browser, timeline_enabled, + system.snapshot_set_configuration(browser, free_space, timeline_enabled, software_enabled, hourly, daily, weekly, - monthly, yearly, delete_old) + monthly, yearly) @when( parsers.parse( - 'I configure snapshots with timeline snapshots {timeline_enabled:w}, ' + 'I configure snapshots with free_space {free_space:d}, ' + 'timeline snapshots {timeline_enabled:w}, ' 'software snapshots {software_enabled:w}, hourly limit {hourly:d}, ' 'daily limit {daily:d}, weekly limit {weekly:d}, monthly limit ' - '{monthly:d}, yearly limit {yearly:d}, delete old software snapshots ' - '{delete_old:d}')) -def snapshot_set_configuration(browser, timeline_enabled, software_enabled, - hourly, daily, weekly, monthly, yearly, - delete_old): + '{monthly:d}, yearly limit {yearly:d}')) +def snapshot_set_configuration(browser, free_space, timeline_enabled, + software_enabled, hourly, daily, weekly, + monthly, yearly): timeline_enabled = (timeline_enabled == 'enabled') software_enabled = (software_enabled == 'enabled') - system.snapshot_set_configuration(browser, timeline_enabled, + system.snapshot_set_configuration(browser, free_space, timeline_enabled, software_enabled, hourly, daily, weekly, - monthly, yearly, delete_old) + monthly, yearly) @then( parsers.parse( - 'snapshots should be configured with timeline snapshots ' - '{timeline_enabled:w}, software snapshots {software_enabled:w}, hourly ' - 'limit {hourly:d}, daily limit {daily:d}, weekly limit {weekly:d}, ' - 'monthly limit {monthly:d}, yearly limit {yearly:d}, delete old ' - 'software snapshots {delete_old:d}')) -def snapshot_assert_configuration(browser, timeline_enabled, software_enabled, - hourly, daily, weekly, monthly, yearly, - delete_old): + 'snapshots should be configured with free_space {free_space:d}, ' + 'timeline snapshots {timeline_enabled:w}, software snapshots ' + '{software_enabled:w}, hourly limit {hourly:d}, daily limit ' + '{daily:d}, weekly limit {weekly:d}, monthly limit {monthly:d}, ' + 'yearly limit {yearly:d}')) +def snapshot_assert_configuration(browser, free_space, timeline_enabled, + software_enabled, hourly, daily, weekly, + monthly, yearly): timeline_enabled = (timeline_enabled == 'enabled') software_enabled = (software_enabled == 'enabled') - assert (timeline_enabled, software_enabled, hourly, daily, weekly, monthly, - yearly, delete_old) == system.snapshot_get_configuration(browser) + print(system.snapshot_get_configuration(browser)) + assert (free_space, timeline_enabled, software_enabled, hourly, daily, + weekly, monthly, + yearly) == system.snapshot_get_configuration(browser) @then(parsers.parse('the default app should be {app_name:w}')) @@ -360,4 +362,4 @@ def open_main_page(browser): @then(parsers.parse('the main page should be shown')) def main_page_is_shown(browser): - assert(browser.url.endswith('/plinth/')) + assert (browser.url.endswith('/plinth/')) diff --git a/functional_tests/support/system.py b/functional_tests/support/system.py index 6048c31e5..2dd67917d 100644 --- a/functional_tests/support/system.py +++ b/functional_tests/support/system.py @@ -102,11 +102,12 @@ def get_snapshot_count(browser): return len(browser.find_by_xpath('//tr')) - 1 -def snapshot_set_configuration(browser, timeline_enabled, software_enabled, - hourly, daily, weekly, monthly, yearly, - delete_old): +def snapshot_set_configuration(browser, free_space, timeline_enabled, + software_enabled, hourly, daily, weekly, + monthly, yearly): """Set the configuration for snapshots.""" nav_to_module(browser, 'snapshot') + browser.find_by_name('free_space').select(free_space / 100) browser.find_by_name('enable_timeline_snapshots').select( 'yes' if timeline_enabled else 'no') browser.find_by_name('enable_software_snapshots').select( @@ -116,21 +117,20 @@ def snapshot_set_configuration(browser, timeline_enabled, software_enabled, browser.find_by_name('weekly_limit').fill(weekly) browser.find_by_name('monthly_limit').fill(monthly) browser.find_by_name('yearly_limit').fill(yearly) - browser.find_by_name('number_min_age').fill(delete_old) submit(browser) def snapshot_get_configuration(browser): """Return the current configuration for snapshots.""" nav_to_module(browser, 'snapshot') - return (browser.find_by_name('enable_timeline_snapshots').value == 'yes', + return (int(float(browser.find_by_name('free_space').value) * 100), + browser.find_by_name('enable_timeline_snapshots').value == 'yes', browser.find_by_name('enable_software_snapshots').value == 'yes', int(browser.find_by_name('hourly_limit').value), int(browser.find_by_name('daily_limit').value), int(browser.find_by_name('weekly_limit').value), int(browser.find_by_name('monthly_limit').value), - int(browser.find_by_name('yearly_limit').value), - int(browser.find_by_name('number_min_age').value)) + int(browser.find_by_name('yearly_limit').value)) def check_home_page_redirect(browser, app_name):