From 2bf652f4697fae5a2915b1804500ac61925a7979 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Thu, 6 Feb 2020 19:13:22 +0530 Subject: [PATCH] functional-tests: Use Name attribute in backups - The operations create backup, restore, delete and download are done based on the name of the backup archive. - Using select-all to uncheck all checkboxes for a minor speedup while creating backups. - Using the new name-based tests for backups for 3 apps Signed-off-by: Joseph Nuthalapati [sunil: Minor indentation fix] [sunil: Use older API for searching links in Splinter, no advantage with new] [sunil: Update patch for coturn and coquelicot] Signed-off-by: Sunil Mohan Adapa Reviewed-by: Sunil Mohan Adapa test use name fixes Signed-off-by: Sunil Mohan Adapa --- functional_tests/config.ini | 1 - functional_tests/features/backups.feature | 8 ++-- functional_tests/features/bind.feature | 4 +- functional_tests/features/coquelicot.feature | 4 +- functional_tests/features/coturn.feature | 4 +- .../features/date_and_time.feature | 4 +- functional_tests/features/deluge.feature | 4 +- functional_tests/features/dynamicdns.feature | 4 +- functional_tests/features/ejabberd.feature | 4 +- functional_tests/features/gitweb.feature | 4 +- functional_tests/features/ikiwiki.feature | 4 +- functional_tests/features/jsxc.feature | 4 +- functional_tests/features/mediawiki.feature | 4 +- functional_tests/features/mldonkey.feature | 4 +- .../features/monkeysphere.feature | 4 +- functional_tests/features/mumble.feature | 4 +- functional_tests/features/openvpn.feature | 4 +- functional_tests/features/pagekite.feature | 4 +- functional_tests/features/privoxy.feature | 4 +- functional_tests/features/quassel.feature | 4 +- functional_tests/features/roundcube.feature | 4 +- functional_tests/features/samba.feature | 4 +- functional_tests/features/searx.feature | 4 +- functional_tests/features/security.feature | 4 +- functional_tests/features/shadowsocks.feature | 4 +- functional_tests/features/sharing.feature | 4 +- functional_tests/features/ssh.feature | 4 +- .../features/storage_snapshots.feature | 4 +- functional_tests/features/syncthing.feature | 4 +- functional_tests/features/tahoe.feature | 4 +- functional_tests/features/tor.feature | 4 +- .../features/transmission.feature | 4 +- functional_tests/features/ttrss.feature | 4 +- functional_tests/features/upgrades.feature | 4 +- functional_tests/step_definitions/system.py | 27 +++++++----- functional_tests/support/system.py | 42 ++++++++++--------- 36 files changed, 107 insertions(+), 99 deletions(-) diff --git a/functional_tests/config.ini b/functional_tests/config.ini index ba78055e2..6f60c99c4 100644 --- a/functional_tests/config.ini +++ b/functional_tests/config.ini @@ -2,5 +2,4 @@ url = https://localhost:4430 username = tester password = testingtesting -delete_root_backup_archives = true samba_port = 4450 diff --git a/functional_tests/features/backups.feature b/functional_tests/features/backups.feature index d34e9adf1..0db1336f3 100644 --- a/functional_tests/features/backups.feature +++ b/functional_tests/features/backups.feature @@ -10,8 +10,8 @@ Background: Scenario: Browser waits for redirect after restoring a backup Given the bind application is enabled - When I create a backup of the bind app data - And I restore the bind app data backup + When I create a backup of the bind app data with name test_backups + And I restore the bind app data backup with name test_backups And I open the main page And I wait for 5 seconds Then the main page should be shown @@ -19,8 +19,8 @@ Scenario: Browser waits for redirect after restoring a backup Scenario: Download, upload and restore a backup Given the bind application is enabled When I set bind forwarders to 1.1.1.1 - And I create a backup of the bind app data + And I create a backup of the bind app data with name test_backups And I set bind forwarders to 1.0.0.1 - And I download the latest app data backup + And I download the app data backup with name test_backups And I restore the downloaded app data backup Then bind forwarders should be 1.1.1.1 diff --git a/functional_tests/features/bind.feature b/functional_tests/features/bind.feature index bdd3131aa..3fd02d314 100644 --- a/functional_tests/features/bind.feature +++ b/functional_tests/features/bind.feature @@ -35,10 +35,10 @@ Scenario: Backup and restore bind Given the bind application is enabled When I set bind forwarders to 1.1.1.1 And I disable bind DNSSEC - And I create a backup of the bind app data + And I create a backup of the bind app data with name test_bind And I set bind forwarders to 1.0.0.1 And I enable bind DNSSEC - And I restore the bind app data backup + And I restore the bind app data backup with name test_bind Then bind forwarders should be 1.1.1.1 And bind DNSSEC should be disabled diff --git a/functional_tests/features/coquelicot.feature b/functional_tests/features/coquelicot.feature index 1fff498b3..f15c4788c 100644 --- a/functional_tests/features/coquelicot.feature +++ b/functional_tests/features/coquelicot.feature @@ -41,10 +41,10 @@ Scenario: Backup and restore coquelicot When I modify the coquelicot upload password to beforebackup123 And I modify the maximum file size of coquelicot to 128 And I upload the sample local file to coquelicot with password beforebackup123 - And I create a backup of the coquelicot app data + And I create a backup of the coquelicot app data with name test_coquelicot And I modify the coquelicot upload password to afterbackup123 And I modify the maximum file size of coquelicot to 64 - And I restore the coquelicot app data backup + And I restore the coquelicot app data backup with name test_coquelicot And I download the uploaded file from coquelicot Then the coquelicot service should be running And I should be able to login to coquelicot with password beforebackup123 diff --git a/functional_tests/features/coturn.feature b/functional_tests/features/coturn.feature index b707c02fe..687f50389 100644 --- a/functional_tests/features/coturn.feature +++ b/functional_tests/features/coturn.feature @@ -17,9 +17,9 @@ Scenario: Enable coturn application # TODO: Improve this by checking that secret and domain did not change Scenario: Backup and restore coturn Given the coturn application is enabled - When I create a backup of the coturn app data + When I create a backup of the coturn app data with name test_coturn And I restore the coturn app data backup - Then the coturn service should be running + Then the coturn service should be running with name test_coturn Scenario: Disable coturn application Given the coturn application is enabled diff --git a/functional_tests/features/date_and_time.feature b/functional_tests/features/date_and_time.feature index 504057609..fa8e9d39f 100644 --- a/functional_tests/features/date_and_time.feature +++ b/functional_tests/features/date_and_time.feature @@ -25,7 +25,7 @@ Scenario: Set timezone Scenario: Backup and restore datetime When I set the time zone to Africa/Accra - And I create a backup of the datetime app data + And I create a backup of the datetime app data with name test_datetime And I set the time zone to Africa/Cairo - And I restore the datetime app data backup + And I restore the datetime app data backup with name test_datetime Then the time zone should be Africa/Accra diff --git a/functional_tests/features/deluge.feature b/functional_tests/features/deluge.feature index 802cd4877..2da871917 100644 --- a/functional_tests/features/deluge.feature +++ b/functional_tests/features/deluge.feature @@ -23,9 +23,9 @@ Scenario: Backup and restore deluge Given the deluge application is enabled When all torrents are removed from deluge And I upload a sample torrent to deluge - And I create a backup of the deluge app data + And I create a backup of the deluge app data with name test_deluge And all torrents are removed from deluge - And I restore the deluge app data backup + And I restore the deluge app data backup with name test_deluge Then the deluge service should be running And there should be 1 torrents listed in deluge diff --git a/functional_tests/features/dynamicdns.feature b/functional_tests/features/dynamicdns.feature index cded48a2a..57023cf0e 100644 --- a/functional_tests/features/dynamicdns.feature +++ b/functional_tests/features/dynamicdns.feature @@ -10,7 +10,7 @@ Background: Scenario: Backup and restore configuration Given dynamicdns is configured - When I create a backup of the dynamicdns app data + When I create a backup of the dynamicdns app data with name test_dynamicdns And I change the dynamicdns configuration - And I restore the dynamicdns app data backup + And I restore the dynamicdns app data backup with name test_dynamicdns Then dynamicdns should have the original configuration diff --git a/functional_tests/features/ejabberd.feature b/functional_tests/features/ejabberd.feature index 057ac6a66..f57d2c63d 100644 --- a/functional_tests/features/ejabberd.feature +++ b/functional_tests/features/ejabberd.feature @@ -26,9 +26,9 @@ Scenario: Disable message archive management Scenario: Backup and restore ejabberd Given the ejabberd application is enabled And I have added a contact to my roster - When I create a backup of the ejabberd app data + When I create a backup of the ejabberd app data with name test_ejabberd And I delete the contact from my roster - And I restore the ejabberd app data backup + And I restore the ejabberd app data backup with name test_ejabberd Then I should have a contact on my roster Scenario: Disable ejabberd application diff --git a/functional_tests/features/gitweb.feature b/functional_tests/features/gitweb.feature index 5f3be943b..d509199e2 100644 --- a/functional_tests/features/gitweb.feature +++ b/functional_tests/features/gitweb.feature @@ -36,9 +36,9 @@ Scenario: Delete repository Scenario: Backup and restore gitweb Given the gitweb application is enabled And a repository - When I create a backup of the gitweb app data + When I create a backup of the gitweb app data with name test_gitweb And I delete the repository - And I restore the gitweb app data backup + And I restore the gitweb app data backup with name test_gitweb Then the repository should be restored And the gitweb site should be available diff --git a/functional_tests/features/ikiwiki.feature b/functional_tests/features/ikiwiki.feature index e63d2e704..f25a0dae3 100644 --- a/functional_tests/features/ikiwiki.feature +++ b/functional_tests/features/ikiwiki.feature @@ -16,9 +16,9 @@ Scenario: Enable wiki application Scenario: Backup and restore wiki Given the wiki application is enabled When there is an ikiwiki wiki - And I create a backup of the ikiwiki app data + And I create a backup of the ikiwiki app data with name test_ikiwiki And I delete the ikiwiki wiki - And I restore the ikiwiki app data backup + And I restore the ikiwiki app data backup with name test_ikiwiki Then the ikiwiki wiki should be restored Scenario: Disable wiki application diff --git a/functional_tests/features/jsxc.feature b/functional_tests/features/jsxc.feature index 26c447562..677a1d033 100644 --- a/functional_tests/features/jsxc.feature +++ b/functional_tests/features/jsxc.feature @@ -13,6 +13,6 @@ Scenario: Install jsxc application Scenario: Backup and restore jsxc Given the jsxc application is installed - When I create a backup of the jsxc app data - And I restore the jsxc app data backup + When I create a backup of the jsxc app data with name test_jsxc + And I restore the jsxc app data backup with name test_jsxc Then the jsxc site should be available diff --git a/functional_tests/features/mediawiki.feature b/functional_tests/features/mediawiki.feature index 64b6e9bbd..e3b0de90f 100644 --- a/functional_tests/features/mediawiki.feature +++ b/functional_tests/features/mediawiki.feature @@ -65,10 +65,10 @@ Scenario: Upload SVG image Scenario: Backup and restore mediawiki Given the mediawiki application is enabled - When I create a backup of the mediawiki app data + When I create a backup of the mediawiki app data with name test_mediawiki When I enable mediawiki public registrations And I delete the mediawiki main page - And I restore the mediawiki app data backup + And I restore the mediawiki app data backup with name test_mediawiki Then the mediawiki main page should be restored Then the mediawiki site should allow creating accounts diff --git a/functional_tests/features/mldonkey.feature b/functional_tests/features/mldonkey.feature index 53d25f5f4..188366c0d 100644 --- a/functional_tests/features/mldonkey.feature +++ b/functional_tests/features/mldonkey.feature @@ -24,9 +24,9 @@ Scenario: Backup and restore mldonkey Given the mldonkey application is enabled When all ed2k files are removed from mldonkey And I upload a sample ed2k file to mldonkey - And I create a backup of the mldonkey app data + And I create a backup of the mldonkey app data with name test_mldonkey And all ed2k files are removed from mldonkey - And I restore the mldonkey app data backup + And I restore the mldonkey app data backup with name test_mldonkey Then the mldonkey service should be running And there should be 1 ed2k files listed in mldonkey diff --git a/functional_tests/features/monkeysphere.feature b/functional_tests/features/monkeysphere.feature index 0dda1b863..be30b4b45 100644 --- a/functional_tests/features/monkeysphere.feature +++ b/functional_tests/features/monkeysphere.feature @@ -29,7 +29,7 @@ Scenario: Publish HTTPS keys Scenario: Backup and restore monkeysphere When I import SSH key for mydomain.example in monkeysphere And I import HTTPS key for mydomain.example in monkeysphere - And I create a backup of the monkeysphere app data - And I restore the monkeysphere app data backup + And I create a backup of the monkeysphere app data with name test_monkeysphere + And I restore the monkeysphere app data backup with name test_monkeysphere Then the SSH key should imported for mydomain.example in monkeysphere And the HTTPS key should imported for mydomain.example in monkeysphere diff --git a/functional_tests/features/mumble.feature b/functional_tests/features/mumble.feature index ae6818172..1218201f7 100644 --- a/functional_tests/features/mumble.feature +++ b/functional_tests/features/mumble.feature @@ -17,8 +17,8 @@ Scenario: Enable mumble application # certificates are restored. Scenario: Backup and restore mumble Given the mumble application is enabled - When I create a backup of the mumble app data - And I restore the mumble app data backup + When I create a backup of the mumble app data with name test_mumble + And I restore the mumble app data backup with name test_mumble Then the mumble service should be running Scenario: Disable mumble application diff --git a/functional_tests/features/openvpn.feature b/functional_tests/features/openvpn.feature index 524b7c286..5ebe53e70 100644 --- a/functional_tests/features/openvpn.feature +++ b/functional_tests/features/openvpn.feature @@ -21,8 +21,8 @@ Scenario: Download openvpn profile Scenario: Backup and restore openvpn Given the openvpn application is enabled And I download openvpn profile - When I create a backup of the openvpn app data - And I restore the openvpn app data backup + When I create a backup of the openvpn app data with name test_openvpn + And I restore the openvpn app data backup with name test_openvpn Then the openvpn profile downloaded should be same as before Scenario: Disable openvpn application diff --git a/functional_tests/features/pagekite.feature b/functional_tests/features/pagekite.feature index ed829e4b5..1b6e32862 100644 --- a/functional_tests/features/pagekite.feature +++ b/functional_tests/features/pagekite.feature @@ -21,9 +21,9 @@ Scenario: Configure pagekite application Scenario: Backup and restore pagekite Given the pagekite application is enabled When I configure pagekite with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret - And I create a backup of the pagekite app data + And I create a backup of the pagekite app data with name test_pagekite And I configure pagekite with host afterbackup.example.com, port 8082, kite name afterbackup.example.com and kite secret afterbackupsecret - And I restore the pagekite app data backup + And I restore the pagekite app data backup with name test_pagekite Then the pagekite service should be running And pagekite should be configured with host beforebackup.example.com, port 8081, kite name beforebackup.example.com and kite secret beforebackupsecret diff --git a/functional_tests/features/privoxy.feature b/functional_tests/features/privoxy.feature index 4fb9bf157..66a1f133a 100644 --- a/functional_tests/features/privoxy.feature +++ b/functional_tests/features/privoxy.feature @@ -15,8 +15,8 @@ Scenario: Enable privoxy application Scenario: Backup and restore privoxy Given the privoxy application is enabled - When I create a backup of the privoxy app data - And I restore the privoxy app data backup + When I create a backup of the privoxy app data with name test_privoxy + And I restore the privoxy app data backup with name test_privoxy Then the privoxy service should be running Scenario: Disable privoxy application diff --git a/functional_tests/features/quassel.feature b/functional_tests/features/quassel.feature index 6223536ad..89a64b30b 100644 --- a/functional_tests/features/quassel.feature +++ b/functional_tests/features/quassel.feature @@ -16,8 +16,8 @@ Scenario: Enable quassel application # TODO: Improve this to actually check that data configured servers is restored. Scenario: Backup and restore quassel Given the quassel application is enabled - When I create a backup of the quassel app data - And I restore the quassel app data backup + When I create a backup of the quassel app data with name test_quassel + And I restore the quassel app data backup with name test_quassel Then the quassel service should be running Scenario: Disable quassel application diff --git a/functional_tests/features/roundcube.feature b/functional_tests/features/roundcube.feature index 2f446ed74..ee8ce3f27 100644 --- a/functional_tests/features/roundcube.feature +++ b/functional_tests/features/roundcube.feature @@ -15,8 +15,8 @@ Scenario: Enable roundcube application Scenario: Backup and restore roundcube Given the roundcube application is enabled - When I create a backup of the roundcube app data - And I restore the roundcube app data backup + When I create a backup of the roundcube app data with name test_roundcube + And I restore the roundcube app data backup with name test_roundcube Then the roundcube site should be available Scenario: Disable roundcube application diff --git a/functional_tests/features/samba.feature b/functional_tests/features/samba.feature index 1b5aaf7b9..c8936254d 100644 --- a/functional_tests/features/samba.feature +++ b/functional_tests/features/samba.feature @@ -40,9 +40,9 @@ Scenario: Disable open samba share Scenario: Backup and restore samba Given the samba application is enabled When I enable the home samba share - And I create a backup of the samba app data + And I create a backup of the samba app data with name test_samba And I disable the home samba share - And I restore the samba app data backup + And I restore the samba app data backup with name test_samba Then the samba service should be running And I can write to the home samba share diff --git a/functional_tests/features/searx.feature b/functional_tests/features/searx.feature index 735981ada..e0ca2db14 100644 --- a/functional_tests/features/searx.feature +++ b/functional_tests/features/searx.feature @@ -15,8 +15,8 @@ Scenario: Enable searx application Scenario: Backup and restore searx Given the searx application is enabled - When I create a backup of the searx app data - And I restore the searx app data backup + When I create a backup of the searx app data with name test_searx + And I restore the searx app data backup with name test_searx Then the searx site should be available Scenario: Enable public access diff --git a/functional_tests/features/security.feature b/functional_tests/features/security.feature index 5f1e42f2e..d9dba5b9a 100644 --- a/functional_tests/features/security.feature +++ b/functional_tests/features/security.feature @@ -14,9 +14,9 @@ Scenario: Disable restricted console logins Scenario: Backup and restore security When I enable restricted console logins - And I create a backup of the security app data + And I create a backup of the security app data with name test_security And I disable restricted console logins - And I restore the security app data backup + And I restore the security app data backup with name test_security Then restricted console logins should be enabled Scenario: Enable restricted console logins diff --git a/functional_tests/features/shadowsocks.feature b/functional_tests/features/shadowsocks.feature index cf26f14a7..866b077c0 100644 --- a/functional_tests/features/shadowsocks.feature +++ b/functional_tests/features/shadowsocks.feature @@ -17,9 +17,9 @@ Scenario: Enable shadowsocks application Scenario: Backup and restore shadowsocks Given the shadowsocks application is enabled When I configure shadowsocks with server example.com and password beforebackup123 - And I create a backup of the shadowsocks app data + And I create a backup of the shadowsocks app data with name test_shadowsocks And I configure shadowsocks with server example.org and password afterbackup123 - And I restore the shadowsocks app data backup + And I restore the shadowsocks app data backup with name test_shadowsocks Then the shadowsocks service should be running And shadowsocks should be configured with server example.com and password beforebackup123 diff --git a/functional_tests/features/sharing.feature b/functional_tests/features/sharing.feature index a6908cb55..b77669dc3 100644 --- a/functional_tests/features/sharing.feature +++ b/functional_tests/features/sharing.feature @@ -44,8 +44,8 @@ Scenario: Public share Scenario: Backup and restore sharing Given share tmp is not available When I add a share tmp from path /tmp for admin - And I create a backup of the sharing app data + And I create a backup of the sharing app data with name test_sharing And I remove share tmp - And I restore the sharing app data backup + And I restore the sharing app data backup with name test_sharing Then the share tmp should be listed from path /tmp for admin And the share tmp should be accessible diff --git a/functional_tests/features/ssh.feature b/functional_tests/features/ssh.feature index 519525053..e8a169508 100644 --- a/functional_tests/features/ssh.feature +++ b/functional_tests/features/ssh.feature @@ -22,6 +22,6 @@ Scenario: Disable ssh application # restored. Scenario: Backup and restore ssh Given the ssh application is enabled - When I create a backup of the ssh app data - And I restore the ssh app data backup + When I create a backup of the ssh app data with name test_ssh + And I restore the ssh app data backup with name test_ssh Then the ssh service should be running diff --git a/functional_tests/features/storage_snapshots.feature b/functional_tests/features/storage_snapshots.feature index cfb0eb672..8899499ad 100644 --- a/functional_tests/features/storage_snapshots.feature +++ b/functional_tests/features/storage_snapshots.feature @@ -20,7 +20,7 @@ Scenario: Configure snapshots Scenario: Backup and restore snapshot 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 create a backup of the snapshot app data with name test_storage_snapshots 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 + And I restore the snapshot app data backup with name test_storage_snapshots 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/features/syncthing.feature b/functional_tests/features/syncthing.feature index 932539233..84360256f 100644 --- a/functional_tests/features/syncthing.feature +++ b/functional_tests/features/syncthing.feature @@ -29,9 +29,9 @@ Scenario: Backup and restore syncthing Given the syncthing application is enabled And syncthing folder Test is not present When I add a folder /tmp as syncthing folder Test - And I create a backup of the syncthing app data + And I create a backup of the syncthing app data with name test_syncthing And I remove syncthing folder Test - And I restore the syncthing app data backup + And I restore the syncthing app data backup with name test_syncthing Then syncthing folder Test should be present Scenario: Disable syncthing application diff --git a/functional_tests/features/tahoe.feature b/functional_tests/features/tahoe.feature index c90ac6aa3..ad12c10b7 100644 --- a/functional_tests/features/tahoe.feature +++ b/functional_tests/features/tahoe.feature @@ -40,9 +40,9 @@ Scenario: Remove tahoe introducer Scenario: Backup and restore tahoe Given the tahoe application is enabled And backupdomain.example is a tahoe introducer - When I create a backup of the tahoe app data + When I create a backup of the tahoe app data with name test_tahoe And I remove backupdomain.example as a tahoe introducer - And I restore the tahoe app data backup + And I restore the tahoe app data backup with name test_tahoe Then the tahoe service should be running And backupdomain.example should be a tahoe connected introducer diff --git a/functional_tests/features/tor.feature b/functional_tests/features/tor.feature index 3cf89f833..80513816e 100644 --- a/functional_tests/features/tor.feature +++ b/functional_tests/features/tor.feature @@ -44,10 +44,10 @@ Scenario: Backup and restore tor And tor relay is enabled And tor bridge relay is enabled And tor hidden services are enabled - When I create a backup of the tor app data + When I create a backup of the tor app data with name test_tor And I disable tor relay And I disable tor hidden services - And I restore the tor app data backup + And I restore the tor app data backup with name test_tor Then the tor service should be running And tor relay should be enabled And tor bridge relay should be enabled diff --git a/functional_tests/features/transmission.feature b/functional_tests/features/transmission.feature index 5bb75f642..1b992c411 100644 --- a/functional_tests/features/transmission.feature +++ b/functional_tests/features/transmission.feature @@ -23,9 +23,9 @@ Scenario: Backup and restore transmission Given the transmission application is enabled When all torrents are removed from transmission And I upload a sample torrent to transmission - And I create a backup of the transmission app data + And I create a backup of the transmission app data with name test_transmission And all torrents are removed from transmission - And I restore the transmission app data backup + And I restore the transmission app data backup with name test_transmission Then the transmission service should be running And there should be 1 torrents listed in transmission diff --git a/functional_tests/features/ttrss.feature b/functional_tests/features/ttrss.feature index e3314cccf..d208e4f2a 100644 --- a/functional_tests/features/ttrss.feature +++ b/functional_tests/features/ttrss.feature @@ -16,9 +16,9 @@ Scenario: Enable ttrss application Scenario: Backup and restore ttrss Given the ttrss application is enabled And I subscribe to a feed in ttrss - When I create a backup of the ttrss app data + When I create a backup of the ttrss app data with name test_ttrss And I unsubscribe from the feed in ttrss - And I restore the ttrss app data backup + And I restore the ttrss app data backup with name test_ttrss Then the ttrss service should be running And I should be subscribed to the feed in ttrss diff --git a/functional_tests/features/upgrades.feature b/functional_tests/features/upgrades.feature index ff8551c3c..a196c4ea6 100644 --- a/functional_tests/features/upgrades.feature +++ b/functional_tests/features/upgrades.feature @@ -14,9 +14,9 @@ Scenario: Enable automatic upgrades Scenario: Backup and restore upgrades When I enable automatic upgrades - And I create a backup of the upgrades app data + And I create a backup of the upgrades app data with name test_upgrades And I disable automatic upgrades - And I restore the upgrades app data backup + And I restore the upgrades app data backup with name test_upgrades Then automatic upgrades should be enabled Scenario: Disable automatic upgrades diff --git a/functional_tests/step_definitions/system.py b/functional_tests/step_definitions/system.py index 96eb43c80..2eb70e629 100644 --- a/functional_tests/step_definitions/system.py +++ b/functional_tests/step_definitions/system.py @@ -167,22 +167,27 @@ def dynamicdns_has_original_config(session_browser): assert system.dynamicdns_has_original_config(session_browser) -@when(parsers.parse('I create a backup of the {app_name:w} app data')) -def backup_create(session_browser, app_name): - if config.getboolean('DEFAULT', 'delete_root_backup_archives'): - system.backup_delete_root_archives(session_browser) - system.backup_create(session_browser, app_name) +@when( + parsers.parse( + 'I create a backup of the {app_name:w} app data with name {archive_name:w}' + )) +def backup_create(session_browser, app_name, archive_name): + system.backup_create(session_browser, app_name, archive_name) -@when(parsers.parse('I download the latest app data backup')) -def backup_download(session_browser, downloaded_file_info): - file_path = system.download_latest_backup(session_browser) +@when( + parsers.parse('I download the app data backup with name {archive_name:w}')) +def backup_download(session_browser, downloaded_file_info, archive_name): + file_path = system.download_backup(session_browser, archive_name) downloaded_file_info['path'] = file_path -@when(parsers.parse('I restore the {app_name:w} app data backup')) -def backup_restore(session_browser, app_name): - system.backup_restore(session_browser, app_name) +@when( + parsers.parse( + 'I restore the {app_name:w} app data backup with name {archive_name:w}' + )) +def backup_restore(session_browser, app_name, archive_name): + system.backup_restore(session_browser, app_name, archive_name) @when(parsers.parse('I restore the downloaded app data backup')) diff --git a/functional_tests/support/system.py b/functional_tests/support/system.py index 20e79e243..dee5af398 100644 --- a/functional_tests/support/system.py +++ b/functional_tests/support/system.py @@ -190,22 +190,30 @@ def dynamicdns_change_config(browser): submit(browser) -def backup_delete_root_archives(browser): - """Delete all archives of the root borg repository""" - browser.visit(default_url + '/plinth/sys/backups/') - path = "//a[starts-with(@href,'/plinth/sys/backups/root/delete/')]" - while browser.find_by_xpath(path): - browser.find_by_xpath(path).first.click() +def _click_button_and_confirm(browser, href): + buttons = browser.find_link_by_href(href) + if buttons: + buttons.first.click() with wait_for_page_update(browser, expected_url='/plinth/sys/backups/'): submit(browser) -def backup_create(browser, app_name): +def backup_delete_archive_by_name(browser, archive_name): + nav_to_module(browser, 'backups') + href = f'/plinth/sys/backups/root/delete/{archive_name}/' + _click_button_and_confirm(browser, href) + + +def backup_create(browser, app_name, archive_name=None): application.install(browser, 'backups') + if archive_name: + backup_delete_archive_by_name(browser, archive_name) + browser.find_link_by_href('/plinth/sys/backups/create/').first.click() - for app in browser.find_by_css('input[type=checkbox]'): - app.uncheck() + browser.find_by_id('select-all').uncheck() + if archive_name: + browser.find_by_id('id_backups-name').fill(archive_name) # ensure the checkbox is scrolled into view browser.execute_script('window.scrollTo(0, 0)') @@ -213,13 +221,10 @@ def backup_create(browser, app_name): submit(browser) -def backup_restore(browser, app_name): +def backup_restore(browser, app_name, archive_name=None): nav_to_module(browser, 'backups') - path = "//a[starts-with(@href,'/plinth/sys/backups/root/restore-archive/')]" - # assume that want to restore the last (most recently created) backup - browser.find_by_xpath(path).last.click() - with wait_for_page_update(browser, expected_url='/plinth/sys/backups/'): - submit(browser) + href = f'/plinth/sys/backups/root/restore-archive/{archive_name}/' + _click_button_and_confirm(browser, href) def backup_upload_and_restore(browser, app_name, downloaded_file_path): @@ -234,11 +239,10 @@ def backup_upload_and_restore(browser, app_name, downloaded_file_path): submit(browser) -def download_latest_backup(browser): +def download_backup(browser, archive_name=None): nav_to_module(browser, 'backups') - path = "//a[starts-with(@href,'/plinth/sys/backups/root/download/')]" - ele = browser.driver.find_elements_by_xpath(path)[0] - url = ele.get_attribute('href') + href = f'/plinth/sys/backups/root/download/{archive_name}/' + url = config['DEFAULT']['url'] + href file_path = download_file_logged_in(browser, url, suffix='.tar.gz') return file_path