From 2c1372c26df252c73846e39788d209215072b43b Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 18 Oct 2018 15:05:20 -0700 Subject: [PATCH] snapshot: Add functional tests for setting configuration Reviewed-by: James Valleroy --- .../features/storage_snapshots.feature | 5 ++ functional_tests/step_definitions/system.py | 50 +++++++++++++++++++ functional_tests/support/system.py | 31 ++++++++++++ 3 files changed, 86 insertions(+) diff --git a/functional_tests/features/storage_snapshots.feature b/functional_tests/features/storage_snapshots.feature index 7669867d5..05b526554 100644 --- a/functional_tests/features/storage_snapshots.feature +++ b/functional_tests/features/storage_snapshots.feature @@ -27,3 +27,8 @@ Scenario: Create a snapshot Given the list of snapshots is empty When I manually 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 diff --git a/functional_tests/step_definitions/system.py b/functional_tests/step_definitions/system.py index 3bd88cc00..a76cfdee9 100644 --- a/functional_tests/step_definitions/system.py +++ b/functional_tests/step_definitions/system.py @@ -97,6 +97,56 @@ def verify_snapshot_count(browser, count): assert num_snapshots == 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, + software_enabled, hourly, daily, weekly, + monthly, yearly, delete_old): + timeline_enabled = (timeline_enabled == 'enabled') + software_enabled = (software_enabled == 'enabled') + system.snapshot_set_configuration(browser, timeline_enabled, + software_enabled, hourly, daily, weekly, + monthly, yearly, delete_old) + + +@when( + parsers.parse( + 'I configure snapshots 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_set_configuration(browser, timeline_enabled, software_enabled, + hourly, daily, weekly, monthly, yearly, + delete_old): + timeline_enabled = (timeline_enabled == 'enabled') + software_enabled = (software_enabled == 'enabled') + system.snapshot_set_configuration(browser, timeline_enabled, + software_enabled, hourly, daily, weekly, + monthly, yearly, delete_old) + + +@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): + 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) + + @then(parsers.parse('the default app should be {app_name:w}')) def default_app_should_be(browser, app_name): assert system.check_home_page_redirect(browser, app_name) diff --git a/functional_tests/support/system.py b/functional_tests/support/system.py index 8287b412e..9da86b167 100644 --- a/functional_tests/support/system.py +++ b/functional_tests/support/system.py @@ -95,6 +95,37 @@ 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): + """Set the configuration for snapshots.""" + nav_to_module(browser, 'snapshot') + browser.find_by_name('enable_timeline_snapshots').select( + 'yes' if timeline_enabled else 'no') + browser.find_by_name('enable_software_snapshots').select( + 'yes' if software_enabled else 'no') + browser.find_by_name('hourly_limit').fill(hourly) + browser.find_by_name('daily_limit').fill(daily) + 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', + 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)) + + def check_home_page_redirect(browser, app_name): browser.visit(config['DEFAULT']['url']) return browser.find_by_xpath(